vitest-auto-spy 5.53.0 → 5.54.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/CHANGELOG.md +18 -1
- package/agent-docs/checklist.md +5 -2
- package/dist/cli.js +104 -17
- package/dist/perf-reporter.d.ts +10 -0
- package/dist/perf-reporter.js +10 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,22 @@ The latest released version here must always match the one published on
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
## [5.54.0] - 2026-09-30
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **`perf --json <reports> --gate` re-measures its suspects without `--command`.** The perf reporter
|
|
18
|
+
now records the Vitest config file the suite ran with (`configFile`, relative to `root`), and the
|
|
19
|
+
confirmation pass re-runs each suspect with `vitest run --config <that file>` over the suspects
|
|
20
|
+
only: one run per config when the reports came from several (`vitest.config.ts` and
|
|
21
|
+
`libs/tooling/vitest.config.ts`, say), read back as one second reading. A single slow reading on a
|
|
22
|
+
loaded runner now comes back as not reproduced instead of needing `--no-confirm` to fail anything.
|
|
23
|
+
The re-run has coverage off (`--coverage.enabled=false`), even when the first reading had it on:
|
|
24
|
+
coverage thresholds fail a run of a few files, and instrumentation is the harness's cost rather
|
|
25
|
+
than the test's, so a body over budget only because of instrumentation is not reproduced.
|
|
26
|
+
`--command` still takes precedence, and a report without `configFile` is not re-measured, as
|
|
27
|
+
before. The perf report format is version 6; versions 1–6 are read.
|
|
28
|
+
|
|
13
29
|
## [5.53.0] - 2026-09-29
|
|
14
30
|
|
|
15
31
|
### Added
|
|
@@ -6657,7 +6673,8 @@ moved under 1 %: `/angular` +192 B (+1.0 %) for the override queue and the HTTP
|
|
|
6657
6673
|
This copy ships with the package and carries 5.x only. Releases before 5.0.0 are in the
|
|
6658
6674
|
[full changelog](https://github.com/ASDAlexey/vitest-auto-spy/blob/master/CHANGELOG.md).
|
|
6659
6675
|
|
|
6660
|
-
[Unreleased]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.
|
|
6676
|
+
[Unreleased]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.54.0...HEAD
|
|
6677
|
+
[5.54.0]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.53.0...v5.54.0
|
|
6661
6678
|
[5.53.0]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.52.0...v5.53.0
|
|
6662
6679
|
[5.52.0]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.51.0...v5.52.0
|
|
6663
6680
|
[5.51.0]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.50.0...v5.51.0
|
package/agent-docs/checklist.md
CHANGED
|
@@ -254,8 +254,11 @@ test bodies, and the gate prints the slowest tests, the share in hooks against b
|
|
|
254
254
|
time went in the spec, in your code and by package. The report ends in two tables of what is over
|
|
255
255
|
budget and nothing else. And every candidate is re-measured on its own before it may fail anything: a
|
|
256
256
|
file that is fast when it has the machine to itself is reported as _not reproduced_, an `info` rather
|
|
257
|
-
than a finding.
|
|
258
|
-
|
|
257
|
+
than a finding. `--json` without `--command` re-measures too: the report records its Vitest config
|
|
258
|
+
file, and the gate runs `vitest run --config <it>` over the suspects, one run per config when the
|
|
259
|
+
reports came from several, with coverage off. Without a way to re-measure (a `--command` without
|
|
260
|
+
`{paths}`, a report from before the config was recorded), findings are warnings that fail nothing
|
|
261
|
+
unless `--no-confirm` says one reading is enough. Exit `1` is "over budget", exit `2` is "there was nothing
|
|
259
262
|
to judge" — including a red or unfinished (`partial`) suite, which the gate will not judge at all, since a failed test is
|
|
260
263
|
measured until its timeout and 30 s of timeout looks exactly like 30 s of slow code.
|
|
261
264
|
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { ownVersion, isDirectory, readProfile, formatFindings, outputWidth, painterFor, summarize, DOCTOR_CHECKS, writeTextFile, REPORT_SCHEMA, sortFindings, findingJson, tallyOf,
|
|
2
|
+
import { ownVersion, isDirectory, readProfile, formatFindings, outputWidth, painterFor, summarize, ownPackageRoot, DOCTOR_CHECKS, writeTextFile, REPORT_SCHEMA, sortFindings, findingJson, tallyOf, readTextFile, SCAN_CAP_ENV, scanCap, COVERAGE_MATCHING_DOCS, VITEST_5_PERF_DOCS, filterBySeverity, isSymlink, skillFrontmatter, toPosix, pathExists, NOTHING_TO_READ_DOCS, removeFile, parseJsonc, isRecord, extractSetupFiles, captures, gitignoreFilter, BARE_RUN_DOCS, MONOCHROME, findStringEnd, listRepositoryFiles, wrapText, isSkippedDirectory, versionFrom, stripColor, padStart, padEnd } from './cli-SELXGLDQ.js';
|
|
3
3
|
import { resolve, join, posix, relative, isAbsolute, dirname } from 'node:path';
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
5
|
import { createRequire } from 'node:module';
|
|
@@ -1654,7 +1654,7 @@ function foreignPragmaPass() {
|
|
|
1654
1654
|
}
|
|
1655
1655
|
|
|
1656
1656
|
// src/cli/checks/export-map.generated.ts
|
|
1657
|
-
var EXPORT_MAP_VERSION = "5.
|
|
1657
|
+
var EXPORT_MAP_VERSION = "5.53.0";
|
|
1658
1658
|
var ENTRY_SPECIFIERS = "vitest-auto-spy vitest-auto-spy/bun vitest-auto-spy/bun-angular vitest-auto-spy/node vitest-auto-spy/rstest vitest-auto-spy/rxjs vitest-auto-spy/console vitest-auto-spy/dom-stubs vitest-auto-spy/diagnostics vitest-auto-spy/jasmine vitest-auto-spy/jasmine-compat vitest-auto-spy/observer-spy vitest-auto-spy/angular vitest-auto-spy/angular/diagnostics vitest-auto-spy/angular/doubles vitest-auto-spy/angular/matchers vitest-auto-spy/angular-http vitest-auto-spy/angular-router vitest-auto-spy/signal-forms vitest-auto-spy/nestjs vitest-auto-spy/react vitest-auto-spy/vue vitest-auto-spy/svelte vitest-auto-spy/setup vitest-auto-spy/zone vitest-auto-spy/eslint-plugin vitest-auto-spy/perf-reporter";
|
|
1659
1659
|
var EXPORTED_BY = {
|
|
1660
1660
|
AccessorImplementations: "0 1 2 3 4 12 20 21 22",
|
|
@@ -4665,8 +4665,8 @@ var PERF_OUTPUT_ENV = "VITEST_AUTO_SPY_PERF_OUT";
|
|
|
4665
4665
|
var PERF_REPORTER_ENV = "VITEST_AUTO_SPY_PERF_REPORTER";
|
|
4666
4666
|
var PERF_PROFILE_ENV = "VITEST_AUTO_SPY_PERF_PROFILE";
|
|
4667
4667
|
var PERF_ISOLATE_ENV = "VITEST_AUTO_SPY_PERF_ISOLATE";
|
|
4668
|
-
var PERF_FORMAT_VERSION =
|
|
4669
|
-
var READABLE_VERSIONS = [1, 2, 3, 4, 5];
|
|
4668
|
+
var PERF_FORMAT_VERSION = 6;
|
|
4669
|
+
var READABLE_VERSIONS = [1, 2, 3, 4, 5, 6];
|
|
4670
4670
|
var CASE_FLOOR_MS = 100;
|
|
4671
4671
|
var CASES_PER_FILE = 5;
|
|
4672
4672
|
var OPTIONAL_FILE_NUMBERS = ["workerId", "lane", "start", "fetch", "setupFetch", "retries", "autoSpy"];
|
|
@@ -4811,7 +4811,8 @@ function parsePerfRun(text) {
|
|
|
4811
4811
|
...parsed["partial"] === true ? { partial: true } : {},
|
|
4812
4812
|
...end === "failed" || end === "interrupted" || end === "passed" ? { end } : {},
|
|
4813
4813
|
...parsed["hung"] === true ? { hung: true } : {},
|
|
4814
|
-
...coverage === void 0 ? {} : { coverage }
|
|
4814
|
+
...coverage === void 0 ? {} : { coverage },
|
|
4815
|
+
...typeof parsed["configFile"] === "string" && parsed["configFile"] !== "" ? { configFile: parsed["configFile"] } : {}
|
|
4815
4816
|
};
|
|
4816
4817
|
}
|
|
4817
4818
|
function sumOf(run, key) {
|
|
@@ -5385,7 +5386,8 @@ function finding3(candidate, severity, tail) {
|
|
|
5385
5386
|
};
|
|
5386
5387
|
}
|
|
5387
5388
|
var UNCONFIRMED = [
|
|
5388
|
-
"Measured once and never confirmed, so it fails nothing. Run the gate where the files can be re-measured
|
|
5389
|
+
"Measured once and never confirmed, so it fails nothing. Run the gate where the files can be re-measured \u2014",
|
|
5390
|
+
"a --command with {paths}, or a report whose perf reporter recorded the Vitest config \u2014",
|
|
5389
5391
|
"or pass --no-confirm to gate on a single reading."
|
|
5390
5392
|
].join(" ");
|
|
5391
5393
|
function rowOf(candidate, outcome, again) {
|
|
@@ -7450,6 +7452,11 @@ function reroot(path, from, to) {
|
|
|
7450
7452
|
return rest.startsWith("/") || rest.startsWith("\\") ? `${to}${rest}` : path;
|
|
7451
7453
|
}
|
|
7452
7454
|
var END_ORDER = ["interrupted", "failed", "passed"];
|
|
7455
|
+
function sharedConfigFile(inputs) {
|
|
7456
|
+
const configFiles = new Set(inputs.map((input) => input.run.configFile));
|
|
7457
|
+
const [configFile] = configFiles;
|
|
7458
|
+
return { shared: configFiles.size <= 1, configFile };
|
|
7459
|
+
}
|
|
7453
7460
|
function mergedRun(inputs) {
|
|
7454
7461
|
const runs2 = inputs.map((input) => input.run);
|
|
7455
7462
|
const vitest = runs2.find((run) => run.vitest !== void 0)?.vitest;
|
|
@@ -7457,6 +7464,7 @@ function mergedRun(inputs) {
|
|
|
7457
7464
|
const startups = runs2.flatMap((run) => run.startup === void 0 ? [] : [run.startup]);
|
|
7458
7465
|
const end = END_ORDER.find((reason) => runs2.some((run) => run.end === reason));
|
|
7459
7466
|
const coverages = runs2.flatMap((run) => run.coverage === void 0 ? [] : [run.coverage]);
|
|
7467
|
+
const configFile = sharedConfigFile(inputs);
|
|
7460
7468
|
const startup = startups.reduce((total, each) => ({ ms: total.ms + each.ms, workers: total.workers + each.workers }), {
|
|
7461
7469
|
ms: 0,
|
|
7462
7470
|
workers: 0
|
|
@@ -7474,7 +7482,8 @@ function mergedRun(inputs) {
|
|
|
7474
7482
|
...runs2.some((run) => run.partial === true) ? { partial: true } : {},
|
|
7475
7483
|
...end === void 0 ? {} : { end },
|
|
7476
7484
|
...runs2.some((run) => run.hung === true) ? { hung: true } : {},
|
|
7477
|
-
...coverages.length === 0 ? {} : { coverage: Math.max(...coverages) }
|
|
7485
|
+
...coverages.length === 0 ? {} : { coverage: Math.max(...coverages) },
|
|
7486
|
+
...configFile.shared && configFile.configFile !== void 0 ? { configFile: configFile.configFile } : {}
|
|
7478
7487
|
};
|
|
7479
7488
|
}
|
|
7480
7489
|
function mergeRuns(inputs) {
|
|
@@ -7483,15 +7492,18 @@ function mergeRuns(inputs) {
|
|
|
7483
7492
|
const carriedBy = /* @__PURE__ */ new Map();
|
|
7484
7493
|
const empty = [];
|
|
7485
7494
|
const offset = { workerId: 0, lane: 0 };
|
|
7495
|
+
const perFile = !sharedConfigFile(inputs).shared;
|
|
7486
7496
|
for (const input of inputs) {
|
|
7487
7497
|
const from = trimRoot(input.run.root);
|
|
7488
7498
|
const shift = { ...offset };
|
|
7499
|
+
const configFile = perFile ? input.run.configFile : void 0;
|
|
7489
7500
|
if (input.run.files.length === 0) {
|
|
7490
7501
|
empty.push(input.path);
|
|
7491
7502
|
}
|
|
7492
7503
|
for (const file of input.run.files) {
|
|
7493
7504
|
const path = reroot(file.file, from, root);
|
|
7494
|
-
const
|
|
7505
|
+
const placed2 = { ...file, file: path, ...configFile === void 0 ? {} : { configFile } };
|
|
7506
|
+
const moved = shifted(placed2, shift, offset);
|
|
7495
7507
|
const previous = kept.get(path);
|
|
7496
7508
|
carriedBy.set(path, [...carriedBy.get(path) ?? [], input.path]);
|
|
7497
7509
|
if (previous === void 0 || fileTotal(moved) > fileTotal(previous)) {
|
|
@@ -7726,13 +7738,22 @@ function vitestMajor3(cwd) {
|
|
|
7726
7738
|
function versionFlags(cwd) {
|
|
7727
7739
|
return (vitestMajor3(cwd) ?? 0) >= 5 ? ["--experimental.diagnostics=false"] : [];
|
|
7728
7740
|
}
|
|
7741
|
+
function configArgs(config) {
|
|
7742
|
+
return config === void 0 ? [] : ["--config", config, "--coverage.enabled=false"];
|
|
7743
|
+
}
|
|
7729
7744
|
function fromRun(options, spawn, packageRoot) {
|
|
7730
7745
|
const entry = join(options.cwd, "node_modules", "vitest", "vitest.mjs");
|
|
7731
7746
|
const reporter = reporterPath(packageRoot);
|
|
7732
|
-
const mismatch = bareRunWouldMeasureSomethingElse(options.profile);
|
|
7747
|
+
const mismatch = options.config === void 0 ? bareRunWouldMeasureSomethingElse(options.profile) : void 0;
|
|
7733
7748
|
if (mismatch !== void 0) {
|
|
7734
7749
|
return failed(mismatch);
|
|
7735
7750
|
}
|
|
7751
|
+
if (options.config !== void 0 && !pathExists(resolve(options.cwd, options.config))) {
|
|
7752
|
+
return failed(
|
|
7753
|
+
`The report was measured with the Vitest config ${options.config}, and there is no such file in ${options.cwd}. Run the gate in the checkout the report was written for, or pass --command.
|
|
7754
|
+
Docs: ${NOTHING_TO_READ_DOCS}`
|
|
7755
|
+
);
|
|
7756
|
+
}
|
|
7736
7757
|
if (!pathExists(entry)) {
|
|
7737
7758
|
return failed(
|
|
7738
7759
|
`No Vitest is installed in ${options.cwd}, so there is nothing to run. Install vitest there, then measure again.
|
|
@@ -7749,7 +7770,16 @@ Docs: ${NOTHING_TO_READ_DOCS}`
|
|
|
7749
7770
|
removeFile(target);
|
|
7750
7771
|
const spawned = timed(spawn, {
|
|
7751
7772
|
command: process.execPath,
|
|
7752
|
-
args: [
|
|
7773
|
+
args: [
|
|
7774
|
+
entry,
|
|
7775
|
+
"run",
|
|
7776
|
+
...configArgs(options.config),
|
|
7777
|
+
"--reporter=default",
|
|
7778
|
+
`--reporter=${reporter}`,
|
|
7779
|
+
"--logHeapUsage",
|
|
7780
|
+
...versionFlags(options.cwd),
|
|
7781
|
+
...options.paths
|
|
7782
|
+
],
|
|
7753
7783
|
cwd: options.cwd,
|
|
7754
7784
|
env: runEnv(options, target, reporter),
|
|
7755
7785
|
shell: false
|
|
@@ -7809,15 +7839,66 @@ function readPerfRun(options, spawn = spawnProcess, packageRoot = ownPackageRoot
|
|
|
7809
7839
|
const source = options.json === void 0 ? fromCommand(options, command, spawn, packageRoot) : fromFile(options.json, options.cwd);
|
|
7810
7840
|
return source.ok ? { ...source, command } : source;
|
|
7811
7841
|
}
|
|
7812
|
-
function
|
|
7842
|
+
function localRoot(root, cwd) {
|
|
7843
|
+
const here = relative(cwd, root);
|
|
7844
|
+
return root !== "" && !here.startsWith("..") && !isAbsolute(here) ? root : cwd;
|
|
7845
|
+
}
|
|
7846
|
+
function recordedConfigs(recorded, cwd) {
|
|
7847
|
+
const root = localRoot(recorded.root, cwd);
|
|
7848
|
+
const configs = /* @__PURE__ */ new Map();
|
|
7849
|
+
for (const [path, file] of measuredFiles(recorded, cwd)) {
|
|
7850
|
+
const configFile = file.configFile ?? recorded.configFile;
|
|
7851
|
+
if (configFile !== void 0) {
|
|
7852
|
+
configs.set(path, toPosix(relative(cwd, resolve(root, configFile))));
|
|
7853
|
+
}
|
|
7854
|
+
}
|
|
7855
|
+
return configs;
|
|
7856
|
+
}
|
|
7857
|
+
function mergeMeasured(measured) {
|
|
7858
|
+
return {
|
|
7859
|
+
ok: true,
|
|
7860
|
+
run: mergeRuns(measured.map((each, index) => ({ path: String(index), run: each.run }))).run,
|
|
7861
|
+
runFailed: measured.some((each) => each.runFailed),
|
|
7862
|
+
profiles: new Map(measured.flatMap((each) => [...new Map(each.profiles)]))
|
|
7863
|
+
};
|
|
7864
|
+
}
|
|
7865
|
+
function underRecordedConfigs(configs, remeasure) {
|
|
7866
|
+
return (paths) => {
|
|
7867
|
+
const groups = /* @__PURE__ */ new Map();
|
|
7868
|
+
for (const path of paths) {
|
|
7869
|
+
const config = configs.get(path);
|
|
7870
|
+
if (config !== void 0) {
|
|
7871
|
+
groups.set(config, [...groups.get(config) ?? [], path]);
|
|
7872
|
+
}
|
|
7873
|
+
}
|
|
7874
|
+
if (groups.size === 0) {
|
|
7875
|
+
return failed(
|
|
7876
|
+
`None of the files to re-measure is in a report that recorded its Vitest config. Pass --command to re-measure them.
|
|
7877
|
+
Docs: ${NOTHING_TO_READ_DOCS}`
|
|
7878
|
+
);
|
|
7879
|
+
}
|
|
7880
|
+
const measured = [];
|
|
7881
|
+
for (const [config, group] of groups) {
|
|
7882
|
+
const source = remeasure(group, config);
|
|
7883
|
+
if (!source.ok) {
|
|
7884
|
+
return source;
|
|
7885
|
+
}
|
|
7886
|
+
measured.push(source);
|
|
7887
|
+
}
|
|
7888
|
+
return mergeMeasured(measured);
|
|
7889
|
+
};
|
|
7890
|
+
}
|
|
7891
|
+
function perfRemeasure(options, spawn = spawnProcess, packageRoot = ownPackageRoot(), recorded) {
|
|
7813
7892
|
if (options.command !== void 0 && !commandTakesPaths(options.command)) {
|
|
7814
7893
|
return void 0;
|
|
7815
7894
|
}
|
|
7895
|
+
const profileDir = join(options.cwd, "node_modules", ".cache", "vitest-auto-spy", `profiles-${process.pid}`);
|
|
7896
|
+
const scoped = { ...options, json: void 0, out: void 0, profileDir };
|
|
7816
7897
|
if (options.command === void 0 && options.json !== void 0) {
|
|
7817
|
-
|
|
7898
|
+
const configs = recorded === void 0 ? /* @__PURE__ */ new Map() : recordedConfigs(recorded, options.cwd);
|
|
7899
|
+
return configs.size === 0 ? void 0 : underRecordedConfigs(configs, (paths, config) => readPerfRun({ ...scoped, paths, config }, spawn, packageRoot));
|
|
7818
7900
|
}
|
|
7819
|
-
|
|
7820
|
-
return (paths) => readPerfRun({ ...options, json: void 0, out: void 0, paths, profileDir }, spawn, packageRoot);
|
|
7901
|
+
return (paths) => readPerfRun({ ...scoped, paths }, spawn, packageRoot);
|
|
7821
7902
|
}
|
|
7822
7903
|
function perfAbIsolate(options, spawn, packageRoot = ownPackageRoot()) {
|
|
7823
7904
|
if (options.command === void 0 && options.json !== void 0) {
|
|
@@ -7901,7 +7982,7 @@ function baselineRequest(args, cwd) {
|
|
|
7901
7982
|
}
|
|
7902
7983
|
};
|
|
7903
7984
|
}
|
|
7904
|
-
var PROFILE_DIR_UNUSED = "warning --profile-dir keeps the profiles the gate's confirmation pass records, and this run has no such pass: add --gate, without --no-confirm, on a source it can run again.\n";
|
|
7985
|
+
var PROFILE_DIR_UNUSED = "warning --profile-dir keeps the profiles the gate's confirmation pass records, and this run has no such pass: add --gate, without --no-confirm, on a source it can run again \u2014 a run, a --command with {paths}, or a report that recorded its Vitest config.\n";
|
|
7905
7986
|
function perfCommand(cwd, argv, io) {
|
|
7906
7987
|
const args = parseArgs(argv);
|
|
7907
7988
|
const format = formatOf(args);
|
|
@@ -7918,7 +7999,13 @@ function perfCommand(cwd, argv, io) {
|
|
|
7918
7999
|
...keepProfiles === void 0 ? {} : { keepProfiles: resolve(cwd, keepProfiles) }
|
|
7919
8000
|
};
|
|
7920
8001
|
const trustSingle = flagEnabled(args, "no-confirm");
|
|
7921
|
-
const
|
|
8002
|
+
const handed = options.json === void 0 ? void 0 : readPerfRun(options, spawn);
|
|
8003
|
+
const recorded = handed?.ok === true ? handed.run : void 0;
|
|
8004
|
+
const gate = flagEnabled(args, "gate") ? {
|
|
8005
|
+
options: gateOptions(args),
|
|
8006
|
+
remeasure: trustSingle ? void 0 : perfRemeasure(options, spawn, ownPackageRoot(), recorded),
|
|
8007
|
+
trustSingle
|
|
8008
|
+
} : void 0;
|
|
7922
8009
|
if (keepProfiles !== void 0 && gate?.remeasure === void 0) {
|
|
7923
8010
|
io.err(PROFILE_DIR_UNUSED);
|
|
7924
8011
|
}
|
|
@@ -7927,7 +8014,7 @@ function perfCommand(cwd, argv, io) {
|
|
|
7927
8014
|
const minSeverity = minSeverityOf(args);
|
|
7928
8015
|
const failOn = failOnOf(args);
|
|
7929
8016
|
const codeQuality = flagValue(args, "code-quality");
|
|
7930
|
-
return renderPerf(readPerfRun(options, spawn), profile, io, {
|
|
8017
|
+
return renderPerf(handed ?? readPerfRun(options, spawn), profile, io, {
|
|
7931
8018
|
budgets: gateOptions(args),
|
|
7932
8019
|
...format === "json" || format === "markdown" ? { format } : {},
|
|
7933
8020
|
...gate === void 0 ? {} : { gate },
|
package/dist/perf-reporter.d.ts
CHANGED
|
@@ -64,6 +64,8 @@ interface PerfFile {
|
|
|
64
64
|
readonly setupFetch?: number;
|
|
65
65
|
/** Failed attempts before a pass, summed over the file's tests. */
|
|
66
66
|
readonly retries?: number;
|
|
67
|
+
/** Set only by `mergeRuns`, when the merged reports ran different configs: this file's, as `PerfRun.configFile`. */
|
|
68
|
+
readonly configFile?: string;
|
|
67
69
|
}
|
|
68
70
|
/** What the run was configured with, read from Vitest's resolved config rather than the config text. */
|
|
69
71
|
interface PerfConfig {
|
|
@@ -108,6 +110,8 @@ interface PerfRun {
|
|
|
108
110
|
readonly hung?: boolean;
|
|
109
111
|
/** Milliseconds coverage took after the last file: generating the map, then writing the reports. */
|
|
110
112
|
readonly coverage?: number;
|
|
113
|
+
/** The Vitest config file the run loaded, relative to `root` with `/` separators; absent without one. */
|
|
114
|
+
readonly configFile?: string;
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
interface PerfDiagnostic {
|
|
@@ -208,6 +212,12 @@ interface PerfVitest {
|
|
|
208
212
|
readonly workersSpawned?: number;
|
|
209
213
|
};
|
|
210
214
|
readonly projects?: readonly PerfProject[];
|
|
215
|
+
/** Vite's resolved config holds the file Vitest loaded, on Vitest 4 and 5 alike; `configFile` is unset without one. */
|
|
216
|
+
readonly vite?: {
|
|
217
|
+
readonly config?: {
|
|
218
|
+
readonly configFile?: string | undefined;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
211
221
|
}
|
|
212
222
|
declare class PerfReporter {
|
|
213
223
|
#private;
|
package/dist/perf-reporter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { join, dirname, sep, basename } from 'node:path';
|
|
1
|
+
import { join, dirname, relative, sep, basename } from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { mkdirSync, writeFileSync, renameSync, rmSync, realpathSync, statSync } from 'node:fs';
|
|
4
4
|
|
|
@@ -39,7 +39,7 @@ var PERF_OUTPUT_ENV = "VITEST_AUTO_SPY_PERF_OUT";
|
|
|
39
39
|
var PERF_PROFILE_ENV = "VITEST_AUTO_SPY_PERF_PROFILE";
|
|
40
40
|
var PERF_ISOLATE_ENV = "VITEST_AUTO_SPY_PERF_ISOLATE";
|
|
41
41
|
var AUTO_SPY_META_KEY = "autoSpyMs";
|
|
42
|
-
var PERF_FORMAT_VERSION =
|
|
42
|
+
var PERF_FORMAT_VERSION = 6;
|
|
43
43
|
var CASE_FLOOR_MS = 100;
|
|
44
44
|
var CASES_PER_FILE = 5;
|
|
45
45
|
|
|
@@ -208,6 +208,10 @@ function configOf(vitest) {
|
|
|
208
208
|
...provided === void 0 ? {} : { provided: Object.keys(provided).filter((key) => provided[key] === true) }
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
+
function configFileOf(vitest) {
|
|
212
|
+
const file = vitest.vite?.config?.configFile;
|
|
213
|
+
return file === void 0 ? void 0 : toPosix(relative(vitest.config.root, file));
|
|
214
|
+
}
|
|
211
215
|
function startupOf(vitest) {
|
|
212
216
|
const { startupTime, workersSpawned } = vitest.state;
|
|
213
217
|
return startupTime === void 0 || workersSpawned === void 0 ? void 0 : { ms: startupTime, workers: workersSpawned };
|
|
@@ -232,9 +236,11 @@ var PerfReporter = class {
|
|
|
232
236
|
#ended;
|
|
233
237
|
#coverage;
|
|
234
238
|
#hung = false;
|
|
239
|
+
#configFile;
|
|
235
240
|
onInit(vitest) {
|
|
236
241
|
this.#vitest = vitest;
|
|
237
242
|
this.#start = Date.now();
|
|
243
|
+
this.#configFile = configFileOf(vitest);
|
|
238
244
|
if (target() === void 0 && !profiling()) {
|
|
239
245
|
return;
|
|
240
246
|
}
|
|
@@ -349,7 +355,8 @@ var PerfReporter = class {
|
|
|
349
355
|
...partial ? { partial: true } : {},
|
|
350
356
|
...end === void 0 ? {} : { end },
|
|
351
357
|
...this.#hung ? { hung: true } : {},
|
|
352
|
-
...this.#coverage === void 0 ? {} : { coverage: this.#coverage }
|
|
358
|
+
...this.#coverage === void 0 ? {} : { coverage: this.#coverage },
|
|
359
|
+
...this.#configFile === void 0 ? {} : { configFile: this.#configFile }
|
|
353
360
|
};
|
|
354
361
|
}
|
|
355
362
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-auto-spy",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.54.0",
|
|
4
4
|
"description": "Auto-generate fully-typed test spies from a class — across Vitest, Bun, node:test and Rstest, with Angular/NestJS/React/Vue/Svelte recipes. Drop-in replacement for jest-auto-spies and jasmine-auto-spies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auto-mock",
|