@flakiness/vitest 1.2.1 → 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 +13 -0
- package/lib/reporter.js +9 -7
- package/package.json +3 -4
- package/types/src/reporter.d.ts +1 -0
- package/types/src/reporter.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ A custom Vitest reporter that generates Flakiness Reports from your Vitest test
|
|
|
17
17
|
- [Environment Detection](#environment-detection)
|
|
18
18
|
- [CI Integration](#ci-integration)
|
|
19
19
|
- [Configuration Options](#configuration-options)
|
|
20
|
+
- [`title?: string`](#title-string)
|
|
20
21
|
- [`flakinessProject?: string`](#flakinessproject-string)
|
|
21
22
|
- [`endpoint?: string`](#endpoint-string)
|
|
22
23
|
- [`token?: string`](#token-string)
|
|
@@ -160,6 +161,16 @@ The reporter automatically detects CI environments and includes:
|
|
|
160
161
|
|
|
161
162
|
The reporter accepts the following options:
|
|
162
163
|
|
|
164
|
+
### `title?: string`
|
|
165
|
+
|
|
166
|
+
Optional human-readable report title. Typically used to name a CI run, matrix shard, or other execution group. Defaults to the `FLAKINESS_TITLE` environment variable, or auto-detects from the CI environment.
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
reporters: [
|
|
170
|
+
['@flakiness/vitest', { title: 'Shard 1/4 — Linux Chrome' }]
|
|
171
|
+
]
|
|
172
|
+
```
|
|
173
|
+
|
|
163
174
|
### `flakinessProject?: string`
|
|
164
175
|
|
|
165
176
|
The Flakiness.io project identifier in `org/project` format. Used for GitHub OIDC authentication — when set, and the Flakiness.io project is bound to the GitHub repository running the workflow, the reporter authenticates uploads via GitHub Actions OIDC token with no access token required.
|
|
@@ -235,6 +246,7 @@ reporters: [
|
|
|
235
246
|
|
|
236
247
|
The reporter respects the following environment variables:
|
|
237
248
|
|
|
249
|
+
- **`FLAKINESS_TITLE`**: Human-readable report title (equivalent to `title` option)
|
|
238
250
|
- **`FLAKINESS_ACCESS_TOKEN`**: Access token for Flakiness.io uploads (equivalent to `token` option)
|
|
239
251
|
- **`FLAKINESS_ENDPOINT`**: Custom Flakiness.io endpoint URL (equivalent to `endpoint` option)
|
|
240
252
|
- **`FLAKINESS_OUTPUT_DIR`**: Output directory for reports (equivalent to `outputFolder` option)
|
|
@@ -253,6 +265,7 @@ export default defineConfig({
|
|
|
253
265
|
reporters: [
|
|
254
266
|
'default',
|
|
255
267
|
['@flakiness/vitest', {
|
|
268
|
+
title: 'My Test Run',
|
|
256
269
|
flakinessProject: 'my-org/my-project',
|
|
257
270
|
endpoint: process.env.FLAKINESS_ENDPOINT,
|
|
258
271
|
token: process.env.FLAKINESS_ACCESS_TOKEN,
|
package/lib/reporter.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FlakinessReport as FK } from "@flakiness/flakiness-report";
|
|
2
|
-
import { CIUtils, CPUUtilization, GitWorktree, RAMUtilization, ReportUtils, uploadReport, writeReport } from "@flakiness/sdk";
|
|
3
|
-
import chalk from "chalk";
|
|
2
|
+
import { CIUtils, CPUUtilization, GitWorktree, RAMUtilization, ReportUtils, showReportCommand, uploadReport, writeReport } from "@flakiness/sdk";
|
|
4
3
|
import crypto from "crypto";
|
|
5
4
|
import assert from "node:assert";
|
|
6
5
|
import path from "node:path";
|
|
6
|
+
import * as nodeUtil from "node:util";
|
|
7
|
+
const styleText = (format, text) => nodeUtil.styleText?.(format, text) ?? text;
|
|
7
8
|
class FKVitestReporter {
|
|
8
9
|
constructor(_options) {
|
|
9
10
|
this._options = _options;
|
|
@@ -11,8 +12,8 @@ class FKVitestReporter {
|
|
|
11
12
|
_impl;
|
|
12
13
|
_vitest;
|
|
13
14
|
_logger = {
|
|
14
|
-
warn: (txt) => console.warn(
|
|
15
|
-
error: (txt) => console.error(
|
|
15
|
+
warn: (txt) => console.warn(styleText("yellow", txt)),
|
|
16
|
+
error: (txt) => console.error(styleText("red", txt)),
|
|
16
17
|
log: (txt) => console.log(txt)
|
|
17
18
|
};
|
|
18
19
|
setLoggerForTest(logger) {
|
|
@@ -320,7 +321,9 @@ class ReporterImpl {
|
|
|
320
321
|
}
|
|
321
322
|
}
|
|
322
323
|
const duration = Date.now() - this._startTimestamp;
|
|
324
|
+
const title = this._options.title ?? process.env.FLAKINESS_TITLE ?? CIUtils.runTitle();
|
|
323
325
|
const report = ReportUtils.normalizeReport({
|
|
326
|
+
title,
|
|
324
327
|
url: CIUtils.runUrl(),
|
|
325
328
|
flakinessProject: this._options.flakinessProject,
|
|
326
329
|
category: "vitest",
|
|
@@ -355,12 +358,11 @@ class ReporterImpl {
|
|
|
355
358
|
logger: this._logger
|
|
356
359
|
});
|
|
357
360
|
}
|
|
358
|
-
const
|
|
359
|
-
const folder = defaultOutputFolder === outputFolder ? "" : path.relative(process.cwd(), outputFolder);
|
|
361
|
+
const command = showReportCommand(outputFolder);
|
|
360
362
|
this._logger.log(`
|
|
361
363
|
To open last Flakiness report, run:
|
|
362
364
|
|
|
363
|
-
${
|
|
365
|
+
${styleText("cyan", command)}
|
|
364
366
|
`);
|
|
365
367
|
}
|
|
366
368
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flakiness/vitest",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/reporter.js",
|
|
6
6
|
"keywords": [],
|
|
@@ -22,9 +22,8 @@
|
|
|
22
22
|
"vitest": "^4.0.18"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@flakiness/flakiness-report": "^0.
|
|
26
|
-
"@flakiness/sdk": "^2.
|
|
27
|
-
"chalk": "^5.6.2"
|
|
25
|
+
"@flakiness/flakiness-report": "^0.29.0",
|
|
26
|
+
"@flakiness/sdk": "^2.5.0"
|
|
28
27
|
},
|
|
29
28
|
"scripts": {
|
|
30
29
|
"build": "kubik build.mts",
|
package/types/src/reporter.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../src/reporter.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAY,UAAU,EAAe,gBAAgB,EAAa,MAAM,EAAE,MAAM,aAAa,CAAC;AAC3H,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,GAAC,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../src/reporter.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAY,UAAU,EAAe,gBAAgB,EAAa,MAAM,EAAE,MAAM,aAAa,CAAC;AAC3H,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC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