vitest 5.1.0-beta.1 → 5.1.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.
Files changed (58) hide show
  1. package/dist/browser.d.ts +6 -5
  2. package/dist/browser.js +6 -6
  3. package/dist/chunks/{base.PJyN9N0u.js → base.Cof-UHJf.js} +14 -19
  4. package/dist/chunks/{browser.d.D7a15z82.d.ts → browser.d.C7tWgUvw.d.ts} +3 -3
  5. package/dist/chunks/{cac.Ccf5Je_F.js → cac.BYbt0aJp.js} +22 -20
  6. package/dist/chunks/{cli-api.DE22LIzq.js → cli-api.COfZo8lK.js} +714 -73
  7. package/dist/chunks/{config.d.BgktgHfG.d.ts → config.d.B3YV4t0O.d.ts} +37 -2
  8. package/dist/chunks/{console.DrMPSuFo.js → console.CQZ877Hi.js} +2 -2
  9. package/dist/chunks/{coverage.-bm5IxnW.js → coverage.9iqXE2gN.js} +1 -1
  10. package/dist/chunks/{coverage.cTDc4uSS.js → coverage.jGCktcGP.js} +1 -1
  11. package/dist/chunks/{creator.BQ3onxbh.js → creator.DHWmytIK.js} +10 -10
  12. package/dist/chunks/{doctor.CPlMs7-y.js → doctor.B-oPbwps.js} +2 -2
  13. package/dist/chunks/{environment.d.CbTLsZSj.d.ts → environment.d.BFQtFKdZ.d.ts} +1 -1
  14. package/dist/chunks/{globals.TipXUFcZ.js → globals.ZKtKSkEf.js} +6 -5
  15. package/dist/chunks/{index.BFXLpwll.js → index.Bi0NXYPf.js} +58 -32
  16. package/dist/chunks/{index.BXttT2gP.js → index.CZzC1gGg.js} +265 -425
  17. package/dist/chunks/{index.D14IAvnE.js → index.Di8au7q4.js} +68 -62
  18. package/dist/chunks/{index.B03wg4V0.js → index.w_oBZ9N8.js} +5 -5
  19. package/dist/chunks/{init-forks.BL1E3__4.js → init-forks.BaDXQSD8.js} +1 -1
  20. package/dist/chunks/{init-threads.CYXAGzKQ.js → init-threads.ZX_Vov0z.js} +1 -1
  21. package/dist/chunks/{init.DVorxUyL.js → init.CO4AB7HZ.js} +4 -4
  22. package/dist/chunks/{module-dependencies.CwNPkcV4.js → module-dependencies._2Eei3FO.js} +1 -1
  23. package/dist/chunks/{native.cdzHIdmv.js → native.upB-V0CK.js} +1 -1
  24. package/dist/chunks/{nativeModuleMocker.3uBcOd84.js → nativeModuleMocker.Dh5azSB4.js} +3 -3
  25. package/dist/chunks/{nativeModuleRunner.xi64Afb2.js → nativeModuleRunner.9xPIMzi7.js} +1 -1
  26. package/dist/chunks/{node.uQulW0ei.js → node.B9mkVmLH.js} +1 -1
  27. package/dist/chunks/{pathe.M-eThtNZ.Ba-7h1rE.js → pathe.M-eThtNZ.zq3TM4NT.js} +1 -1
  28. package/dist/chunks/{plugin.d.olEn8IL9.d.ts → plugin.d.LRFSN46m.d.ts} +90 -19
  29. package/dist/chunks/rawSnapshot.DqSiqIEx.js +356 -0
  30. package/dist/chunks/{resolver.CtCcxIy1.js → resolver.BzpmeQeT.js} +1 -1
  31. package/dist/chunks/{rpc.BV0XpJ5q.js → rpc.Uhkwr2NM.js} +2 -2
  32. package/dist/chunks/{rpc.d.DGFP7vWr.d.ts → rpc.d.3FOhdFx8.d.ts} +1 -1
  33. package/dist/chunks/{run.BfrMbGVD.js → run.CjdgFZiW.js} +7 -4
  34. package/dist/chunks/{setup-common.llxJkJaD.js → setup-common.CqAQCXzx.js} +2 -2
  35. package/dist/chunks/{source-map.BjWcsIL9.js → source-map.DakdQc29.js} +11 -13
  36. package/dist/chunks/{source-map.d.C5A_Tr6V.d.ts → source-map.d.BkG8YK_3.d.ts} +1 -1
  37. package/dist/chunks/{task-utils.d.BUh7ylUT.d.ts → task-utils.d.D-gFPNFi.d.ts} +1 -1
  38. package/dist/chunks/{utils.DSfl_w8V.js → utils.BBk_icFG.js} +6 -3
  39. package/dist/chunks/{vm.Cwj01UFE.js → vm.b4MbCAJQ.js} +15 -13
  40. package/dist/chunks/{worker.d.gsA26mmR.d.ts → worker.d.CyJRpyfZ.d.ts} +3 -3
  41. package/dist/cli.js +2 -2
  42. package/dist/config.d.ts +8 -8
  43. package/dist/index.d.ts +17 -12
  44. package/dist/index.js +6 -5
  45. package/dist/module-evaluator.d.ts +2 -2
  46. package/dist/node.d.ts +10 -10
  47. package/dist/node.js +15 -13
  48. package/dist/runtime.d.ts +4 -4
  49. package/dist/runtime.js +4 -4
  50. package/dist/task-utils.js +7 -3
  51. package/dist/worker.d.ts +4 -4
  52. package/dist/worker.js +14 -13
  53. package/dist/workers/forks.js +15 -14
  54. package/dist/workers/runVmTests.js +13 -10
  55. package/dist/workers/threads.js +15 -14
  56. package/dist/workers/vmForks.js +10 -10
  57. package/dist/workers/vmThreads.js +10 -10
  58. package/package.json +15 -15
package/dist/browser.d.ts CHANGED
@@ -1,12 +1,14 @@
1
- import { F as FileSpecification, c as SerializedDiffOptions } from './chunks/config.d.BgktgHfG.js';
1
+ import { F as FileSpecification, c as SerializedDiffOptions } from './chunks/config.d.B3YV4t0O.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.BgktgHfG.js';
5
- import { R as RuntimeCoverageModuleLoader } from './chunks/source-map.d.C5A_Tr6V.js';
6
- export { D as DecodedMap, g as getOriginalPosition } from './chunks/source-map.d.C5A_Tr6V.js';
4
+ export { P as ParsedStack, _ as SpyModule, d as StringifyOptions, f as format, i as inspect, s as stringify } from './chunks/config.d.B3YV4t0O.js';
5
+ import { R as RuntimeCoverageModuleLoader } from './chunks/source-map.d.BkG8YK_3.js';
6
+ export { D as DecodedMap, g as getOriginalPosition } from './chunks/source-map.d.BkG8YK_3.js';
7
7
  import 'vitest/optional-runtime-types.js';
8
8
  import 'tinybench';
9
9
 
10
+ type BrowserTraceEntryKind = "action" | "expect" | "mark" | "lifecycle";
11
+
10
12
  declare function getType(value: unknown): string;
11
13
 
12
14
  interface SafeTimers {
@@ -59,7 +61,6 @@ interface BrowserCommands {
59
61
  removeFile: (path: string) => Promise<void>;
60
62
  }
61
63
  interface CDPSession {}
62
- type BrowserTraceEntryKind = "action" | "expect" | "mark" | "lifecycle";
63
64
  interface MarkOptions {
64
65
  /**
65
66
  * Optional stack string used to resolve marker location.
package/dist/browser.js CHANGED
@@ -1,11 +1,11 @@
1
- export { s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/coverage.-bm5IxnW.js';
2
- export { p as collectTests, a as processError, s as startTests } from './chunks/run.BfrMbGVD.js';
3
- export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as setupEnv } from './chunks/setup-common.llxJkJaD.js';
1
+ export { s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/coverage.9iqXE2gN.js';
2
+ export { p as collectTests, a as processError, s as startTests } from './chunks/run.CjdgFZiW.js';
3
+ export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as setupEnv } from './chunks/setup-common.CqAQCXzx.js';
4
4
  export { s as SpyModule } from './chunks/spy.DDMXghXv.js';
5
5
  export { f as format, i as inspect, s as stringify } from './chunks/display.BlTmubjj.js';
6
- export { g as getType } from './chunks/pathe.M-eThtNZ.Ba-7h1rE.js';
7
- export { D as DecodedMap, g as getOriginalPosition, a as getSafeTimers, s as setSafeTimers } from './chunks/source-map.BjWcsIL9.js';
8
- import './chunks/coverage.cTDc4uSS.js';
6
+ export { g as getType } from './chunks/pathe.M-eThtNZ.zq3TM4NT.js';
7
+ export { D as DecodedMap, g as getOriginalPosition, a as getSafeTimers, s as setSafeTimers } from './chunks/source-map.DakdQc29.js';
8
+ import './chunks/coverage.jGCktcGP.js';
9
9
  import './chunks/index.D0heQG4v.js';
10
10
  import './chunks/tinyrainbow.Do8I1XRG.js';
11
11
  import './task-utils.js';
@@ -1,22 +1,22 @@
1
1
  import { runInThisContext } from 'node:vm';
2
2
  import { s as spyModule } from './spy.DDMXghXv.js';
3
- import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.B03wg4V0.js';
4
- import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.DVorxUyL.js';
5
- import { n as nativeImports, g as getEvaluatedImports, c as collectDependencies } from './module-dependencies.CwNPkcV4.js';
3
+ import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.w_oBZ9N8.js';
4
+ import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.CO4AB7HZ.js';
5
+ import { n as nativeImports, g as getEvaluatedImports, c as collectDependencies } from './module-dependencies._2Eei3FO.js';
6
6
  import { Traces } from '../traces.js';
7
- import { V as VitestEvaluatedModules } from './rpc.BV0XpJ5q.js';
8
- import { s as startVitestModuleRunner, c as createNodeImportMeta } from './index.BFXLpwll.js';
7
+ import { V as VitestEvaluatedModules } from './rpc.Uhkwr2NM.js';
8
+ import { s as startVitestModuleRunner, c as createNodeImportMeta } from './index.Bi0NXYPf.js';
9
9
  import { performance as performance$1 } from 'node:perf_hooks';
10
- import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './coverage.-bm5IxnW.js';
11
- import { i as index, g as globalExpect, v as vi } from './index.BXttT2gP.js';
10
+ import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './coverage.9iqXE2gN.js';
11
+ import { i as index, g as globalExpect, v as vi } from './index.CZzC1gGg.js';
12
12
  import { c as closeInspector } from './inspector.CvyFGlXm.js';
13
- import { s as startTests, p as publicCollect } from './run.BfrMbGVD.js';
13
+ import { s as startTests, p as publicCollect } from './run.CjdgFZiW.js';
14
14
  import { createRequire, syncBuiltinESMExports } from 'node:module';
15
15
  import timers from 'node:timers';
16
16
  import timersPromises from 'node:timers/promises';
17
17
  import util from 'node:util';
18
- import { K as KNOWN_ASSET_TYPES } from './pathe.M-eThtNZ.Ba-7h1rE.js';
19
- import { s as setupCommonEnv, b as setupEnv } from './setup-common.llxJkJaD.js';
18
+ import { K as KNOWN_ASSET_TYPES } from './pathe.M-eThtNZ.zq3TM4NT.js';
19
+ import { s as setupCommonEnv, b as setupEnv } from './setup-common.CqAQCXzx.js';
20
20
  import { g as getWorkerState, r as resetModules, p as provideWorkerState, a as getSafeWorkerState } from './utils.DYj33du9.js';
21
21
 
22
22
  // this should only be used in Node
@@ -59,7 +59,7 @@ function resolveAsset(mod, url) {
59
59
  mod.exports = url;
60
60
  }
61
61
  async function setupConsoleLogSpy() {
62
- const { createCustomConsole } = await import('./console.DrMPSuFo.js');
62
+ const { createCustomConsole } = await import('./console.CQZ877Hi.js');
63
63
  globalThis.console = createCustomConsole();
64
64
  }
65
65
 
@@ -128,7 +128,7 @@ async function startModuleRunner(options) {
128
128
  let mocker;
129
129
  if (options.state.config.experimental.nodeLoader !== false) {
130
130
  // this additionally imports acorn/magic-string
131
- const { NativeModuleMocker } = await import('./nativeModuleMocker.3uBcOd84.js');
131
+ const { NativeModuleMocker } = await import('./nativeModuleMocker.Dh5azSB4.js');
132
132
  mocker = new NativeModuleMocker({
133
133
  async resolveId(id, importer) {
134
134
  // TODO: use import.meta.resolve instead
@@ -145,7 +145,7 @@ async function startModuleRunner(options) {
145
145
  }
146
146
  // imported lazily (pulls in `local-pkg`) so it stays out of the default
147
147
  // worker startup graph; only the `viteModuleRunner: false` path needs it
148
- const { NativeModuleRunner } = await import('./nativeModuleRunner.xi64Afb2.js').then(function (n) { return n.n; });
148
+ const { NativeModuleRunner } = await import('./nativeModuleRunner.9xPIMzi7.js').then(function (n) { return n.n; });
149
149
  _moduleRunner = new NativeModuleRunner(root, mocker);
150
150
  return _moduleRunner;
151
151
  }
@@ -165,7 +165,7 @@ function recordNativeImport(url, parentURL) {
165
165
  /** @experimental */
166
166
  async function setupBaseEnvironment(context) {
167
167
  if (context.config.experimental.viteModuleRunner === false) {
168
- const { setupNodeLoaderHooks } = await import('./native.cdzHIdmv.js');
168
+ const { setupNodeLoaderHooks } = await import('./native.upB-V0CK.js');
169
169
  const recordDependencies = context.config.experimental.recordDependencies;
170
170
  _canRecordDependencies = await setupNodeLoaderHooks(context, recordDependencies ? recordNativeImport : void 0);
171
171
  // until the tests start, the imports belong to the environment
@@ -212,11 +212,6 @@ async function runBaseTests(method, state, traces) {
212
212
  } catch (error) {
213
213
  throw new Error(`Failed to load custom "defines": ${error.message}`);
214
214
  }
215
- if (ctx.invalidates) ctx.invalidates.forEach((filepath) => {
216
- (state.evaluatedModules.fileToModulesMap.get(filepath) || []).forEach((module) => {
217
- state.evaluatedModules.invalidateModule(module);
218
- });
219
- });
220
215
  ctx.files.forEach((i) => {
221
216
  const filepath = i.filepath;
222
217
  (state.evaluatedModules.fileToModulesMap.get(filepath) || []).forEach((module) => {
@@ -1,6 +1,6 @@
1
- import { F as FileSpecification } from './config.d.BgktgHfG.js';
2
- import { O as OTELCarrier } from './rpc.d.DGFP7vWr.js';
3
- import { T as TestExecutionMethod } from './worker.d.gsA26mmR.js';
1
+ import { F as FileSpecification } from './config.d.B3YV4t0O.js';
2
+ import { O as OTELCarrier } from './rpc.d.3FOhdFx8.js';
3
+ import { T as TestExecutionMethod } from './worker.d.CyJRpyfZ.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.Ba-7h1rE.js';
1
+ import { n as normalize, t as toArray } from './pathe.M-eThtNZ.zq3TM4NT.js';
2
2
  import { EventEmitter } from 'events';
3
3
  import { w } from './tinyrainbow.Do8I1XRG.js';
4
4
  import { i as isForceColor } from './env.BKKtU2WC.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.1.0-beta.1";
623
+ var version = "5.1.0";
624
624
 
625
625
  const apiConfig = (port) => ({
626
626
  port: {
@@ -892,11 +892,18 @@ const cliOptionsConfig = {
892
892
  }
893
893
  },
894
894
  traceView: {
895
- description: "Enable Vitest trace-view collection for browser tests (default: `false`)",
895
+ description: "Enable Vitest trace-view collection for browser tests. `true` records every test, and `false` turns it off (default: `\"failure-only\"`)",
896
896
  argument: "",
897
- transform: transformNestedBoolean,
897
+ transform(value) {
898
+ if (typeof value === "boolean") return { mode: value ? "on" : "off" };
899
+ return value;
900
+ },
898
901
  subcommands: {
899
- enabled: { description: "Enable Vitest trace-view collection for browser tests (default: `false`)" },
902
+ enabled: { description: "Deprecated, use `--browser.traceView.mode` instead. `true` is the same as `--browser.traceView.mode=on`" },
903
+ mode: {
904
+ description: "How trace view records tests. Supported: \"on\" (every test), \"failure-only\" (only failed tests), \"off\" (default: `\"failure-only\"`)",
905
+ argument: "<mode>"
906
+ },
900
907
  recordCanvas: { description: "Capture canvas pixels in trace-view snapshots (default: `false`)" },
901
908
  inlineImages: { description: "Inline loaded image pixels in trace-view snapshots (default: `false`)" },
902
909
  ariaSnapshot: { description: "Capture the accessibility tree in trace-view snapshots (default: `true`)" }
@@ -963,10 +970,7 @@ const cliOptionsConfig = {
963
970
  description: "Run tests that are affected by the changed files (default: `false`)",
964
971
  argument: "[since]"
965
972
  },
966
- sinceLastRun: {
967
- alias: "since-last-run",
968
- description: "Run only the tests whose recorded dependencies were modified since the last run of the test, and the tests that failed in their last run. Enables `--changed`, `--experimental.recordDependencies` and the `mtime` provider (default: `false`)"
969
- },
973
+ sinceLastRun: { description: "Run only the tests whose recorded dependencies were modified since the last run of the test, and the tests that failed in their last run. Enables `--changed`, `--experimental.recordDependencies` and the `mtime` provider (default: `false`)" },
970
974
  lastFailed: { description: "Run only the tests that failed in the last run (default: `false`)" },
971
975
  sequence: {
972
976
  description: "Options for how tests should be sorted",
@@ -1277,6 +1281,7 @@ const cliOptionsConfig = {
1277
1281
  },
1278
1282
  viteModuleRunner: { description: "Control whether Vitest uses Vite's module runner to run the code or fallback to the native `import`. (default: `true`)" },
1279
1283
  nodeLoader: { description: "Controls whether Vitest will use Node.js Loader API to process in-source or mocked files. This has no effect if `viteModuleRunner` is enabled. Disabling this can increase performance. (default: `true`)" },
1284
+ traceTimeline: { description: "Record `expect.poll`, `vi.waitFor`, and `vi.waitUntil` steps of each test and print them as a timeline when the test fails. This has no effect in browser mode. (default: `false`)" },
1280
1285
  vcsProvider: {
1281
1286
  argument: "<path>",
1282
1287
  description: "Provider for detecting changed files: `git`, `mtime` (requires `experimental.recordDependencies`) or a path to a custom provider. (default: `git`)",
@@ -1354,10 +1359,7 @@ const collectCliOptionsConfig = {
1354
1359
  description: "Print only tests that are affected by the changed files (default: `false`)",
1355
1360
  argument: "[since]"
1356
1361
  },
1357
- sinceLastRun: {
1358
- alias: "since-last-run",
1359
- description: "Print only the tests whose recorded dependencies were modified since the last run of the test, and the tests that failed in their last run (default: `false`)"
1360
- },
1362
+ sinceLastRun: { description: "Print only the tests whose recorded dependencies were modified since the last run of the test, and the tests that failed in their last run (default: `false`)" },
1361
1363
  lastFailed: { description: "Print only the tests that failed in the last run (default: `false`)" }
1362
1364
  };
1363
1365
 
@@ -2376,11 +2378,11 @@ function normalizeCliOptions(cliFilters, argv) {
2376
2378
  }
2377
2379
  async function start(cliFilters, options) {
2378
2380
  try {
2379
- const { startVitest } = await import('./cli-api.DE22LIzq.js').then(function (n) { return n.j; });
2381
+ const { startVitest } = await import('./cli-api.COfZo8lK.js').then(function (n) { return n.j; });
2380
2382
  const ctx = await startVitest(cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
2381
2383
  if (!ctx.shouldKeepServer()) await ctx.exit();
2382
2384
  } catch (e) {
2383
- const { errorBanner } = await import('./utils.DSfl_w8V.js').then(function (n) { return n.u; });
2385
+ const { errorBanner } = await import('./utils.BBk_icFG.js').then(function (n) { return n.u; });
2384
2386
  console.error(`\n${errorBanner("Startup Error")}`);
2385
2387
  console.error(e);
2386
2388
  console.error("\n\n");
@@ -2390,11 +2392,11 @@ async function start(cliFilters, options) {
2390
2392
  }
2391
2393
  async function doctorCommand(cliFilters, options) {
2392
2394
  try {
2393
- const { doctor } = await import('./doctor.CPlMs7-y.js');
2395
+ const { doctor } = await import('./doctor.B-oPbwps.js');
2394
2396
  await doctor(cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
2395
2397
  process.exit();
2396
2398
  } catch (e) {
2397
- const { errorBanner } = await import('./utils.DSfl_w8V.js').then(function (n) { return n.u; });
2399
+ const { errorBanner } = await import('./utils.BBk_icFG.js').then(function (n) { return n.u; });
2398
2400
  console.error(`\n${errorBanner("Doctor Error")}`);
2399
2401
  console.error(e);
2400
2402
  console.error("\n\n");
@@ -2407,12 +2409,12 @@ async function init(project) {
2407
2409
  console.error(/* @__PURE__ */ new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project."));
2408
2410
  process.exit(1);
2409
2411
  }
2410
- const { create } = await import('./creator.BQ3onxbh.js');
2412
+ const { create } = await import('./creator.DHWmytIK.js');
2411
2413
  await create();
2412
2414
  }
2413
2415
  async function collect(cliFilters, options) {
2414
2416
  try {
2415
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.DE22LIzq.js').then(function (n) { return n.j; });
2417
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.COfZo8lK.js').then(function (n) { return n.j; });
2416
2418
  const ctx = await prepareVitest({
2417
2419
  ...normalizeCliOptions(cliFilters, options),
2418
2420
  watch: false,
@@ -2434,7 +2436,7 @@ async function collect(cliFilters, options) {
2434
2436
  } else outputFileList(await ctx.getRelevantTestSpecifications(cliFilters.map(normalize)), options);
2435
2437
  await ctx.close();
2436
2438
  } catch (e) {
2437
- const { errorBanner } = await import('./utils.DSfl_w8V.js').then(function (n) { return n.u; });
2439
+ const { errorBanner } = await import('./utils.BBk_icFG.js').then(function (n) { return n.u; });
2438
2440
  console.error(`\n${errorBanner("Collect Error")}`);
2439
2441
  console.error(e);
2440
2442
  console.error("\n\n");