@flakiness/cucumberjs 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -2
- package/lib/formatter.js +16 -7
- package/package.json +4 -4
- package/types/src/formatter.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@ A custom CucumberJS formatter that generates Flakiness Reports from your Cucumbe
|
|
|
30
30
|
- [CI Integration](#ci-integration)
|
|
31
31
|
- [Configuration Options](#configuration-options)
|
|
32
32
|
- [`flakinessProject?: string`](#flakinessproject-string)
|
|
33
|
+
- [`title?: string`](#title-string)
|
|
33
34
|
- [`endpoint?: string`](#endpoint-string)
|
|
34
35
|
- [`token?: string`](#token-string)
|
|
35
36
|
- [`outputFolder?: string`](#outputfolder-string)
|
|
@@ -55,7 +56,10 @@ Add the formatter to your `cucumber.mjs`:
|
|
|
55
56
|
export default {
|
|
56
57
|
paths: ['features/**/*.feature'],
|
|
57
58
|
import: ['features/support/**/*.ts'],
|
|
58
|
-
format: [
|
|
59
|
+
format: [
|
|
60
|
+
'progress',
|
|
61
|
+
['@flakiness/cucumberjs', '.flakiness/cucumber-formatter.log'],
|
|
62
|
+
],
|
|
59
63
|
formatOptions: {
|
|
60
64
|
flakinessProject: 'my-org/my-project',
|
|
61
65
|
},
|
|
@@ -83,6 +87,8 @@ Reports are automatically uploaded to Flakiness.io after test completion. Authen
|
|
|
83
87
|
|
|
84
88
|
If upload fails, the report is still available locally in the output folder.
|
|
85
89
|
|
|
90
|
+
If you combine this formatter with a progress formatter, keep the progress formatter on `stdout` and redirect `@flakiness/cucumberjs` to a file as shown above. Upload status messages are printed to `stderr`, so the uploaded report URL stays visible in the terminal.
|
|
91
|
+
|
|
86
92
|
## Viewing Reports
|
|
87
93
|
|
|
88
94
|
After test execution, you can view the report using:
|
|
@@ -137,6 +143,18 @@ formatOptions: {
|
|
|
137
143
|
}
|
|
138
144
|
```
|
|
139
145
|
|
|
146
|
+
### `title?: string`
|
|
147
|
+
|
|
148
|
+
Optional human-readable report title. Typically used to name a CI run, matrix shard, or other execution group.
|
|
149
|
+
|
|
150
|
+
Defaults to the `FLAKINESS_TITLE` environment variable, or auto-detects from the CI environment if not set.
|
|
151
|
+
|
|
152
|
+
```javascript
|
|
153
|
+
formatOptions: {
|
|
154
|
+
title: 'Shard 1/4 — Linux Chrome',
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
140
158
|
### `endpoint?: string`
|
|
141
159
|
|
|
142
160
|
Custom Flakiness.io endpoint URL for uploading reports. Defaults to the `FLAKINESS_ENDPOINT` environment variable, or `https://flakiness.io` if not set.
|
|
@@ -189,9 +207,13 @@ Here's a complete example with all options:
|
|
|
189
207
|
export default {
|
|
190
208
|
paths: ['features/**/*.feature'],
|
|
191
209
|
import: ['features/support/**/*.ts'],
|
|
192
|
-
format: [
|
|
210
|
+
format: [
|
|
211
|
+
'progress',
|
|
212
|
+
['@flakiness/cucumberjs', '.flakiness/cucumber-formatter.log'],
|
|
213
|
+
],
|
|
193
214
|
formatOptions: {
|
|
194
215
|
flakinessProject: 'my-org/my-project',
|
|
216
|
+
title: 'My Test Run',
|
|
195
217
|
endpoint: process.env.FLAKINESS_ENDPOINT,
|
|
196
218
|
token: process.env.FLAKINESS_ACCESS_TOKEN,
|
|
197
219
|
outputFolder: './flakiness-report',
|
package/lib/formatter.js
CHANGED
|
@@ -13,6 +13,11 @@ import {
|
|
|
13
13
|
import fs from "node:fs";
|
|
14
14
|
import path from "node:path";
|
|
15
15
|
const CUCUMBER_LOG_MEDIA_TYPE = "text/x.cucumber.log+plain";
|
|
16
|
+
const STDERR_LOGGER = {
|
|
17
|
+
log: (...args) => console.error(...args),
|
|
18
|
+
warn: (...args) => console.error(...args),
|
|
19
|
+
error: (...args) => console.error(...args)
|
|
20
|
+
};
|
|
16
21
|
class FlakinessCucumberFormatter extends Formatter {
|
|
17
22
|
static documentation = "Generates a Flakiness report for a CucumberJS run.";
|
|
18
23
|
_config;
|
|
@@ -80,6 +85,7 @@ class FlakinessCucumberFormatter extends Formatter {
|
|
|
80
85
|
return;
|
|
81
86
|
}
|
|
82
87
|
const { attachments, suites } = await this._collectSuites(worktree);
|
|
88
|
+
const title = this._config.title ?? process.env.FLAKINESS_TITLE ?? CIUtils.runTitle();
|
|
83
89
|
const report = ReportUtils.normalizeReport({
|
|
84
90
|
category: "cucumberjs",
|
|
85
91
|
commitId,
|
|
@@ -90,6 +96,7 @@ class FlakinessCucumberFormatter extends Formatter {
|
|
|
90
96
|
})
|
|
91
97
|
],
|
|
92
98
|
flakinessProject: this._config.flakinessProject,
|
|
99
|
+
title,
|
|
93
100
|
suites,
|
|
94
101
|
startTimestamp: this._startTimestamp,
|
|
95
102
|
url: CIUtils.runUrl()
|
|
@@ -98,19 +105,20 @@ class FlakinessCucumberFormatter extends Formatter {
|
|
|
98
105
|
this._cpuUtilization.enrich(report);
|
|
99
106
|
this._ramUtilization.enrich(report);
|
|
100
107
|
await writeReport(report, attachments, this._outputFolder);
|
|
108
|
+
const command = showReportCommand(this._outputFolder);
|
|
109
|
+
console.error(`
|
|
110
|
+
To open last Flakiness report, run:
|
|
111
|
+
|
|
112
|
+
${command}
|
|
113
|
+
`);
|
|
101
114
|
const disableUpload = this._config.disableUpload ?? envBool("FLAKINESS_DISABLE_UPLOAD");
|
|
102
115
|
if (!disableUpload) {
|
|
103
116
|
await uploadReport(report, attachments, {
|
|
104
117
|
flakinessAccessToken: this._config.token,
|
|
105
|
-
flakinessEndpoint: this._config.endpoint
|
|
118
|
+
flakinessEndpoint: this._config.endpoint,
|
|
119
|
+
logger: STDERR_LOGGER
|
|
106
120
|
});
|
|
107
121
|
}
|
|
108
|
-
const command = showReportCommand(this._outputFolder);
|
|
109
|
-
this.log(`
|
|
110
|
-
To open last Flakiness report, run:
|
|
111
|
-
|
|
112
|
-
${command}
|
|
113
|
-
`);
|
|
114
122
|
}
|
|
115
123
|
async _collectSuites(worktree) {
|
|
116
124
|
const suitesByKey = /* @__PURE__ */ new Map();
|
|
@@ -193,6 +201,7 @@ function parseFormatterConfig(parsedArgvOptions) {
|
|
|
193
201
|
endpoint: typeof parsedArgvOptions.endpoint === "string" ? parsedArgvOptions.endpoint : void 0,
|
|
194
202
|
flakinessProject: typeof parsedArgvOptions.flakinessProject === "string" ? parsedArgvOptions.flakinessProject : void 0,
|
|
195
203
|
outputFolder: typeof parsedArgvOptions.outputFolder === "string" ? parsedArgvOptions.outputFolder : void 0,
|
|
204
|
+
title: typeof parsedArgvOptions.title === "string" ? parsedArgvOptions.title : void 0,
|
|
196
205
|
token: typeof parsedArgvOptions.token === "string" ? parsedArgvOptions.token : void 0
|
|
197
206
|
};
|
|
198
207
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flakiness/cucumberjs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/flakiness/cucumberjs.git"
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@flakiness/flakiness-report": "^0.
|
|
24
|
-
"@flakiness/sdk": "^2.
|
|
23
|
+
"@flakiness/flakiness-report": "^0.29.0",
|
|
24
|
+
"@flakiness/sdk": "^2.5.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@cucumber/cucumber": "^12.7.0",
|
|
28
28
|
"@cucumber/messages": "^32.2.0",
|
|
29
|
-
"@flakiness/cucumberjs": "1.
|
|
29
|
+
"@flakiness/cucumberjs": "1.1.1",
|
|
30
30
|
"@types/node": "^25.5.0",
|
|
31
31
|
"c8": "^11.0.0",
|
|
32
32
|
"esbuild": "^0.27.4",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAoB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAoB,MAAM,oBAAoB,CAAC;AAwDjE,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,SAAS;IAC/D,MAAM,CAAC,aAAa,SAAwD;IAE5E,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,eAAe,CAAyC;IAChE,OAAO,CAAC,eAAe,CAAyC;IAChE,OAAO,CAAC,eAAe,CAAoC;IAC3D,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,eAAe,CAAC,CAAiB;IAEzC,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,oBAAoB,CAAsC;IAClE,OAAO,CAAC,qBAAqB,CAAuC;gBAExD,OAAO,EAAE,iBAAiB;IA0BtC,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,mBAAmB;IAIZ,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAaxC,OAAO,CAAC,aAAa;YAMP,kBAAkB;YAuDlB,cAAc;CA4F7B"}
|