vitest 5.0.0-rc.1 → 5.0.0-rc.3

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.
Files changed (59) hide show
  1. package/dist/browser.d.ts +4 -4
  2. package/dist/browser.js +6 -6
  3. package/dist/chunks/{base.IQV3unVv.js → base.CZYgpg5z.js} +16 -15
  4. package/dist/chunks/{browser.d.Dp8LNQdx.d.ts → browser.d.g5Thl309.d.ts} +3 -3
  5. package/dist/chunks/{cac.CM6y_f_i.js → cac.AVSgLgX0.js} +10 -10
  6. package/dist/chunks/{cli-api.B4r6twmv.js → cli-api.BsG_KUyt.js} +29 -21
  7. package/dist/chunks/{config.d.BpALOMjL.d.ts → config.d.CU_b-wJj.d.ts} +14 -21
  8. package/dist/chunks/{console.DWNMLVgF.js → console.CHi0lDgQ.js} +2 -2
  9. package/dist/chunks/{coverage.CPiksdSj.js → coverage.BcXK1DsQ.js} +1 -1
  10. package/dist/chunks/{coverage.VANpXofm.js → coverage.BtDxDqSU.js} +1 -1
  11. package/dist/chunks/{creator.BW8mSwbG.js → creator.CYvpourF.js} +23 -13
  12. package/dist/chunks/{doctor.oxixVMjH.js → doctor.CzJ1dA-i.js} +2 -2
  13. package/dist/chunks/{environment.d.DCnG-EPE.d.ts → environment.d.C6xYahWA.d.ts} +9 -1
  14. package/dist/chunks/{globals.Dfl9zyCz.js → globals.B4gJ9mZH.js} +6 -6
  15. package/dist/chunks/{index.DRmbsPYf.js → index.CSoBZWW_.js} +36 -34
  16. package/dist/chunks/{index.DiRpHFrd.js → index.CVFiuVPx.js} +6048 -554
  17. package/dist/chunks/{index.BfU4rh_M.js → index.DQO7054M.js} +9 -3
  18. package/dist/chunks/{index.CCh1Pb8k.js → index.DmDMHCg8.js} +1 -1
  19. package/dist/chunks/{index.CePpwRnE.js → index.okypXZ97.js} +5 -5
  20. package/dist/chunks/{init-forks.BpFQPK_m.js → init-forks.BqnYxpzU.js} +7 -10
  21. package/dist/chunks/{init-threads.DspSJVVe.js → init-threads.CL4Y0HC6.js} +1 -1
  22. package/dist/chunks/{init.BU4khizz.js → init.DJ2lKyjE.js} +8 -7
  23. package/dist/chunks/{native.offEPk9l.js → native.cLbCmZDO.js} +1 -1
  24. package/dist/chunks/{nativeModuleMocker.0CD1hdFV.js → nativeModuleMocker.DBSXgC3F.js} +2 -2
  25. package/dist/chunks/{nativeModuleRunner.Bc3kXpWn.js → nativeModuleRunner.BOvBCgI_.js} +1 -1
  26. package/dist/chunks/{node.CS-X6Ymg.js → node.Es9ukMGX.js} +1 -1
  27. package/dist/chunks/{pathe.M-eThtNZ.k2RS39sQ.js → pathe.M-eThtNZ.Clq7AXhv.js} +1 -1
  28. package/dist/chunks/{plugin.d.xikpJNpD.d.ts → plugin.d.DAuMAWfb.d.ts} +455 -143
  29. package/dist/chunks/{resolver.B_5CI0Kh.js → resolver.CBCHRZ7j.js} +1 -1
  30. package/dist/chunks/{rpc.DaPTofpf.js → rpc.DWKX1ZbI.js} +3 -3
  31. package/dist/chunks/{rpc.d.DWQfGdI1.d.ts → rpc.d.DA9Utv4e.d.ts} +1 -1
  32. package/dist/chunks/{run.DS9d28OG.js → run.DyRH7m0-.js} +6 -9
  33. package/dist/chunks/{setup-common.D_kw2djf.js → setup-common.p8NqUXPi.js} +2 -2
  34. package/dist/chunks/{source-map.CTObTzjj.js → source-map.Dx3YPjIe.js} +2 -2
  35. package/dist/chunks/{source-map.d.DRVw4m2c.d.ts → source-map.d.YqWNcp4e.d.ts} +1 -1
  36. package/dist/chunks/{task-utils.d.B0b4kWzC.d.ts → task-utils.d.BZm4GSQD.d.ts} +1 -1
  37. package/dist/chunks/{utils.DtdLoSPT.js → utils.CtqmNjXD.js} +1 -1
  38. package/dist/chunks/{vm.QEFtWwx4.js → vm.gGBei5ET.js} +95 -60
  39. package/dist/chunks/{worker.d.D7LKSMQN.d.ts → worker.d.MLmnzOJE.d.ts} +3 -3
  40. package/dist/cli.js +2 -2
  41. package/dist/config.d.ts +10 -9
  42. package/dist/index.d.ts +13 -12
  43. package/dist/index.js +6 -6
  44. package/dist/module-evaluator.d.ts +3 -2
  45. package/dist/node.d.ts +17 -10
  46. package/dist/node.js +26 -17
  47. package/dist/runtime.d.ts +4 -4
  48. package/dist/runtime.js +4 -4
  49. package/dist/task-utils.js +1 -1
  50. package/dist/worker.d.ts +4 -4
  51. package/dist/worker.js +13 -13
  52. package/dist/workers/forks.js +14 -14
  53. package/dist/workers/runVmTests.js +10 -10
  54. package/dist/workers/threads.js +14 -14
  55. package/dist/workers/vmForks.js +11 -11
  56. package/dist/workers/vmThreads.js +11 -11
  57. package/package.json +22 -22
  58. package/dist/chunks/check.Cz_-YojU.js +0 -15
  59. package/dist/chunks/setup.CXTsmSEE.js +0 -5398
package/dist/browser.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { F as FileSpecification, c as SerializedDiffOptions } from './chunks/config.d.BpALOMjL.js';
1
+ import { F as FileSpecification, c as SerializedDiffOptions } from './chunks/config.d.CU_b-wJj.js';
2
2
  import { SerializedCoverageConfig, RunnerTestFile as File, SerializedConfig, DiffOptions, TestError } from './index.js';
3
3
  import { VitestRunner } from './runtime.js';
4
- export { P as ParsedStack, _ as SpyModule, d as StringifyOptions, f as format, i as inspect, s as stringify } from './chunks/config.d.BpALOMjL.js';
5
- import { R as RuntimeCoverageModuleLoader } from './chunks/source-map.d.DRVw4m2c.js';
6
- export { D as DecodedMap, g as getOriginalPosition } from './chunks/source-map.d.DRVw4m2c.js';
4
+ export { P as ParsedStack, _ as SpyModule, d as StringifyOptions, f as format, i as inspect, s as stringify } from './chunks/config.d.CU_b-wJj.js';
5
+ import { R as RuntimeCoverageModuleLoader } from './chunks/source-map.d.YqWNcp4e.js';
6
+ export { D as DecodedMap, g as getOriginalPosition } from './chunks/source-map.d.YqWNcp4e.js';
7
7
  import 'vitest/optional-runtime-types.js';
8
8
  import 'tinybench';
9
9
 
package/dist/browser.js CHANGED
@@ -1,11 +1,11 @@
1
- export { s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/coverage.VANpXofm.js';
2
- export { p as collectTests, a as processError, s as startTests } from './chunks/run.DS9d28OG.js';
3
- export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as setupEnv } from './chunks/setup-common.D_kw2djf.js';
1
+ export { s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/coverage.BtDxDqSU.js';
2
+ export { p as collectTests, a as processError, s as startTests } from './chunks/run.DyRH7m0-.js';
3
+ export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as setupEnv } from './chunks/setup-common.p8NqUXPi.js';
4
4
  export { s as SpyModule } from './chunks/spy.DPpyuUIA.js';
5
5
  export { f as format, i as inspect, s as stringify } from './chunks/display.pkpxlVcY.js';
6
- export { g as getType } from './chunks/pathe.M-eThtNZ.k2RS39sQ.js';
7
- export { D as DecodedMap, g as getOriginalPosition, a as getSafeTimers, s as setSafeTimers } from './chunks/source-map.CTObTzjj.js';
8
- import './chunks/coverage.CPiksdSj.js';
6
+ export { g as getType } from './chunks/pathe.M-eThtNZ.Clq7AXhv.js';
7
+ export { D as DecodedMap, g as getOriginalPosition, a as getSafeTimers, s as setSafeTimers } from './chunks/source-map.Dx3YPjIe.js';
8
+ import './chunks/coverage.BcXK1DsQ.js';
9
9
  import './chunks/index.M2dsQ_UQ.js';
10
10
  import './chunks/tinyrainbow.Ht9iggcq.js';
11
11
  import './task-utils.js';
@@ -1,21 +1,21 @@
1
1
  import { runInThisContext } from 'node:vm';
2
2
  import { s as spyModule } from './spy.DPpyuUIA.js';
3
- import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.CePpwRnE.js';
4
- import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.BU4khizz.js';
3
+ import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.okypXZ97.js';
4
+ import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.DJ2lKyjE.js';
5
5
  import { Traces } from '../traces.js';
6
- import { V as VitestEvaluatedModules } from './rpc.DaPTofpf.js';
7
- import { s as startVitestModuleRunner, c as createNodeImportMeta } from './index.BfU4rh_M.js';
6
+ import { V as VitestEvaluatedModules } from './rpc.DWKX1ZbI.js';
7
+ import { s as startVitestModuleRunner, c as createNodeImportMeta } from './index.DQO7054M.js';
8
8
  import { performance as performance$1 } from 'node:perf_hooks';
9
- import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './coverage.VANpXofm.js';
10
- import { i as index, g as globalExpect, v as vi } from './index.DRmbsPYf.js';
9
+ import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './coverage.BtDxDqSU.js';
10
+ import { i as index, g as globalExpect, v as vi } from './index.CSoBZWW_.js';
11
11
  import { c as closeInspector } from './inspector.CvyFGlXm.js';
12
- import { s as startTests, p as publicCollect } from './run.DS9d28OG.js';
12
+ import { s as startTests, p as publicCollect } from './run.DyRH7m0-.js';
13
13
  import { createRequire } from 'node:module';
14
14
  import timers from 'node:timers';
15
15
  import timersPromises from 'node:timers/promises';
16
16
  import util from 'node:util';
17
- import { K as KNOWN_ASSET_TYPES } from './pathe.M-eThtNZ.k2RS39sQ.js';
18
- import { s as setupCommonEnv, b as setupEnv } from './setup-common.D_kw2djf.js';
17
+ import { K as KNOWN_ASSET_TYPES } from './pathe.M-eThtNZ.Clq7AXhv.js';
18
+ import { s as setupCommonEnv, b as setupEnv } from './setup-common.p8NqUXPi.js';
19
19
  import { g as getWorkerState, r as resetModules, p as provideWorkerState, a as getSafeWorkerState } from './utils.DYj33du9.js';
20
20
 
21
21
  // this should only be used in Node
@@ -57,7 +57,7 @@ function resolveAsset(mod, url) {
57
57
  mod.exports = url;
58
58
  }
59
59
  async function setupConsoleLogSpy() {
60
- const { createCustomConsole } = await import('./console.DWNMLVgF.js');
60
+ const { createCustomConsole } = await import('./console.CHi0lDgQ.js');
61
61
  globalThis.console = createCustomConsole();
62
62
  }
63
63
 
@@ -108,17 +108,18 @@ const evaluatedModules = new VitestEvaluatedModules();
108
108
  const moduleExecutionInfo = /* @__PURE__ */ new Map();
109
109
  async function startModuleRunner(options) {
110
110
  if (_moduleRunner) return _moduleRunner;
111
+ const state = () => getSafeWorkerState() || options.state;
111
112
  process.exit = (code = process.exitCode || 0) => {
112
- throw new Error(`process.exit unexpectedly called with "${code}"`);
113
+ const filepath = state().filepath;
114
+ throw new Error(`process.exit unexpectedly called with "${code}"${filepath ? ` (test file: ${filepath})` : ""}`);
113
115
  };
114
- const state = () => getSafeWorkerState() || options.state;
115
116
  listenForErrors(state);
116
117
  if (options.state.config.experimental.viteModuleRunner === false) {
117
118
  const root = options.state.config.root;
118
119
  let mocker;
119
120
  if (options.state.config.experimental.nodeLoader !== false) {
120
121
  // this additionally imports acorn/magic-string
121
- const { NativeModuleMocker } = await import('./nativeModuleMocker.0CD1hdFV.js');
122
+ const { NativeModuleMocker } = await import('./nativeModuleMocker.DBSXgC3F.js');
122
123
  mocker = new NativeModuleMocker({
123
124
  async resolveId(id, importer) {
124
125
  // TODO: use import.meta.resolve instead
@@ -135,7 +136,7 @@ async function startModuleRunner(options) {
135
136
  }
136
137
  // imported lazily (pulls in `local-pkg`) so it stays out of the default
137
138
  // worker startup graph; only the `viteModuleRunner: false` path needs it
138
- const { NativeModuleRunner } = await import('./nativeModuleRunner.Bc3kXpWn.js').then(function (n) { return n.n; });
139
+ const { NativeModuleRunner } = await import('./nativeModuleRunner.BOvBCgI_.js').then(function (n) { return n.n; });
139
140
  _moduleRunner = new NativeModuleRunner(root, mocker);
140
141
  return _moduleRunner;
141
142
  }
@@ -147,7 +148,7 @@ let _environmentTime;
147
148
  /** @experimental */
148
149
  async function setupBaseEnvironment(context) {
149
150
  if (context.config.experimental.viteModuleRunner === false) {
150
- const { setupNodeLoaderHooks } = await import('./native.offEPk9l.js');
151
+ const { setupNodeLoaderHooks } = await import('./native.cLbCmZDO.js');
151
152
  await setupNodeLoaderHooks(context);
152
153
  }
153
154
  const startTime = performance.now();
@@ -1,6 +1,6 @@
1
- import { F as FileSpecification } from './config.d.BpALOMjL.js';
2
- import { O as OTELCarrier } from './rpc.d.DWQfGdI1.js';
3
- import { T as TestExecutionMethod } from './worker.d.D7LKSMQN.js';
1
+ import { F as FileSpecification } from './config.d.CU_b-wJj.js';
2
+ import { O as OTELCarrier } from './rpc.d.DA9Utv4e.js';
3
+ import { T as TestExecutionMethod } from './worker.d.MLmnzOJE.js';
4
4
 
5
5
  interface ModuleDefinitionLocation {
6
6
  line: number;
@@ -1,4 +1,4 @@
1
- import { n as normalize, t as toArray } from './pathe.M-eThtNZ.k2RS39sQ.js';
1
+ import { n as normalize, t as toArray } from './pathe.M-eThtNZ.Clq7AXhv.js';
2
2
  import { EventEmitter } from 'events';
3
3
  import { m } from './tinyrainbow.Ht9iggcq.js';
4
4
  import { a as isForceColor } from './env.DzFJjrmK.js';
@@ -620,7 +620,7 @@ class CAC extends EventEmitter {
620
620
 
621
621
  const cac = (name = "") => new CAC(name);
622
622
 
623
- var version = "5.0.0-rc.1";
623
+ var version = "5.0.0-rc.3";
624
624
 
625
625
  const apiConfig = (port) => ({
626
626
  port: {
@@ -1129,7 +1129,7 @@ const cliOptionsConfig = {
1129
1129
  },
1130
1130
  project: {
1131
1131
  shorthand: "p",
1132
- description: "The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: `--project=1 --project=2`. You can also filter projects using wildcards like `--project=packages*`, and exclude projects with `--project=!pattern`.",
1132
+ description: "The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: `--project=1 --project=2`. You can also filter projects using wildcards like `--project=packages*`, and exclude projects with `--project=!pattern`. A project runs if it matches no negated pattern and, when regular patterns are also given, matches at least one of them.",
1133
1133
  argument: "<name>",
1134
1134
  array: true
1135
1135
  },
@@ -2363,11 +2363,11 @@ function normalizeCliOptions(cliFilters, argv) {
2363
2363
  }
2364
2364
  async function start(cliFilters, options) {
2365
2365
  try {
2366
- const { startVitest } = await import('./cli-api.B4r6twmv.js').then(function (n) { return n.a; });
2366
+ const { startVitest } = await import('./cli-api.BsG_KUyt.js').then(function (n) { return n.a; });
2367
2367
  const ctx = await startVitest(cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
2368
2368
  if (!ctx.shouldKeepServer()) await ctx.exit();
2369
2369
  } catch (e) {
2370
- const { errorBanner } = await import('./utils.DtdLoSPT.js').then(function (n) { return n.u; });
2370
+ const { errorBanner } = await import('./utils.CtqmNjXD.js').then(function (n) { return n.u; });
2371
2371
  console.error(`\n${errorBanner("Startup Error")}`);
2372
2372
  console.error(e);
2373
2373
  console.error("\n\n");
@@ -2377,11 +2377,11 @@ async function start(cliFilters, options) {
2377
2377
  }
2378
2378
  async function doctorCommand(cliFilters, options) {
2379
2379
  try {
2380
- const { doctor } = await import('./doctor.oxixVMjH.js');
2380
+ const { doctor } = await import('./doctor.CzJ1dA-i.js');
2381
2381
  await doctor(cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
2382
2382
  process.exit();
2383
2383
  } catch (e) {
2384
- const { errorBanner } = await import('./utils.DtdLoSPT.js').then(function (n) { return n.u; });
2384
+ const { errorBanner } = await import('./utils.CtqmNjXD.js').then(function (n) { return n.u; });
2385
2385
  console.error(`\n${errorBanner("Doctor Error")}`);
2386
2386
  console.error(e);
2387
2387
  console.error("\n\n");
@@ -2394,12 +2394,12 @@ async function init(project) {
2394
2394
  console.error(/* @__PURE__ */ new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project."));
2395
2395
  process.exit(1);
2396
2396
  }
2397
- const { create } = await import('./creator.BW8mSwbG.js');
2397
+ const { create } = await import('./creator.CYvpourF.js');
2398
2398
  await create();
2399
2399
  }
2400
2400
  async function collect(cliFilters, options) {
2401
2401
  try {
2402
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.B4r6twmv.js').then(function (n) { return n.a; });
2402
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.BsG_KUyt.js').then(function (n) { return n.a; });
2403
2403
  const ctx = await prepareVitest({
2404
2404
  ...normalizeCliOptions(cliFilters, options),
2405
2405
  watch: false,
@@ -2421,7 +2421,7 @@ async function collect(cliFilters, options) {
2421
2421
  } else outputFileList(await ctx.getRelevantTestSpecifications(cliFilters.map(normalize)), options);
2422
2422
  await ctx.close();
2423
2423
  } catch (e) {
2424
- const { errorBanner } = await import('./utils.DtdLoSPT.js').then(function (n) { return n.u; });
2424
+ const { errorBanner } = await import('./utils.CtqmNjXD.js').then(function (n) { return n.u; });
2425
2425
  console.error(`\n${errorBanner("Collect Error")}`);
2426
2426
  console.error(e);
2427
2427
  console.error("\n\n");
@@ -1,11 +1,11 @@
1
1
  import { mkdirSync, writeFileSync } from 'node:fs';
2
- import { C as CoverageProviderMap } from './coverage.CPiksdSj.js';
3
- import { L as Logger, j as VitestPackageInstaller, P as PluginHarness, u as resolveConfig, V as Vitest, y as stdout, w as prompt, f as FilesNotFoundError, G as GitNotFoundError, I as IncludeTaskLocationDisabledError, z as RangeLocationFilterProvidedError, A as LocationFilterFileNotFoundError } from './index.DiRpHFrd.js';
2
+ import { C as CoverageProviderMap } from './coverage.BcXK1DsQ.js';
3
+ import { L as Logger, k as VitestPackageInstaller, P as PluginHarness, w as resolveConfig, V as Vitest, A as stdout, y as prompt, g as FilesNotFoundError, G as GitNotFoundError, I as IncludeTaskLocationDisabledError, C as RangeLocationFilterProvidedError, E as LocationFilterFileNotFoundError } from './index.CVFiuVPx.js';
4
4
  import readline from 'node:readline';
5
5
  import { y } from './tinyrainbow.Ht9iggcq.js';
6
6
  import { i as isWindows } from './env.DzFJjrmK.js';
7
7
  import { stripVTControlCharacters } from 'node:util';
8
- import { e as createDefer, a as relative, r as resolve, d as dirname, i as isAbsolute } from './pathe.M-eThtNZ.k2RS39sQ.js';
8
+ import { e as createDefer, a as relative, r as resolve, d as dirname, i as isAbsolute } from './pathe.M-eThtNZ.Clq7AXhv.js';
9
9
 
10
10
  async function createVitest(modeOrOptions, optionsOrViteOverrides = {}, viteOverridesOrVitestOptions = {}, maybeVitestOptions = {}) {
11
11
  let options;
@@ -352,9 +352,14 @@ async function startVitest(modeOrCliFilters, cliFiltersOrOptions, optionsOrViteO
352
352
  const stdout = vitestOptions?.stdout || process.stdout;
353
353
  let stdinCleanup;
354
354
  if (stdin.isTTY && ctx.config.watch) stdinCleanup = registerConsoleShortcuts(ctx, stdin, stdout);
355
- ctx.onAfterSetServer(() => {
356
- if (ctx.config.standalone) ctx.standalone();
357
- else ctx.start(cliFilters);
355
+ ctx.onAfterSetServer(async () => {
356
+ if (ctx.closingPromise) return;
357
+ try {
358
+ if (ctx.config.standalone) await ctx.standalone();
359
+ else await ctx.start(cliFilters);
360
+ } catch (error) {
361
+ reportStartError(ctx, error);
362
+ }
358
363
  });
359
364
  try {
360
365
  if (ctx.config.listTags) await ctx.listTags();
@@ -364,21 +369,7 @@ async function startVitest(modeOrCliFilters, cliFiltersOrOptions, optionsOrViteO
364
369
  else await ctx.start(cliFilters);
365
370
  return ctx;
366
371
  } catch (e) {
367
- if (e instanceof FilesNotFoundError) return ctx;
368
- if (e instanceof GitNotFoundError) {
369
- ctx.logger.error(e.message);
370
- return ctx;
371
- }
372
- if (e instanceof IncludeTaskLocationDisabledError || e instanceof RangeLocationFilterProvidedError || e instanceof LocationFilterFileNotFoundError) {
373
- ctx.logger.printError(e, { verbose: false });
374
- return ctx;
375
- }
376
- process.exitCode = 1;
377
- ctx.logger.printError(e, {
378
- fullStack: true,
379
- type: "Unhandled Error"
380
- });
381
- ctx.logger.error("\n\n");
372
+ reportStartError(ctx, e);
382
373
  return ctx;
383
374
  } finally {
384
375
  if (!ctx?.shouldKeepServer()) {
@@ -387,6 +378,23 @@ async function startVitest(modeOrCliFilters, cliFiltersOrOptions, optionsOrViteO
387
378
  }
388
379
  }
389
380
  }
381
+ function reportStartError(ctx, error) {
382
+ if (error instanceof FilesNotFoundError) return;
383
+ if (error instanceof GitNotFoundError) {
384
+ ctx.logger.error(error.message);
385
+ return;
386
+ }
387
+ if (error instanceof IncludeTaskLocationDisabledError || error instanceof RangeLocationFilterProvidedError || error instanceof LocationFilterFileNotFoundError) {
388
+ ctx.logger.printError(error, { verbose: false });
389
+ return;
390
+ }
391
+ process.exitCode = 1;
392
+ ctx.logger.printError(error, {
393
+ fullStack: true,
394
+ type: "Unhandled Error"
395
+ });
396
+ ctx.logger.error("\n\n");
397
+ }
390
398
  async function prepareVitest(modeOrOptions, optionsOrViteOverrides, viteOverridesOrVitestOptions, vitestOptionsOrCliFilters, maybeCliFilters) {
391
399
  let options;
392
400
  let viteOverrides;
@@ -323,20 +323,6 @@ interface TestError extends SerializedError {
323
323
  expected?: string;
324
324
  }
325
325
 
326
- interface SnapshotEnvironment {
327
- getVersion: () => string;
328
- getHeader: () => string;
329
- resolvePath: (filepath: string) => Promise<string>;
330
- resolveRawPath: (testPath: string, rawPath: string) => Promise<string>;
331
- saveSnapshotFile: (filepath: string, snapshot: string) => Promise<void>;
332
- readSnapshotFile: (filepath: string) => Promise<string | null>;
333
- removeSnapshotFile: (filepath: string) => Promise<void>;
334
- processStackTrace?: (stack: ParsedStack) => ParsedStack;
335
- }
336
- interface SnapshotEnvironmentOptions {
337
- snapshotsDirName?: string;
338
- }
339
-
340
326
  interface DomainMatchResult {
341
327
  pass: boolean;
342
328
  message?: string;
@@ -385,13 +371,20 @@ interface RawSnapshotInfo {
385
371
  content?: string;
386
372
  }
387
373
 
388
- /**
389
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
390
- *
391
- * This source code is licensed under the MIT license found in the
392
- * LICENSE file in the root directory of this source tree.
393
- */
394
-
374
+ interface SnapshotEnvironment {
375
+ getVersion: () => string;
376
+ getHeader: () => string;
377
+ resolvePath: (filepath: string) => Promise<string>;
378
+ resolveRawPath: (testPath: string, rawPath: string) => Promise<string>;
379
+ saveSnapshotFile: (filepath: string, snapshot: string) => Promise<void>;
380
+ readSnapshotFile: (filepath: string) => Promise<string | null>;
381
+ readSnapshotFileData?: (filepath: string) => Promise<Record<string, string> | null>;
382
+ removeSnapshotFile: (filepath: string) => Promise<void>;
383
+ processStackTrace?: (stack: ParsedStack) => ParsedStack;
384
+ }
385
+ interface SnapshotEnvironmentOptions {
386
+ snapshotsDirName?: string;
387
+ }
395
388
  declare class DefaultMap<
396
389
  K,
397
390
  V
@@ -1,10 +1,10 @@
1
1
  import { Console } from 'node:console';
2
2
  import { relative } from 'node:path';
3
3
  import { Writable } from 'node:stream';
4
- import { a as getSafeTimers } from './source-map.CTObTzjj.js';
4
+ import { a as getSafeTimers } from './source-map.Dx3YPjIe.js';
5
5
  import { y } from './tinyrainbow.Ht9iggcq.js';
6
6
  import { g as getWorkerState } from './utils.DYj33du9.js';
7
- import './pathe.M-eThtNZ.k2RS39sQ.js';
7
+ import './pathe.M-eThtNZ.Clq7AXhv.js';
8
8
 
9
9
  const RealDate = globalThis.Date;
10
10
  const UNKNOWN_TEST_ID = "__vitest__unknown_test__";
@@ -1,4 +1,4 @@
1
- import { r as resolve } from './pathe.M-eThtNZ.k2RS39sQ.js';
1
+ import { r as resolve } from './pathe.M-eThtNZ.Clq7AXhv.js';
2
2
 
3
3
  function getCoverageFilesDirectory(reportsDirectory, shard) {
4
4
  return resolve(reportsDirectory, `.tmp${shard ? `-${shard.index}-${shard.count}` : ""}`);
@@ -1,4 +1,4 @@
1
- import { r as resolveCoverageProviderModule } from './coverage.CPiksdSj.js';
1
+ import { r as resolveCoverageProviderModule } from './coverage.BcXK1DsQ.js';
2
2
 
3
3
  async function startCoverageInsideWorker(options, loader, runtimeOptions) {
4
4
  const coverageModule = await resolveCoverageProviderModule(options, loader);
@@ -2,51 +2,61 @@ import { existsSync, writeFileSync, readFileSync } from 'node:fs';
2
2
  import { mkdir, writeFile } from 'node:fs/promises';
3
3
  import { resolve, dirname, relative } from 'node:path';
4
4
  import { detectPackageManager, installPackage } from './index.DXQx-kDM.js';
5
- import { w as prompt, x as findConfigFile } from './index.DiRpHFrd.js';
5
+ import { y as prompt, z as findConfigFile } from './index.CVFiuVPx.js';
6
6
  import { x } from 'tinyexec';
7
7
  import { y } from './tinyrainbow.Ht9iggcq.js';
8
8
  import 'node:process';
9
9
  import 'node:os';
10
- import './pathe.M-eThtNZ.k2RS39sQ.js';
11
- import './source-map.CTObTzjj.js';
12
- import './cac.CM6y_f_i.js';
10
+ import './pathe.M-eThtNZ.Clq7AXhv.js';
11
+ import './source-map.Dx3YPjIe.js';
12
+ import './cac.AVSgLgX0.js';
13
13
  import 'events';
14
14
  import './env.DzFJjrmK.js';
15
15
  import 'std-env';
16
16
  import './constants.-juJ8b_4.js';
17
17
  import 'node:assert';
18
+ import 'node:perf_hooks';
19
+ import './index.DmDMHCg8.js';
20
+ import 'https';
21
+ import 'http';
22
+ import 'net';
23
+ import 'tls';
24
+ import 'crypto';
25
+ import 'stream';
26
+ import 'url';
27
+ import 'zlib';
28
+ import 'buffer';
29
+ import 'util';
30
+ import 'vite';
31
+ import 'node:crypto';
18
32
  import '../path.js';
19
33
  import 'node:url';
20
- import './run.DS9d28OG.js';
34
+ import './run.DyRH7m0-.js';
21
35
  import './index.M2dsQ_UQ.js';
22
36
  import './display.pkpxlVcY.js';
23
37
  import '../task-utils.js';
24
- import './nativeModuleRunner.Bc3kXpWn.js';
38
+ import './nativeModuleRunner.BOvBCgI_.js';
25
39
  import 'node:module';
26
40
  import 'node:v8';
27
41
  import 'node:util';
28
42
  import 'vite/module-runner';
29
43
  import '../traces.js';
30
- import 'vite';
31
44
  import 'obug';
32
- import 'node:crypto';
33
45
  import 'tinyglobby';
34
46
  import './defaults.D2ip7f-X.js';
35
47
  import 'magic-string';
36
48
  import '@vitest/mocker/node';
37
49
  import 'node:console';
38
50
  import 'node:stream';
39
- import 'node:perf_hooks';
40
51
  import './offset.Dy-5Fdfn.js';
41
- import './utils.DtdLoSPT.js';
52
+ import './utils.CtqmNjXD.js';
42
53
  import '#module-evaluator';
43
54
  import 'picomatch';
44
- import './coverage.CPiksdSj.js';
45
- import './resolver.B_5CI0Kh.js';
55
+ import './coverage.BcXK1DsQ.js';
56
+ import './resolver.CBCHRZ7j.js';
46
57
  import 'es-module-lexer';
47
58
  import 'node:tty';
48
59
  import 'node:events';
49
- import './index.CCh1Pb8k.js';
50
60
  import './modules.BJuCwlRJ.js';
51
61
  import 'node:child_process';
52
62
  import 'node:worker_threads';
@@ -4,7 +4,7 @@ import { availableParallelism, tmpdir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
  import { performance } from 'node:perf_hooks';
6
6
  import { pathToFileURL } from 'node:url';
7
- import { t as toArray, r as resolve } from './pathe.M-eThtNZ.k2RS39sQ.js';
7
+ import { t as toArray, r as resolve } from './pathe.M-eThtNZ.Clq7AXhv.js';
8
8
  import { y } from './tinyrainbow.Ht9iggcq.js';
9
9
  import { distDir } from '../path.js';
10
10
 
@@ -99,7 +99,7 @@ function log(...args) {
99
99
  console.log(...args);
100
100
  }
101
101
  async function doctor(cliFilters, options) {
102
- const { prepareVitest } = await import('./cli-api.B4r6twmv.js').then(function (n) { return n.a; });
102
+ const { prepareVitest } = await import('./cli-api.BsG_KUyt.js').then(function (n) { return n.a; });
103
103
  log();
104
104
  log(y.inverse(y.bold(y.blue(" DOCTOR "))), "resolving the current configuration...");
105
105
  const ctx = await prepareVitest({
@@ -1,4 +1,4 @@
1
- import { A as Awaitable } from './config.d.BpALOMjL.js';
1
+ import { A as Awaitable } from './config.d.CU_b-wJj.js';
2
2
 
3
3
  interface EnvironmentReturn {
4
4
  teardown: (global: any) => Awaitable<void>;
@@ -22,6 +22,14 @@ interface Environment {
22
22
  * By default, fallbacks to `name`.
23
23
  */
24
24
  viteEnvironment?: "client" | "ssr" | ({} & string);
25
+ /**
26
+ * Let the server transform the test file's import graph while `setupVM`
27
+ * runs. Only worth it when `setupVM` is slow (jsdom, happy-dom): otherwise
28
+ * the transforms compete with the worker's own module requests.
29
+ *
30
+ * @default `true`
31
+ */
32
+ prewarmModules?: boolean;
25
33
  setupVM?: (options: Record<string, any>) => Awaitable<VmEnvironmentReturn>;
26
34
  setup: (global: any, options: Record<string, any>) => Awaitable<EnvironmentReturn>;
27
35
  }
@@ -1,20 +1,20 @@
1
1
  import { g as globalApis } from './constants.-juJ8b_4.js';
2
- import { i as index } from './index.DRmbsPYf.js';
3
- import './run.DS9d28OG.js';
2
+ import { i as index } from './index.CSoBZWW_.js';
3
+ import './run.DyRH7m0-.js';
4
4
  import './index.M2dsQ_UQ.js';
5
5
  import './tinyrainbow.Ht9iggcq.js';
6
6
  import './display.pkpxlVcY.js';
7
- import './pathe.M-eThtNZ.k2RS39sQ.js';
8
- import './source-map.CTObTzjj.js';
7
+ import './pathe.M-eThtNZ.Clq7AXhv.js';
8
+ import './source-map.Dx3YPjIe.js';
9
9
  import '../task-utils.js';
10
10
  import './utils.DYj33du9.js';
11
11
  import './spy.DPpyuUIA.js';
12
12
  import 'chai';
13
13
  import './plugins.Cigb0uSy.js';
14
14
  import './offset.Dy-5Fdfn.js';
15
- import './rpc.DaPTofpf.js';
15
+ import './rpc.DWKX1ZbI.js';
16
16
  import 'vite/module-runner';
17
- import './index.CCh1Pb8k.js';
17
+ import './index.DmDMHCg8.js';
18
18
  import 'tinybench';
19
19
  import 'expect-type';
20
20
 
@@ -1,8 +1,8 @@
1
- import { b as printDiffOrStringify, d as diff, a as processError, T as TestSyntaxError, g as getCurrentTest, c as createTaskCollector, e as getCurrentSuite, f as createChainable, h as getHooks, i as getFn, m as matchesTags, j as afterAll, k as afterEach, l as aroundAll, n as aroundEach, o as beforeAll, q as beforeEach, r as describe, t as it, u as onTestFailed, v as onTestFinished, w as recordArtifact, x as suite, y as test } from './run.DS9d28OG.js';
1
+ import { b as printDiffOrStringify, d as diff, a as processError, T as TestSyntaxError, g as getCurrentTest, c as createTaskCollector, e as getCurrentSuite, f as createChainable, h as getHooks, i as getFn, m as matchesTags, j as afterAll, k as afterEach, l as aroundAll, n as aroundEach, o as beforeAll, q as beforeEach, r as describe, t as it, u as onTestFailed, v as onTestFinished, w as recordArtifact, x as suite, y as test } from './run.DyRH7m0-.js';
2
2
  import { i as isChildProcess, r as resetModules, g as getWorkerState } from './utils.DYj33du9.js';
3
- import { d as getDefaultExportFromCjs, h as parseErrorStacktrace, i as commonjsGlobal, a as getSafeTimers, f as parseSingleStack, j as delay } from './source-map.CTObTzjj.js';
3
+ import { e as getDefaultExportFromCjs, f as parseErrorStacktrace, h as commonjsGlobal, a as getSafeTimers, i as parseSingleStack, j as delay } from './source-map.Dx3YPjIe.js';
4
4
  import { i as isMockFunction, f as fn, a as spyOn, r as restoreAllMocks, b as resetAllMocks, c as clearAllMocks } from './spy.DPpyuUIA.js';
5
- import { v as isObject, D as getCallLastIndex, g as getType, p as noop, y as assertTypes, x as ordinal, E as createSimpleStackTrace, i as isAbsolute, a as relative, n as normalize } from './pathe.M-eThtNZ.k2RS39sQ.js';
5
+ import { u as isObject, B as getCallLastIndex, g as getType, D as noop, x as assertTypes, w as ordinal, E as createSimpleStackTrace, i as isAbsolute, a as relative, n as normalize } from './pathe.M-eThtNZ.Clq7AXhv.js';
6
6
  import { s as stringify, i as inspect } from './display.pkpxlVcY.js';
7
7
  import { y } from './tinyrainbow.Ht9iggcq.js';
8
8
  import * as chai from 'chai';
@@ -11,7 +11,7 @@ import { getNames, getTests, getTestName, createFileTask } from '../task-utils.j
11
11
  import { g as getSerializers, a as addSerializer } from './plugins.Cigb0uSy.js';
12
12
  import { p as positionToOffset, o as offsetToLineNumber, l as lineSplitRE } from './offset.Dy-5Fdfn.js';
13
13
  import { f as format } from './index.M2dsQ_UQ.js';
14
- import { r as rpc, V as VitestEvaluatedModules } from './rpc.DaPTofpf.js';
14
+ import { r as rpc, V as VitestEvaluatedModules } from './rpc.DWKX1ZbI.js';
15
15
  import { Bench } from 'tinybench';
16
16
  import { expectTypeOf } from 'expect-type';
17
17
 
@@ -90,22 +90,15 @@ function keyToTestName(key) {
90
90
  if (!/ \d+$/.test(key)) throw new Error("Snapshot keys must end with a number.");
91
91
  return key.replace(/ \d+$/, "");
92
92
  }
93
- function getSnapshotData(content, options) {
94
- const update = options.updateSnapshot;
93
+ // Evaluate a snapshot file's content into its snapshot key/value pairs.
94
+ function evaluateSnapshotFile(filepath, content) {
95
95
  const data = Object.create(null);
96
- let snapshotContents = "";
97
- let dirty = false;
98
- if (content != null) try {
99
- snapshotContents = content;
100
- new Function("exports", snapshotContents)(data);
101
- } catch {}
102
- // if (update === 'none' && isInvalid)
103
- // throw validationResult
104
- if ((update === "all" || update === "new") && snapshotContents) dirty = true;
105
- return {
106
- data,
107
- dirty
108
- };
96
+ try {
97
+ new Function("exports", content)(data);
98
+ } catch (cause) {
99
+ throw new Error(`Invalid snapshot file, please manually fix or delete it: ${filepath}`, { cause });
100
+ }
101
+ return data;
109
102
  }
110
103
  // Add extra line breaks at beginning and end of multiline snapshot
111
104
  // to make the content easier to read.
@@ -420,11 +413,13 @@ class SnapshotState {
420
413
  set updated(value) {
421
414
  this._updated._total = value;
422
415
  }
423
- constructor(testFilePath, snapshotPath, snapshotContent, options) {
416
+ constructor(testFilePath, snapshotPath, fileData, options) {
424
417
  this.testFilePath = testFilePath;
425
418
  this.snapshotPath = snapshotPath;
426
- const { data, dirty } = getSnapshotData(snapshotContent, options);
427
- this._fileExists = snapshotContent != null;
419
+ const data = fileData ?? Object.create(null);
420
+ this._fileExists = fileData != null;
421
+ const update = options.updateSnapshot;
422
+ const dirty = (update === "all" || update === "new") && fileData != null;
428
423
  this._initialData = { ...data };
429
424
  this._snapshotData = { ...data };
430
425
  this._dirty = dirty;
@@ -446,9 +441,15 @@ class SnapshotState {
446
441
  this._environment = options.snapshotEnvironment;
447
442
  }
448
443
  static async create(testFilePath, options) {
449
- const snapshotPath = await options.snapshotEnvironment.resolvePath(testFilePath);
450
- const content = await options.snapshotEnvironment.readSnapshotFile(snapshotPath);
451
- return new SnapshotState(testFilePath, snapshotPath, content, options);
444
+ const environment = options.snapshotEnvironment;
445
+ const snapshotPath = await environment.resolvePath(testFilePath);
446
+ let fileData;
447
+ if (environment.readSnapshotFileData) fileData = await environment.readSnapshotFileData(snapshotPath);
448
+ else {
449
+ const content = await environment.readSnapshotFile(snapshotPath);
450
+ fileData = content != null ? evaluateSnapshotFile(snapshotPath, content) : null;
451
+ }
452
+ return new SnapshotState(testFilePath, snapshotPath, fileData, options);
452
453
  }
453
454
  get snapshotUpdateState() {
454
455
  return this._updateSnapshot;
@@ -814,6 +815,11 @@ class SnapshotClient {
814
815
  let { received } = options;
815
816
  if (!filepath) throw new Error("Snapshot cannot be used outside of test");
816
817
  const snapshotState = this.getSnapshotState(filepath);
818
+ if (rawSnapshot?.file === snapshotState.snapshotPath)
819
+ // note that this hard rejection is best-effort in a sense that,
820
+ // if `toMatchFileSnapshot` is called with a different test file's snapshot path,
821
+ // this check will not catch it.
822
+ throw new Error(`File snapshot cannot use the same path as the test snapshot file: ${rawSnapshot.file}`);
817
823
  const testName = [name, ...message ? [message] : []].join(" > ");
818
824
  // Probe first so we can mark as checked even on early return
819
825
  const expectedSnapshot = snapshotState.probeExpectedSnapshot({
@@ -1604,13 +1610,10 @@ function getState(expect) {
1604
1610
  }
1605
1611
  function setState(state, expect) {
1606
1612
  const map = globalThis[MATCHERS_OBJECT];
1607
- const current = map.get(expect) || {};
1613
+ const current = map.get(expect);
1608
1614
  // so it keeps getters from `testPath`
1609
- const results = Object.defineProperties(current, {
1610
- ...Object.getOwnPropertyDescriptors(current),
1611
- ...Object.getOwnPropertyDescriptors(state)
1612
- });
1613
- map.set(expect, results);
1615
+ const next = Object.defineProperties(current || {}, Object.getOwnPropertyDescriptors(state));
1616
+ if (!current) map.set(expect, next);
1614
1617
  }
1615
1618
 
1616
1619
  class AsymmetricMatcher {
@@ -8413,11 +8416,10 @@ class TestRunner {
8413
8416
  if (this.pool !== "vmThreads" && this.pool !== "vmForks") this.onCleanupWorkerContext = (listener) => this.workerState.onCleanup(listener);
8414
8417
  }
8415
8418
  importFile(filepath, source) {
8416
- const moduleNode = this.workerState.evaluatedModules.getModuleById(filepath);
8417
- if (moduleNode && (source === "setup" || moduleNode.evaluated)) this.workerState.evaluatedModules.invalidateModule(moduleNode);
8418
8419
  return this._otel.$(`vitest.module.import_${source === "setup" ? "setup" : "spec"}`, { attributes: { "code.file.path": filepath } }, () => {
8419
8420
  if (!this.viteModuleRunner) filepath = `${filepath}?vitest=${Date.now()}`;
8420
- return this.moduleRunner.import(filepath);
8421
+ const options = this.viteModuleRunner ? { invalidate: true } : void 0;
8422
+ return this.moduleRunner.import(filepath, options);
8421
8423
  });
8422
8424
  }
8423
8425
  onCollectStart(file) {