vitest 5.0.0-rc.2 → 5.0.0-rc.4

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 (54) hide show
  1. package/dist/browser.js +6 -6
  2. package/dist/chunks/{base.C1WTaPOM.js → base.DE9oA_9r.js} +13 -13
  3. package/dist/chunks/{browser.d.C9OF2Et_.d.ts → browser.d.g5Thl309.d.ts} +1 -1
  4. package/dist/chunks/{cac.D09XQ6pO.js → cac.Bf8-pv1O.js} +14 -11
  5. package/dist/chunks/{cli-api.te-1Pvjs.js → cli-api.rZIctZe8.js} +4 -4
  6. package/dist/chunks/{console.DWNMLVgF.js → console.CHi0lDgQ.js} +2 -2
  7. package/dist/chunks/{coverage.CPiksdSj.js → coverage.BcXK1DsQ.js} +1 -1
  8. package/dist/chunks/{coverage.VANpXofm.js → coverage.BtDxDqSU.js} +1 -1
  9. package/dist/chunks/{creator.Cqwo9lsW.js → creator.BNqrBW1W.js} +23 -13
  10. package/dist/chunks/{doctor.CNpBUniZ.js → doctor.heFfAozl.js} +2 -2
  11. package/dist/chunks/{environment.d.C0fjmVGG.d.ts → environment.d.C6xYahWA.d.ts} +8 -0
  12. package/dist/chunks/{globals.C5MA6F-b.js → globals.xG0BzeWF.js} +6 -6
  13. package/dist/chunks/{index.BH4BaN4R.js → index.CD2j-4_2.js} +38 -30
  14. package/dist/chunks/{index.DzzDnMj8.js → index.Cd7SnpwO.js} +5720 -310
  15. package/dist/chunks/{index.C0qliBI-.js → index.DKvCqCMl.js} +5 -5
  16. package/dist/chunks/{index.BfU4rh_M.js → index.DQO7054M.js} +9 -3
  17. package/dist/chunks/{index.CCh1Pb8k.js → index.DmDMHCg8.js} +1 -1
  18. package/dist/chunks/{init-forks.Bo2g6tWs.js → init-forks.BqnYxpzU.js} +1 -1
  19. package/dist/chunks/{init-threads.BSTHIk3P.js → init-threads.CL4Y0HC6.js} +1 -1
  20. package/dist/chunks/{init.i_K8EJrW.js → init.DJ2lKyjE.js} +6 -5
  21. package/dist/chunks/{native.offEPk9l.js → native.cLbCmZDO.js} +1 -1
  22. package/dist/chunks/{nativeModuleMocker.0CD1hdFV.js → nativeModuleMocker.DBSXgC3F.js} +2 -2
  23. package/dist/chunks/{nativeModuleRunner.Bc3kXpWn.js → nativeModuleRunner.BOvBCgI_.js} +1 -1
  24. package/dist/chunks/{node.CS-X6Ymg.js → node.Es9ukMGX.js} +1 -1
  25. package/dist/chunks/{pathe.M-eThtNZ.k2RS39sQ.js → pathe.M-eThtNZ.Clq7AXhv.js} +1 -1
  26. package/dist/chunks/{plugin.d.CNqvINDS.d.ts → plugin.d.BbcoZhuj.d.ts} +453 -144
  27. package/dist/chunks/{resolver.B_5CI0Kh.js → resolver.CBCHRZ7j.js} +1 -1
  28. package/dist/chunks/{rpc.DaPTofpf.js → rpc.DWKX1ZbI.js} +3 -3
  29. package/dist/chunks/{run.COOMV-72.js → run.CQOUYP-x.js} +95 -28
  30. package/dist/chunks/{setup-common.AcXJaDWq.js → setup-common.QoaKiKGk.js} +2 -2
  31. package/dist/chunks/{source-map.CTObTzjj.js → source-map.Dx3YPjIe.js} +2 -2
  32. package/dist/chunks/{utils.DtdLoSPT.js → utils.CtqmNjXD.js} +1 -1
  33. package/dist/chunks/{vm.FXMbMqlj.js → vm.DhWYFrLG.js} +111 -61
  34. package/dist/chunks/{worker.d.XSpk7g5N.d.ts → worker.d.MLmnzOJE.d.ts} +1 -1
  35. package/dist/cli.js +2 -2
  36. package/dist/config.d.ts +6 -5
  37. package/dist/index.d.ts +7 -7
  38. package/dist/index.js +6 -6
  39. package/dist/module-evaluator.d.ts +1 -0
  40. package/dist/node.d.ts +6 -5
  41. package/dist/node.js +26 -17
  42. package/dist/runtime.d.ts +2 -2
  43. package/dist/runtime.js +4 -4
  44. package/dist/task-utils.js +1 -1
  45. package/dist/worker.d.ts +2 -2
  46. package/dist/worker.js +13 -13
  47. package/dist/workers/forks.js +14 -14
  48. package/dist/workers/runVmTests.js +10 -10
  49. package/dist/workers/threads.js +14 -14
  50. package/dist/workers/vmForks.js +11 -11
  51. package/dist/workers/vmThreads.js +11 -11
  52. package/package.json +23 -23
  53. package/dist/chunks/check.Cz_-YojU.js +0 -15
  54. package/dist/chunks/setup.CBDqPUzi.js +0 -5405
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.COOMV-72.js';
3
- export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as setupEnv } from './chunks/setup-common.AcXJaDWq.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.CQOUYP-x.js';
3
+ export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as setupEnv } from './chunks/setup-common.QoaKiKGk.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.C0qliBI-.js';
4
- import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.i_K8EJrW.js';
3
+ import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.DKvCqCMl.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.BH4BaN4R.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.CD2j-4_2.js';
11
11
  import { c as closeInspector } from './inspector.CvyFGlXm.js';
12
- import { s as startTests, p as publicCollect } from './run.COOMV-72.js';
12
+ import { s as startTests, p as publicCollect } from './run.CQOUYP-x.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.AcXJaDWq.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.QoaKiKGk.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
 
@@ -119,7 +119,7 @@ async function startModuleRunner(options) {
119
119
  let mocker;
120
120
  if (options.state.config.experimental.nodeLoader !== false) {
121
121
  // this additionally imports acorn/magic-string
122
- const { NativeModuleMocker } = await import('./nativeModuleMocker.0CD1hdFV.js');
122
+ const { NativeModuleMocker } = await import('./nativeModuleMocker.DBSXgC3F.js');
123
123
  mocker = new NativeModuleMocker({
124
124
  async resolveId(id, importer) {
125
125
  // TODO: use import.meta.resolve instead
@@ -136,7 +136,7 @@ async function startModuleRunner(options) {
136
136
  }
137
137
  // imported lazily (pulls in `local-pkg`) so it stays out of the default
138
138
  // worker startup graph; only the `viteModuleRunner: false` path needs it
139
- 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; });
140
140
  _moduleRunner = new NativeModuleRunner(root, mocker);
141
141
  return _moduleRunner;
142
142
  }
@@ -148,7 +148,7 @@ let _environmentTime;
148
148
  /** @experimental */
149
149
  async function setupBaseEnvironment(context) {
150
150
  if (context.config.experimental.viteModuleRunner === false) {
151
- const { setupNodeLoaderHooks } = await import('./native.offEPk9l.js');
151
+ const { setupNodeLoaderHooks } = await import('./native.cLbCmZDO.js');
152
152
  await setupNodeLoaderHooks(context);
153
153
  }
154
154
  const startTime = performance.now();
@@ -1,6 +1,6 @@
1
1
  import { F as FileSpecification } from './config.d.CU_b-wJj.js';
2
2
  import { O as OTELCarrier } from './rpc.d.DA9Utv4e.js';
3
- import { T as TestExecutionMethod } from './worker.d.XSpk7g5N.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.2";
623
+ var version = "5.0.0-rc.4";
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
  },
@@ -1337,7 +1337,10 @@ const collectCliOptionsConfig = {
1337
1337
  argument: "[true/path]"
1338
1338
  },
1339
1339
  filesOnly: { description: "Print only test files with out the test cases" },
1340
- staticParse: { description: "Parse files statically instead of running them to collect tests (default: false)" },
1340
+ staticParse: {
1341
+ description: "Parse files statically instead of running them to collect tests (default: true)",
1342
+ default: true
1343
+ },
1341
1344
  staticParseConcurrency: {
1342
1345
  description: "How many tests to process at the same time (default: os.availableParallelism())",
1343
1346
  argument: "<limit>"
@@ -2363,11 +2366,11 @@ function normalizeCliOptions(cliFilters, argv) {
2363
2366
  }
2364
2367
  async function start(cliFilters, options) {
2365
2368
  try {
2366
- const { startVitest } = await import('./cli-api.te-1Pvjs.js').then(function (n) { return n.a; });
2369
+ const { startVitest } = await import('./cli-api.rZIctZe8.js').then(function (n) { return n.a; });
2367
2370
  const ctx = await startVitest(cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
2368
2371
  if (!ctx.shouldKeepServer()) await ctx.exit();
2369
2372
  } catch (e) {
2370
- const { errorBanner } = await import('./utils.DtdLoSPT.js').then(function (n) { return n.u; });
2373
+ const { errorBanner } = await import('./utils.CtqmNjXD.js').then(function (n) { return n.u; });
2371
2374
  console.error(`\n${errorBanner("Startup Error")}`);
2372
2375
  console.error(e);
2373
2376
  console.error("\n\n");
@@ -2377,11 +2380,11 @@ async function start(cliFilters, options) {
2377
2380
  }
2378
2381
  async function doctorCommand(cliFilters, options) {
2379
2382
  try {
2380
- const { doctor } = await import('./doctor.CNpBUniZ.js');
2383
+ const { doctor } = await import('./doctor.heFfAozl.js');
2381
2384
  await doctor(cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
2382
2385
  process.exit();
2383
2386
  } catch (e) {
2384
- const { errorBanner } = await import('./utils.DtdLoSPT.js').then(function (n) { return n.u; });
2387
+ const { errorBanner } = await import('./utils.CtqmNjXD.js').then(function (n) { return n.u; });
2385
2388
  console.error(`\n${errorBanner("Doctor Error")}`);
2386
2389
  console.error(e);
2387
2390
  console.error("\n\n");
@@ -2394,12 +2397,12 @@ async function init(project) {
2394
2397
  console.error(/* @__PURE__ */ new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project."));
2395
2398
  process.exit(1);
2396
2399
  }
2397
- const { create } = await import('./creator.Cqwo9lsW.js');
2400
+ const { create } = await import('./creator.BNqrBW1W.js');
2398
2401
  await create();
2399
2402
  }
2400
2403
  async function collect(cliFilters, options) {
2401
2404
  try {
2402
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.te-1Pvjs.js').then(function (n) { return n.a; });
2405
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.rZIctZe8.js').then(function (n) { return n.a; });
2403
2406
  const ctx = await prepareVitest({
2404
2407
  ...normalizeCliOptions(cliFilters, options),
2405
2408
  watch: false,
@@ -2421,7 +2424,7 @@ async function collect(cliFilters, options) {
2421
2424
  } else outputFileList(await ctx.getRelevantTestSpecifications(cliFilters.map(normalize)), options);
2422
2425
  await ctx.close();
2423
2426
  } catch (e) {
2424
- const { errorBanner } = await import('./utils.DtdLoSPT.js').then(function (n) { return n.u; });
2427
+ const { errorBanner } = await import('./utils.CtqmNjXD.js').then(function (n) { return n.u; });
2425
2428
  console.error(`\n${errorBanner("Collect Error")}`);
2426
2429
  console.error(e);
2427
2430
  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, k as VitestPackageInstaller, P as PluginHarness, v as resolveConfig, V as Vitest, z as stdout, x as prompt, g as FilesNotFoundError, G as GitNotFoundError, I as IncludeTaskLocationDisabledError, A as RangeLocationFilterProvidedError, C as LocationFilterFileNotFoundError } from './index.DzzDnMj8.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.Cd7SnpwO.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;
@@ -363,7 +363,7 @@ async function startVitest(modeOrCliFilters, cliFiltersOrOptions, optionsOrViteO
363
363
  });
364
364
  try {
365
365
  if (ctx.config.listTags) await ctx.listTags();
366
- else if (ctx.config.clearCache) await ctx.experimental_clearCache();
366
+ else if (ctx.config.clearCache) await ctx.clearCache();
367
367
  else if (ctx.config.mergeReports) await ctx.mergeReports();
368
368
  else if (ctx.config.standalone) await ctx.standalone();
369
369
  else await ctx.start(cliFilters);
@@ -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 { x as prompt, y as findConfigFile } from './index.DzzDnMj8.js';
5
+ import { y as prompt, z as findConfigFile } from './index.Cd7SnpwO.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.D09XQ6pO.js';
10
+ import './pathe.M-eThtNZ.Clq7AXhv.js';
11
+ import './source-map.Dx3YPjIe.js';
12
+ import './cac.Bf8-pv1O.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.COOMV-72.js';
34
+ import './run.CQOUYP-x.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.te-1Pvjs.js').then(function (n) { return n.a; });
102
+ const { prepareVitest } = await import('./cli-api.rZIctZe8.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({
@@ -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.BH4BaN4R.js';
3
- import './run.COOMV-72.js';
2
+ import { i as index } from './index.CD2j-4_2.js';
3
+ import './run.CQOUYP-x.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.COOMV-72.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.CQOUYP-x.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
 
@@ -815,6 +815,11 @@ class SnapshotClient {
815
815
  let { received } = options;
816
816
  if (!filepath) throw new Error("Snapshot cannot be used outside of test");
817
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}`);
818
823
  const testName = [name, ...message ? [message] : []].join(" > ");
819
824
  // Probe first so we can mark as checked even on early return
820
825
  const expectedSnapshot = snapshotState.probeExpectedSnapshot({
@@ -1605,13 +1610,10 @@ function getState(expect) {
1605
1610
  }
1606
1611
  function setState(state, expect) {
1607
1612
  const map = globalThis[MATCHERS_OBJECT];
1608
- const current = map.get(expect) || {};
1613
+ const current = map.get(expect);
1609
1614
  // so it keeps getters from `testPath`
1610
- const results = Object.defineProperties(current, {
1611
- ...Object.getOwnPropertyDescriptors(current),
1612
- ...Object.getOwnPropertyDescriptors(state)
1613
- });
1614
- map.set(expect, results);
1615
+ const next = Object.defineProperties(current || {}, Object.getOwnPropertyDescriptors(state));
1616
+ if (!current) map.set(expect, next);
1615
1617
  }
1616
1618
 
1617
1619
  class AsymmetricMatcher {
@@ -2211,13 +2213,15 @@ const JestChaiExpect = (chai, utils) => {
2211
2213
  const spyName = spy.getMockName();
2212
2214
  const pass = spy.mock.calls.some((callArg) => equalsArgumentArray(callArg, args));
2213
2215
  const isNot = utils.flag(this, "negate");
2214
- const msg = utils.getMessage(this, [
2215
- pass,
2216
- `expected "${spyName}" to be called with arguments: #{exp}`,
2217
- `expected "${spyName}" to not be called with arguments: #{exp}`,
2218
- args
2219
- ]);
2220
- if (pass && isNot || !pass && !isNot) throw new AssertionError(formatCalls(spy, msg, args));
2216
+ if (pass && isNot || !pass && !isNot) {
2217
+ const msg = utils.getMessage(this, [
2218
+ pass,
2219
+ `expected "${spyName}" to be called with arguments: #{exp}`,
2220
+ `expected "${spyName}" to not be called with arguments: #{exp}`,
2221
+ args
2222
+ ]);
2223
+ throw new AssertionError(formatCalls(spy, msg, args));
2224
+ }
2221
2225
  });
2222
2226
  def("toHaveBeenCalledExactlyOnceWith", function(...args) {
2223
2227
  const spy = getSpy(this);
@@ -2225,13 +2229,15 @@ const JestChaiExpect = (chai, utils) => {
2225
2229
  const callCount = spy.mock.calls.length;
2226
2230
  const pass = spy.mock.calls.some((callArg) => equalsArgumentArray(callArg, args)) && callCount === 1;
2227
2231
  const isNot = utils.flag(this, "negate");
2228
- const msg = utils.getMessage(this, [
2229
- pass,
2230
- `expected "${spyName}" to be called once with arguments: #{exp}`,
2231
- `expected "${spyName}" to not be called once with arguments: #{exp}`,
2232
- args
2233
- ]);
2234
- if (pass && isNot || !pass && !isNot) throw new AssertionError(formatCalls(spy, msg, args));
2232
+ if (pass && isNot || !pass && !isNot) {
2233
+ const msg = utils.getMessage(this, [
2234
+ pass,
2235
+ `expected "${spyName}" to be called once with arguments: #{exp}`,
2236
+ `expected "${spyName}" to not be called once with arguments: #{exp}`,
2237
+ args
2238
+ ]);
2239
+ throw new AssertionError(formatCalls(spy, msg, args));
2240
+ }
2235
2241
  });
2236
2242
  def("toHaveBeenNthCalledWith", function(times, ...args) {
2237
2243
  const spy = getSpy(this);
@@ -7613,20 +7619,23 @@ function createExpectPoll(expect) {
7613
7619
  }
7614
7620
  });
7615
7621
  let resultPromise;
7622
+ // lets `expect.element` register the poll with the task deadline
7623
+ const wrap = chai.util.flag(assertion, "_poll.wrap");
7624
+ const start = () => resultPromise ||= wrap ? wrap(promise(), STACK_TRACE_ERROR) : promise();
7616
7625
  // only .then is enough to check awaited, but we type this as `Promise<void>` in global types
7617
7626
  // so let's follow it
7618
7627
  return {
7619
7628
  then(onFulfilled, onRejected) {
7620
7629
  awaited = true;
7621
- return (resultPromise ||= promise()).then(onFulfilled, onRejected);
7630
+ return start().then(onFulfilled, onRejected);
7622
7631
  },
7623
7632
  catch(onRejected) {
7624
7633
  awaited = true;
7625
- return (resultPromise ||= promise()).catch(onRejected);
7634
+ return start().catch(onRejected);
7626
7635
  },
7627
7636
  finally(onFinally) {
7628
7637
  awaited = true;
7629
- return (resultPromise ||= promise()).finally(onFinally);
7638
+ return start().finally(onFinally);
7630
7639
  },
7631
7640
  [Symbol.toStringTag]: "Promise"
7632
7641
  };
@@ -8414,11 +8423,10 @@ class TestRunner {
8414
8423
  if (this.pool !== "vmThreads" && this.pool !== "vmForks") this.onCleanupWorkerContext = (listener) => this.workerState.onCleanup(listener);
8415
8424
  }
8416
8425
  importFile(filepath, source) {
8417
- const moduleNode = this.workerState.evaluatedModules.getModuleById(filepath);
8418
- if (moduleNode && (source === "setup" || moduleNode.evaluated)) this.workerState.evaluatedModules.invalidateModule(moduleNode);
8419
8426
  return this._otel.$(`vitest.module.import_${source === "setup" ? "setup" : "spec"}`, { attributes: { "code.file.path": filepath } }, () => {
8420
8427
  if (!this.viteModuleRunner) filepath = `${filepath}?vitest=${Date.now()}`;
8421
- return this.moduleRunner.import(filepath);
8428
+ const options = this.viteModuleRunner ? { invalidate: true } : void 0;
8429
+ return this.moduleRunner.import(filepath, options);
8422
8430
  });
8423
8431
  }
8424
8432
  onCollectStart(file) {