@flakiness/playwright 1.3.2 → 1.4.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 +15 -1
- package/lib/playwright-test.js +20 -13
- package/package.json +6 -5
- package/types/src/playwright-test.d.ts +1 -0
- package/types/src/playwright-test.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[](https://flakiness.io/flakiness/playwright)
|
|
2
|
+
|
|
1
3
|
# Flakiness.io Playwright Reporter
|
|
2
4
|
|
|
3
5
|
A custom Playwright test reporter that generates Flakiness Reports from your Playwright test runs. The reporter automatically converts Playwright test results into the standardized [Flakiness JSON format](https://github.com/flakiness/flakiness-report), capturing test outcomes, attachments, system utilization, and environment information.
|
|
@@ -20,6 +22,7 @@ A custom Playwright test reporter that generates Flakiness Reports from your Pla
|
|
|
20
22
|
- [`outputFolder?: string`](#outputfolder-string)
|
|
21
23
|
- [`open?: 'always' | 'never' | 'on-failure'`](#open-always--never--on-failure)
|
|
22
24
|
- [`collectBrowserVersions?: boolean`](#collectbrowserversions-boolean)
|
|
25
|
+
- [`disableUpload?: boolean`](#disableupload-boolean)
|
|
23
26
|
- [Environment Variables](#environment-variables)
|
|
24
27
|
- [Example Configuration](#example-configuration)
|
|
25
28
|
|
|
@@ -202,6 +205,16 @@ reporter: [
|
|
|
202
205
|
]
|
|
203
206
|
```
|
|
204
207
|
|
|
208
|
+
### `disableUpload?: boolean`
|
|
209
|
+
|
|
210
|
+
When set to `true`, the reporter will skip uploading the report to Flakiness.io. The report is still generated locally in the output folder. This is useful for local development or testing the reporter itself. Can also be enabled via the `FLAKINESS_DISABLE_UPLOAD` environment variable.
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
reporter: [
|
|
214
|
+
['@flakiness/playwright', { disableUpload: true }]
|
|
215
|
+
]
|
|
216
|
+
```
|
|
217
|
+
|
|
205
218
|
## Environment Variables
|
|
206
219
|
|
|
207
220
|
The reporter respects the following environment variables:
|
|
@@ -209,6 +222,7 @@ The reporter respects the following environment variables:
|
|
|
209
222
|
- **`FLAKINESS_ACCESS_TOKEN`**: Access token for Flakiness.io uploads (equivalent to `token` option)
|
|
210
223
|
- **`FLAKINESS_ENDPOINT`**: Custom Flakiness.io endpoint URL (equivalent to `endpoint` option)
|
|
211
224
|
- **`FLAKINESS_OUTPUT_DIR`**: Output directory for reports (equivalent to `outputFolder` option)
|
|
225
|
+
- **`FLAKINESS_DISABLE_UPLOAD`**: When set, disables report upload (equivalent to `disableUpload` option)
|
|
212
226
|
|
|
213
227
|
|
|
214
228
|
|
|
@@ -228,9 +242,9 @@ export default defineConfig({
|
|
|
228
242
|
outputFolder: './flakiness-report',
|
|
229
243
|
open: 'on-failure',
|
|
230
244
|
collectBrowserVersions: false,
|
|
245
|
+
disableUpload: false,
|
|
231
246
|
}]
|
|
232
247
|
],
|
|
233
248
|
// ... rest of your config
|
|
234
249
|
});
|
|
235
250
|
```
|
|
236
|
-
|
package/lib/playwright-test.js
CHANGED
|
@@ -3,16 +3,18 @@ import {
|
|
|
3
3
|
GitWorktree,
|
|
4
4
|
ReportUtils,
|
|
5
5
|
showReport,
|
|
6
|
+
showReportCommand,
|
|
6
7
|
CPUUtilization,
|
|
7
8
|
RAMUtilization,
|
|
8
9
|
uploadReport,
|
|
9
10
|
writeReport
|
|
10
11
|
} from "@flakiness/sdk";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
const
|
|
15
|
-
const
|
|
12
|
+
import fs from "node:fs";
|
|
13
|
+
import path from "node:path";
|
|
14
|
+
import * as nodeUtil from "node:util";
|
|
15
|
+
const styleText = (format, text) => nodeUtil.styleText?.(format, text) ?? text;
|
|
16
|
+
const warn = (txt) => console.warn(styleText("yellow", `[flakiness.io] ${txt}`));
|
|
17
|
+
const err = (txt) => console.error(styleText("red", `[flakiness.io] ${txt}`));
|
|
16
18
|
const log = (txt) => console.log(`[flakiness.io] ${txt}`);
|
|
17
19
|
function parseDurationMS(value) {
|
|
18
20
|
if (isNaN(value))
|
|
@@ -27,7 +29,7 @@ async function existsAsync(aPath) {
|
|
|
27
29
|
class FlakinessReporter {
|
|
28
30
|
constructor(_options = {}) {
|
|
29
31
|
this._options = _options;
|
|
30
|
-
this._outputFolder = path.
|
|
32
|
+
this._outputFolder = path.resolve(process.cwd(), this._options.outputFolder ?? process.env.FLAKINESS_OUTPUT_DIR ?? "flakiness-report");
|
|
31
33
|
this._sampleSystem = this._sampleSystem.bind(this);
|
|
32
34
|
this._sampleSystem();
|
|
33
35
|
}
|
|
@@ -253,25 +255,30 @@ class FlakinessReporter {
|
|
|
253
255
|
async onExit() {
|
|
254
256
|
if (!this._report)
|
|
255
257
|
return;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
const disableUpload = this._options.disableUpload ?? envBool("FLAKINESS_DISABLE_UPLOAD");
|
|
259
|
+
if (!disableUpload) {
|
|
260
|
+
await uploadReport(this._report, this._attachments, {
|
|
261
|
+
flakinessAccessToken: this._options.token,
|
|
262
|
+
flakinessEndpoint: this._options.endpoint
|
|
263
|
+
});
|
|
264
|
+
}
|
|
260
265
|
const openMode = this._options.open ?? "on-failure";
|
|
261
266
|
const shouldOpen = process.stdin.isTTY && !process.env.CI && (openMode === "always" || openMode === "on-failure" && this._result?.status === "failed");
|
|
262
267
|
if (shouldOpen) {
|
|
263
268
|
await showReport(this._outputFolder);
|
|
264
269
|
} else {
|
|
265
|
-
const
|
|
266
|
-
const folder = defaultOutputFolder === this._outputFolder ? "" : path.relative(process.cwd(), this._outputFolder);
|
|
270
|
+
const command = showReportCommand(this._outputFolder);
|
|
267
271
|
console.log(`
|
|
268
272
|
To open last Flakiness report, run:
|
|
269
273
|
|
|
270
|
-
${
|
|
274
|
+
${styleText("cyan", command)}
|
|
271
275
|
`);
|
|
272
276
|
}
|
|
273
277
|
}
|
|
274
278
|
}
|
|
279
|
+
function envBool(name) {
|
|
280
|
+
return ["1", "true"].includes(process.env[name]?.toLowerCase() ?? "");
|
|
281
|
+
}
|
|
275
282
|
function toSTDIOEntry(data) {
|
|
276
283
|
if (Buffer.isBuffer(data))
|
|
277
284
|
return { buffer: data.toString("base64") };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flakiness/playwright",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"author": "Degu Labs, Inc",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"devDependencies": {
|
|
31
|
+
"@flakiness/playwright": "^1.3.2",
|
|
31
32
|
"@playwright/test": "^1.57.0",
|
|
32
33
|
"@types/node": "^25.0.3",
|
|
33
34
|
"esbuild": "^0.27.2",
|
|
@@ -36,12 +37,12 @@
|
|
|
36
37
|
"typescript": "^5.9.3"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@flakiness/flakiness-report": "^0.
|
|
40
|
-
"@flakiness/sdk": "2.
|
|
41
|
-
"chalk": "^5.6.2"
|
|
40
|
+
"@flakiness/flakiness-report": "^0.28.0",
|
|
41
|
+
"@flakiness/sdk": "2.4.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "kubik build.mts",
|
|
45
|
-
"watch": "kubik build.mts -w"
|
|
45
|
+
"watch": "kubik build.mts -w",
|
|
46
|
+
"test": "playwright test"
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwright-test.d.ts","sourceRoot":"","sources":["../../src/playwright-test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"playwright-test.d.ts","sourceRoot":"","sources":["../../src/playwright-test.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAC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