@flakiness/vitest 1.6.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/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
- let commitId;
59
- let worktree;
60
- try {
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();
@@ -331,6 +336,9 @@ class ReporterImpl {
331
336
  category: "vitest",
332
337
  configPath: this._configPath ? this._worktree.gitPath(this._configPath) : void 0,
333
338
  commitId: this._commitId,
339
+ generatedBy: { name: pkg.name, version: pkg.version },
340
+ testRunner: { name: "vitest", version: this._vitestVersion },
341
+ runtime: ReportUtils.detectRuntime(),
334
342
  environments: this._environments,
335
343
  startTimestamp: this._startTimestamp,
336
344
  duration,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flakiness/vitest",
3
- "version": "1.6.0",
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.5.0",
16
- "@types/node": "^25.3.3",
17
- "@vitest/utils": "^4.0.18",
18
- "esbuild": "^0.27.3",
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
25
  "vitest": "^4.1.5"
23
26
  },
24
27
  "dependencies": {
25
- "@flakiness/flakiness-report": "^0.29.0",
26
- "@flakiness/sdk": "^2.6.0"
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;AAKjD,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;IAC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