@flakiness/vitest 1.5.0 → 1.7.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 +2 -0
- package/lib/reporter.js +22 -11
- package/package.json +11 -8
- package/types/src/reporter.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -96,6 +96,8 @@ npx flakiness show ./flakiness-report
|
|
|
96
96
|
|
|
97
97
|
## Features
|
|
98
98
|
|
|
99
|
+
See [features.md](./features.md) for this reporter's status against the [Flakiness Report spec](https://github.com/flakiness/flakiness-report/blob/main/features.md).
|
|
100
|
+
|
|
99
101
|
### Test Location Tracking
|
|
100
102
|
|
|
101
103
|
When `includeTaskLocation: true` is set in your Vitest config, the reporter records the exact file, line, and column for each test. This enables precise navigation from the Flakiness.io dashboard back to your source code.
|
package/lib/reporter.js
CHANGED
|
@@ -4,11 +4,13 @@ import crypto from "crypto";
|
|
|
4
4
|
import assert from "node:assert";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import * as nodeUtil from "node:util";
|
|
7
|
+
import pkg from "../package.json" with { type: "json" };
|
|
7
8
|
const styleText = (format, text) => nodeUtil.styleText?.(format, text) ?? text;
|
|
8
9
|
class FKVitestReporter {
|
|
9
10
|
constructor(_options) {
|
|
10
11
|
this._options = _options;
|
|
11
12
|
}
|
|
13
|
+
_options;
|
|
12
14
|
_impl;
|
|
13
15
|
_vitest;
|
|
14
16
|
_logger = {
|
|
@@ -27,7 +29,7 @@ class FKVitestReporter {
|
|
|
27
29
|
}
|
|
28
30
|
onTestRunStart() {
|
|
29
31
|
assert(this._vitest, "onInit must be called before onTestRunStart");
|
|
30
|
-
this._impl = ReporterImpl.create(this._vitest.config.root, this._vitest.projects, this._options, this._logger, this._vitest.config.config);
|
|
32
|
+
this._impl = ReporterImpl.create(this._vitest.config.root, this._vitest.projects, this._options, this._logger, this._vitest.version, this._vitest.config.config);
|
|
31
33
|
}
|
|
32
34
|
async onTestRunEnd(testModules, unhandledErrors, reason) {
|
|
33
35
|
await this._impl?.onTestRunEnd(testModules, unhandledErrors, reason);
|
|
@@ -36,11 +38,12 @@ class FKVitestReporter {
|
|
|
36
38
|
}
|
|
37
39
|
const gTestToTestCaseId = /* @__PURE__ */ new WeakMap();
|
|
38
40
|
class ReporterImpl {
|
|
39
|
-
constructor(_worktree, projects, _commitId, _options, _logger, _configPath) {
|
|
41
|
+
constructor(_worktree, projects, _commitId, _options, _logger, _vitestVersion, _configPath) {
|
|
40
42
|
this._worktree = _worktree;
|
|
41
43
|
this._commitId = _commitId;
|
|
42
44
|
this._options = _options;
|
|
43
45
|
this._logger = _logger;
|
|
46
|
+
this._vitestVersion = _vitestVersion;
|
|
44
47
|
this._configPath = _configPath;
|
|
45
48
|
this._environments = projects.map((project) => ReportUtils.createEnvironment({
|
|
46
49
|
name: this._envName(project)
|
|
@@ -48,24 +51,26 @@ class ReporterImpl {
|
|
|
48
51
|
this._sampleSystem = this._sampleSystem.bind(this);
|
|
49
52
|
this._sampleSystem();
|
|
50
53
|
}
|
|
54
|
+
_worktree;
|
|
55
|
+
_commitId;
|
|
56
|
+
_options;
|
|
57
|
+
_logger;
|
|
58
|
+
_vitestVersion;
|
|
59
|
+
_configPath;
|
|
51
60
|
_telemetryTimer;
|
|
52
61
|
_cpuUtilization = new CPUUtilization({ precision: 10 });
|
|
53
62
|
_ramUtilization = new RAMUtilization({ precision: 10 });
|
|
54
63
|
_startTimestamp = Date.now();
|
|
55
64
|
_stdio = /* @__PURE__ */ new Map();
|
|
56
65
|
_environments = [];
|
|
57
|
-
static create(rootPath, projects, options, logger, config) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
worktree = GitWorktree.create(rootPath);
|
|
62
|
-
commitId = worktree.headCommitId();
|
|
63
|
-
return new ReporterImpl(worktree, projects, commitId, options, logger, config);
|
|
64
|
-
} catch (e) {
|
|
65
|
-
logger.warn(`[flakiness.io] Failed to fetch commit info - is this a git repo?`);
|
|
66
|
+
static create(rootPath, projects, options, logger, vitestVersion, config) {
|
|
67
|
+
const result = GitWorktree.initialize(rootPath);
|
|
68
|
+
if (!result.ok) {
|
|
69
|
+
logger.warn(`[flakiness.io] Failed to fetch commit info - is this a git repo? (${result.error})`);
|
|
66
70
|
logger.error(`[flakiness.io] Report is NOT generated.`);
|
|
67
71
|
return;
|
|
68
72
|
}
|
|
73
|
+
return new ReporterImpl(result.worktree, projects, result.commitId, options, logger, vitestVersion, config);
|
|
69
74
|
}
|
|
70
75
|
_sampleSystem() {
|
|
71
76
|
this._cpuUtilization.sample();
|
|
@@ -116,6 +121,7 @@ class ReporterImpl {
|
|
|
116
121
|
const fkTest = {
|
|
117
122
|
attempts: [],
|
|
118
123
|
title: testCase.name,
|
|
124
|
+
tags: testCase.tags?.length ? [...testCase.tags] : void 0,
|
|
119
125
|
location: testCase.location ? {
|
|
120
126
|
file: this._worktree.gitPath(testCase.module.moduleId),
|
|
121
127
|
column: testCase.location.column,
|
|
@@ -181,6 +187,7 @@ class ReporterImpl {
|
|
|
181
187
|
expectedStatus,
|
|
182
188
|
// TODO: ideally, we can differentiate STDIO between attempts.
|
|
183
189
|
// However, vitest doesn't let us do so easily.
|
|
190
|
+
// See https://github.com/vitest-dev/vitest/issues/10303
|
|
184
191
|
// We slice these arrays just to be safe: if someone downstream from us
|
|
185
192
|
// decides to push a new annotation, then they can do it per-attempt safely.
|
|
186
193
|
stdio: stdio.slice(),
|
|
@@ -196,6 +203,7 @@ class ReporterImpl {
|
|
|
196
203
|
expectedStatus,
|
|
197
204
|
// TODO: ideally, we can differentiate STDIO between attempts.
|
|
198
205
|
// However, vitest doesn't let us do so easily.
|
|
206
|
+
// See https://github.com/vitest-dev/vitest/issues/10303
|
|
199
207
|
stdio,
|
|
200
208
|
errors,
|
|
201
209
|
annotations
|
|
@@ -328,6 +336,9 @@ class ReporterImpl {
|
|
|
328
336
|
category: "vitest",
|
|
329
337
|
configPath: this._configPath ? this._worktree.gitPath(this._configPath) : void 0,
|
|
330
338
|
commitId: this._commitId,
|
|
339
|
+
generatedBy: { name: pkg.name, version: pkg.version },
|
|
340
|
+
testRunner: { name: "vitest", version: this._vitestVersion },
|
|
341
|
+
runtime: ReportUtils.detectRuntime(),
|
|
331
342
|
environments: this._environments,
|
|
332
343
|
startTimestamp: this._startTimestamp,
|
|
333
344
|
duration,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flakiness/vitest",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/reporter.js",
|
|
6
6
|
"keywords": [],
|
|
@@ -11,19 +11,22 @@
|
|
|
11
11
|
"url": "https://github.com/flakiness/vitest"
|
|
12
12
|
},
|
|
13
13
|
"type": "module",
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": "^20.17.0 || >=22.9.0"
|
|
16
|
+
},
|
|
14
17
|
"devDependencies": {
|
|
15
|
-
"@flakiness/vitest": "1.
|
|
16
|
-
"@types/node": "^25.
|
|
17
|
-
"@vitest/utils": "^4.
|
|
18
|
-
"esbuild": "^0.27.
|
|
18
|
+
"@flakiness/vitest": "1.6.0",
|
|
19
|
+
"@types/node": "^25.6.2",
|
|
20
|
+
"@vitest/utils": "^4.1.5",
|
|
21
|
+
"esbuild": "^0.27.7",
|
|
19
22
|
"kubik": "^0.24.0",
|
|
20
23
|
"tsx": "^4.21.0",
|
|
21
24
|
"typescript": "^5.9.3",
|
|
22
|
-
"vitest": "^4.
|
|
25
|
+
"vitest": "^4.1.5"
|
|
23
26
|
},
|
|
24
27
|
"dependencies": {
|
|
25
|
-
"@flakiness/flakiness-report": "^0.
|
|
26
|
-
"@flakiness/sdk": "^2.
|
|
28
|
+
"@flakiness/flakiness-report": "^0.34.0",
|
|
29
|
+
"@flakiness/sdk": "^3.2.0"
|
|
27
30
|
},
|
|
28
31
|
"scripts": {
|
|
29
32
|
"build": "kubik build.mts",
|
|
@@ -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;
|
|
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;AAMjD,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;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAMD,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,QAAQ;IAS3C,OAAO,CAAC,QAAQ;IAR5B,OAAO,CAAC,KAAK,CAAC,CAAe;IAC7B,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,OAAO,CAId;gBAEmB,QAAQ,EAAE,uBAAuB;IAGrD,gBAAgB,CAAC,MAAM,EAAE,cAAc;IAIjC,gBAAgB,CAAC,GAAG,EAAE,cAAc;IAI1C,MAAM,CAAC,MAAM,EAAE,MAAM;IAIrB,cAAc;IAOR,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,eAAe,EAAE,aAAa,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,gBAAgB;CAIrI"}
|