vitest 4.0.0-beta.4 → 4.0.0-beta.6

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 (78) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/browser.d.ts +8 -9
  3. package/dist/browser.js +3 -2
  4. package/dist/chunks/base.BXI97p6t.js +39 -0
  5. package/dist/chunks/{benchmark.CYdenmiT.js → benchmark.UW6Ezvxy.js} +6 -8
  6. package/dist/chunks/{browser.d.BRP8scJf.d.ts → browser.d.Cawq_X_N.d.ts} +1 -1
  7. package/dist/chunks/{cac.CY0IAxC4.js → cac.WE-urWw5.js} +38 -115
  8. package/dist/chunks/{cli-api.B8xRY9Zt.js → cli-api.CZz3evYC.js} +931 -1439
  9. package/dist/chunks/{config.d.DZo8c7fw.d.ts → config.d.CKNVOKm0.d.ts} +3 -8
  10. package/dist/chunks/{console.DoJHFxmj.js → console.B0quX7yH.js} +32 -68
  11. package/dist/chunks/{constants.CXzqaLmq.js → constants.D_Q9UYh-.js} +1 -6
  12. package/dist/chunks/{coverage.C84l9G-M.js → coverage.BPRS6xgn.js} +395 -665
  13. package/dist/chunks/{coverage.DVF1vEu8.js → coverage.D_JHT54q.js} +2 -2
  14. package/dist/chunks/{coverage.d.CNYjU4GF.d.ts → coverage.d.BZtK59WP.d.ts} +7 -5
  15. package/dist/chunks/{creator.yfA2ExGt.js → creator.KEg6n5IC.js} +29 -75
  16. package/dist/chunks/{date.Bq6ZW5rf.js → date.-jtEtIeV.js} +6 -17
  17. package/dist/chunks/{environment.d.Bhm9oc0v.d.ts → environment.d.2fYMoz3o.d.ts} +26 -4
  18. package/dist/chunks/{git.BVQ8w_Sw.js → git.BFNcloKD.js} +1 -2
  19. package/dist/chunks/{global.d.DAhT2emn.d.ts → global.d.K6uBQHzY.d.ts} +1 -1
  20. package/dist/chunks/{globals.Dgo-vS5G.js → globals.lgsmH00r.js} +7 -6
  21. package/dist/chunks/{index.D3SKT3tv.js → index.7w0eqmYM.js} +14 -24
  22. package/dist/chunks/{index.D1_MsKEt.js → index.AR8aAkCC.js} +4 -2
  23. package/dist/chunks/{index.CmSc2RE5.js → index.BG0gqZH-.js} +43 -106
  24. package/dist/chunks/{index.CtUvr1c8.js → index.CsFXYRkW.js} +27 -46
  25. package/dist/chunks/{index.Bz6b0Ib7.js → index.VNI-1z5c.js} +276 -604
  26. package/dist/chunks/{inspector.C914Efll.js → inspector.CvQD-Nie.js} +10 -25
  27. package/dist/chunks/moduleRunner.d.8kKUsuDg.d.ts +202 -0
  28. package/dist/chunks/moduleTransport.I-bgQy0S.js +19 -0
  29. package/dist/chunks/{node.fjCdwEIl.js → node.BOqcT2jW.js} +1 -1
  30. package/dist/chunks/{plugin.d.CLhMcYdD.d.ts → plugin.d.DuiQJfUL.d.ts} +1 -1
  31. package/dist/chunks/{reporters.d.DWg40D2B.d.ts → reporters.d.CqR9-CDJ.d.ts} +52 -101
  32. package/dist/chunks/resolver.Bx6lE0iq.js +119 -0
  33. package/dist/chunks/{rpc.jnQO9F8a.js → rpc.RpPylpp0.js} +7 -21
  34. package/dist/chunks/runBaseTests.D6sfuWBM.js +99 -0
  35. package/dist/chunks/{setup-common.Ebx5x0eP.js → setup-common.hLGRxhC8.js} +15 -27
  36. package/dist/chunks/startModuleRunner.C8TW8zTN.js +655 -0
  37. package/dist/chunks/{typechecker.CMNPqJOo.js → typechecker.Cd1wvxUM.js} +97 -209
  38. package/dist/chunks/{utils.CcGm2cd1.js → utils.C2YI6McM.js} +4 -13
  39. package/dist/chunks/{utils.XdZDrNZV.js → utils.C7__0Iv5.js} +7 -17
  40. package/dist/chunks/{vi.CA0EPI9Y.js → vi.BfdOiD4j.js} +116 -269
  41. package/dist/chunks/{vm.BUnLJt_P.js → vm.BHBje7cC.js} +101 -225
  42. package/dist/chunks/{worker.d.zjyR34Pb.d.ts → worker.d.D9QWnzAe.d.ts} +16 -13
  43. package/dist/chunks/{worker.d.C-1AbnVe.d.ts → worker.d.Db-UVmXc.d.ts} +1 -1
  44. package/dist/cli.js +4 -4
  45. package/dist/config.cjs +3 -9
  46. package/dist/config.d.ts +10 -12
  47. package/dist/config.js +1 -1
  48. package/dist/coverage.d.ts +10 -11
  49. package/dist/coverage.js +5 -6
  50. package/dist/environments.d.ts +2 -2
  51. package/dist/environments.js +1 -1
  52. package/dist/index.d.ts +10 -9
  53. package/dist/index.js +6 -5
  54. package/dist/module-evaluator.d.ts +12 -0
  55. package/dist/module-evaluator.js +276 -0
  56. package/dist/module-runner.js +15 -0
  57. package/dist/node.d.ts +12 -13
  58. package/dist/node.js +19 -24
  59. package/dist/reporters.d.ts +7 -8
  60. package/dist/reporters.js +3 -3
  61. package/dist/runners.d.ts +3 -3
  62. package/dist/runners.js +35 -57
  63. package/dist/snapshot.js +2 -2
  64. package/dist/suite.js +2 -2
  65. package/dist/worker.js +82 -45
  66. package/dist/workers/forks.js +11 -10
  67. package/dist/workers/runVmTests.js +27 -46
  68. package/dist/workers/threads.js +11 -10
  69. package/dist/workers/vmForks.js +11 -10
  70. package/dist/workers/vmThreads.js +11 -10
  71. package/dist/workers.d.ts +5 -4
  72. package/dist/workers.js +17 -16
  73. package/package.json +22 -17
  74. package/dist/chunks/base.BaCDDRPG.js +0 -38
  75. package/dist/chunks/execute.Dt-pCVcL.js +0 -708
  76. package/dist/chunks/runBaseTests.DBVVLMSb.js +0 -129
  77. package/dist/execute.d.ts +0 -148
  78. package/dist/execute.js +0 -13
package/LICENSE.md CHANGED
@@ -3,7 +3,7 @@ Vitest is released under the MIT license:
3
3
 
4
4
  MIT License
5
5
 
6
- Copyright (c) 2021-Present Vitest Team
6
+ Copyright (c) 2021-Present VoidZero Inc. and Vitest contributors
7
7
 
8
8
  Permission is hereby granted, free of charge, to any person obtaining a copy
9
9
  of this software and associated documentation files (the "Software"), to deal
package/dist/browser.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.DZo8c7fw.js';
2
- import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.CNYjU4GF.js';
1
+ import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.CKNVOKm0.js';
2
+ import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.BZtK59WP.js';
3
3
  import { SerializedDiffOptions } from '@vitest/utils/diff';
4
- import { VitestExecutor } from './execute.js';
4
+ import { V as VitestModuleRunner } from './chunks/moduleRunner.d.8kKUsuDg.js';
5
5
  export { collectTests, processError, startTests } from '@vitest/runner';
6
6
  import * as spy from '@vitest/spy';
7
7
  export { spy as SpyModule };
@@ -9,11 +9,10 @@ export { LoupeOptions, ParsedStack, StringifyOptions, format, getSafeTimers, ins
9
9
  export { TraceMap, originalPositionFor } from '@vitest/utils/source-map';
10
10
  import '@vitest/pretty-format';
11
11
  import '@vitest/snapshot';
12
- import 'vite-node/client';
13
- import 'vite-node';
14
- import './chunks/worker.d.zjyR34Pb.js';
15
- import './chunks/environment.d.Bhm9oc0v.js';
16
12
  import 'node:vm';
13
+ import 'vite/module-runner';
14
+ import './chunks/worker.d.D9QWnzAe.js';
15
+ import './chunks/environment.d.2fYMoz3o.js';
17
16
  import '@vitest/mocker';
18
17
  import './chunks/mocker.d.BE_2ls6u.js';
19
18
 
@@ -26,7 +25,7 @@ declare function stopCoverageInsideWorker(options: SerializedCoverageConfig | un
26
25
  }): Promise<unknown>;
27
26
 
28
27
  declare function setupCommonEnv(config: SerializedConfig): Promise<void>;
29
- declare function loadDiffConfig(config: SerializedConfig, executor: VitestExecutor): Promise<SerializedDiffOptions | undefined>;
30
- declare function loadSnapshotSerializers(config: SerializedConfig, executor: VitestExecutor): Promise<void>;
28
+ declare function loadDiffConfig(config: SerializedConfig, moduleRunner: VitestModuleRunner): Promise<SerializedDiffOptions | undefined>;
29
+ declare function loadSnapshotSerializers(config: SerializedConfig, moduleRunner: VitestModuleRunner): Promise<void>;
31
30
 
32
31
  export { loadDiffConfig, loadSnapshotSerializers, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, takeCoverageInsideWorker };
package/dist/browser.js CHANGED
@@ -1,8 +1,9 @@
1
- export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.Ebx5x0eP.js';
1
+ export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.hLGRxhC8.js';
2
2
  export { collectTests, processError, startTests } from '@vitest/runner';
3
3
  import * as spy from '@vitest/spy';
4
4
  export { spy as SpyModule };
5
5
  export { format, getSafeTimers, inspect, stringify } from '@vitest/utils';
6
6
  export { TraceMap, originalPositionFor } from '@vitest/utils/source-map';
7
- import './chunks/coverage.DVF1vEu8.js';
7
+ import './chunks/coverage.D_JHT54q.js';
8
8
  import '@vitest/snapshot';
9
+ import './chunks/utils.C7__0Iv5.js';
@@ -0,0 +1,39 @@
1
+ import { EvaluatedModules } from 'vite/module-runner';
2
+ import { s as startVitestModuleRunner } from './startModuleRunner.C8TW8zTN.js';
3
+ import { p as provideWorkerState } from './utils.C7__0Iv5.js';
4
+
5
+ let _moduleRunner;
6
+ const evaluatedModules = new EvaluatedModules(), moduleExecutionInfo = /* @__PURE__ */ new Map();
7
+ async function startModuleRunner(options) {
8
+ return _moduleRunner || (_moduleRunner = await startVitestModuleRunner(options), _moduleRunner);
9
+ }
10
+ async function runBaseTests(method, state) {
11
+ const { ctx } = state;
12
+ if (state.evaluatedModules = evaluatedModules, state.moduleExecutionInfo = moduleExecutionInfo, provideWorkerState(globalThis, state), ctx.invalidates) ctx.invalidates.forEach((filepath) => {
13
+ const modules = state.evaluatedModules.fileToModulesMap.get(filepath) || [];
14
+ modules.forEach((module) => {
15
+ state.evaluatedModules.invalidateModule(module);
16
+ });
17
+ // evaluatedModules.delete(fsPath)
18
+ // evaluatedModules.delete(`mock:${fsPath}`)
19
+ });
20
+ ctx.files.forEach((i) => {
21
+ const filepath = typeof i === "string" ? i : i.filepath, modules = state.evaluatedModules.fileToModulesMap.get(filepath) || [];
22
+ modules.forEach((module) => {
23
+ state.evaluatedModules.invalidateModule(module);
24
+ });
25
+ });
26
+ const [executor, { run }] = await Promise.all([startModuleRunner({
27
+ state,
28
+ evaluatedModules: state.evaluatedModules
29
+ }), import('./runBaseTests.D6sfuWBM.js')]), fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
30
+ filepath: f,
31
+ testLocations: void 0
32
+ } : f);
33
+ await run(method, fileSpecs, ctx.config, {
34
+ environment: state.environment,
35
+ options: ctx.environment.options
36
+ }, executor);
37
+ }
38
+
39
+ export { runBaseTests as r };
@@ -1,10 +1,9 @@
1
1
  import { getCurrentSuite } from '@vitest/runner';
2
2
  import { createChainable } from '@vitest/runner/utils';
3
3
  import { noop } from '@vitest/utils';
4
- import { g as getWorkerState } from './utils.XdZDrNZV.js';
4
+ import { g as getWorkerState } from './utils.C7__0Iv5.js';
5
5
 
6
- const benchFns = /* @__PURE__ */ new WeakMap();
7
- const benchOptsMap = /* @__PURE__ */ new WeakMap();
6
+ const benchFns = /* @__PURE__ */ new WeakMap(), benchOptsMap = /* @__PURE__ */ new WeakMap();
8
7
  function getBenchOptions(key) {
9
8
  return benchOptsMap.get(key);
10
9
  }
@@ -17,8 +16,9 @@ const bench = createBenchmark(function(name, fn = noop, options = {}) {
17
16
  ...this,
18
17
  meta: { benchmark: true }
19
18
  });
20
- benchFns.set(task, fn);
21
- benchOptsMap.set(task, options);
19
+ // vitest runner sets mode to `todo` if handler is not passed down
20
+ // but we store handler separetly
21
+ if (benchFns.set(task, fn), benchOptsMap.set(task, options), !this.todo && task.mode === "todo") task.mode = "run";
22
22
  });
23
23
  function createBenchmark(fn) {
24
24
  const benchmark = createChainable([
@@ -26,9 +26,7 @@ function createBenchmark(fn) {
26
26
  "only",
27
27
  "todo"
28
28
  ], fn);
29
- benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark;
30
- benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip;
31
- return benchmark;
29
+ return benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark, benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip, benchmark;
32
30
  }
33
31
  function formatName(name) {
34
32
  return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
@@ -1,4 +1,4 @@
1
- import { T as TestExecutionMethod } from './worker.d.zjyR34Pb.js';
1
+ import { T as TestExecutionMethod } from './worker.d.D9QWnzAe.js';
2
2
 
3
3
  type SerializedTestSpecification = [project: {
4
4
  name: string | undefined;
@@ -2,8 +2,8 @@ import { toArray } from '@vitest/utils';
2
2
  import { EventEmitter } from 'events';
3
3
  import { normalize } from 'pathe';
4
4
  import c from 'tinyrainbow';
5
- import { a as defaultPort, d as defaultBrowserPort } from './constants.CXzqaLmq.js';
6
- import { R as ReportersMap } from './index.Bz6b0Ib7.js';
5
+ import { a as defaultPort, d as defaultBrowserPort } from './constants.D_Q9UYh-.js';
6
+ import { R as ReportersMap } from './index.VNI-1z5c.js';
7
7
 
8
8
  function toArr(any) {
9
9
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -619,7 +619,7 @@ class CAC extends EventEmitter {
619
619
 
620
620
  const cac = (name = "") => new CAC(name);
621
621
 
622
- var version = "4.0.0-beta.4";
622
+ var version = "4.0.0-beta.6";
623
623
 
624
624
  const apiConfig = (port) => ({
625
625
  port: {
@@ -632,8 +632,7 @@ const apiConfig = (port) => ({
632
632
  },
633
633
  strictPort: { description: "Set to true to exit if port is already in use, instead of automatically trying the next available port" },
634
634
  middlewareMode: null
635
- });
636
- const poolThreadsCommands = {
635
+ }), poolThreadsCommands = {
637
636
  isolate: { description: "Isolate tests in threads pool (default: `true`)" },
638
637
  singleThread: { description: "Run tests inside a single thread (default: `false`)" },
639
638
  maxThreads: {
@@ -646,8 +645,7 @@ const poolThreadsCommands = {
646
645
  },
647
646
  useAtomics: { description: "Use Atomics to synchronize threads. This can improve performance in some cases, but might cause segfault in older Node versions (default: `false`)" },
648
647
  execArgv: null
649
- };
650
- const poolForksCommands = {
648
+ }, poolForksCommands = {
651
649
  isolate: { description: "Isolate tests in forks pool (default: `true`)" },
652
650
  singleFork: { description: "Run tests inside a single child_process (default: `false`)" },
653
651
  maxForks: {
@@ -661,12 +659,10 @@ const poolForksCommands = {
661
659
  execArgv: null
662
660
  };
663
661
  function watermarkTransform(value) {
664
- if (typeof value === "string") return value.split(",").map(Number);
665
- return value;
662
+ return typeof value === "string" ? value.split(",").map(Number) : value;
666
663
  }
667
664
  function transformNestedBoolean(value) {
668
- if (typeof value === "boolean") return { enabled: value };
669
- return value;
665
+ return typeof value === "boolean" ? { enabled: value } : value;
670
666
  }
671
667
  const cliOptionsConfig = {
672
668
  root: {
@@ -843,11 +839,7 @@ const cliOptionsConfig = {
843
839
  description: "Run tests in the browser. Equivalent to `--browser.enabled` (default: `false`)",
844
840
  argument: "<name>",
845
841
  transform(browser) {
846
- if (typeof browser === "boolean") return { enabled: browser };
847
- if (browser === "true" || browser === "false") return { enabled: browser === "true" };
848
- if (browser === "yes" || browser === "no") return { enabled: browser === "yes" };
849
- if (typeof browser === "string") return { name: browser };
850
- return browser;
842
+ return typeof browser === "boolean" ? { enabled: browser } : browser === "true" || browser === "false" ? { enabled: browser === "true" } : browser === "yes" || browser === "no" ? { enabled: browser === "yes" } : typeof browser === "string" ? { name: browser } : browser;
851
843
  },
852
844
  subcommands: {
853
845
  enabled: { description: "Run tests in the browser. Equivalent to `--browser.enabled` (default: `false`)" },
@@ -991,18 +983,14 @@ const cliOptionsConfig = {
991
983
  description: "Enable Node.js inspector (default: `127.0.0.1:9229`)",
992
984
  argument: "[[host:]port]",
993
985
  transform(portOrEnabled) {
994
- if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes") return true;
995
- if (portOrEnabled === "false" || portOrEnabled === "no") return false;
996
- return portOrEnabled;
986
+ return portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes" ? true : portOrEnabled === "false" || portOrEnabled === "no" ? false : portOrEnabled;
997
987
  }
998
988
  },
999
989
  inspectBrk: {
1000
990
  description: "Enable Node.js inspector and break before the test starts",
1001
991
  argument: "[[host:]port]",
1002
992
  transform(portOrEnabled) {
1003
- if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes") return true;
1004
- if (portOrEnabled === "false" || portOrEnabled === "no") return false;
1005
- return portOrEnabled;
993
+ return portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes" ? true : portOrEnabled === "false" || portOrEnabled === "no" ? false : portOrEnabled;
1006
994
  }
1007
995
  },
1008
996
  inspector: null,
@@ -1126,8 +1114,7 @@ const cliOptionsConfig = {
1126
1114
  default: true,
1127
1115
  transform(cache) {
1128
1116
  if (typeof cache !== "boolean" && cache) throw new Error("--cache.dir is deprecated");
1129
- if (cache) return {};
1130
- return cache;
1117
+ return cache && {};
1131
1118
  }
1132
1119
  },
1133
1120
  maxConcurrency: {
@@ -1184,8 +1171,7 @@ const cliOptionsConfig = {
1184
1171
  description: "Path to a blob reports directory. If this options is used, Vitest won't run any tests, it will only report previously recorded tests",
1185
1172
  argument: "[path]",
1186
1173
  transform(value) {
1187
- if (!value || typeof value === "boolean") return ".vitest-reports";
1188
- return value;
1174
+ return !value || typeof value === "boolean" ? ".vitest-reports" : value;
1189
1175
  }
1190
1176
  },
1191
1177
  cliExclude: null,
@@ -1208,7 +1194,6 @@ const cliOptionsConfig = {
1208
1194
  uiBase: null,
1209
1195
  benchmark: null,
1210
1196
  include: null,
1211
- testTransformMode: null,
1212
1197
  fakeTimers: null,
1213
1198
  chaiConfig: null,
1214
1199
  clearMocks: null,
@@ -1256,11 +1241,7 @@ function addCommand(cli, name, option) {
1256
1241
  const received = value.map((s) => typeof s === "string" ? `"${s}"` : s).join(", ");
1257
1242
  throw new Error(`Expected a single value for option "${command}", received [${received}]`);
1258
1243
  }
1259
- value = removeQuotes(value);
1260
- if (option.transform) return option.transform(value);
1261
- if (option.array) return toArray(value);
1262
- if (option.normalize) return normalize(String(value));
1263
- return value;
1244
+ return value = removeQuotes(value), option.transform ? option.transform(value) : option.array ? toArray(value) : option.normalize ? normalize(String(value)) : value;
1264
1245
  }
1265
1246
  const hasSubcommands = "subcommands" in option && option.subcommands;
1266
1247
  if (option.description) {
@@ -1278,24 +1259,16 @@ function addCliOptions(cli, options) {
1278
1259
  }
1279
1260
  function createCLI(options = {}) {
1280
1261
  const cli = cac("vitest");
1281
- cli.version(version);
1282
- addCliOptions(cli, cliOptionsConfig);
1283
- cli.help((info) => {
1262
+ return cli.version(version), addCliOptions(cli, cliOptionsConfig), cli.help((info) => {
1284
1263
  const helpSection = info.find((current) => current.title?.startsWith("For more info, run any command"));
1285
1264
  if (helpSection) helpSection.body += "\n $ vitest --help --expand-help";
1286
1265
  const options = info.find((current) => current.title === "Options");
1287
1266
  if (typeof options !== "object") return info;
1288
- const helpIndex = process.argv.findIndex((arg) => arg === "--help");
1289
- const subcommands = process.argv.slice(helpIndex + 1);
1290
- const defaultOutput = options.body.split("\n").filter((line) => /^\s+--\S+\./.test(line) === false).join("\n");
1267
+ const helpIndex = process.argv.findIndex((arg) => arg === "--help"), subcommands = process.argv.slice(helpIndex + 1), defaultOutput = options.body.split("\n").filter((line) => /^\s+--\S+\./.test(line) === false).join("\n");
1291
1268
  // Filter out options with dot-notation if --help is not called with a subcommand (default behavior)
1292
- if (subcommands.length === 0) {
1293
- options.body = defaultOutput;
1294
- return info;
1295
- }
1269
+ if (subcommands.length === 0) return options.body = defaultOutput, info;
1296
1270
  if (subcommands.length === 1 && (subcommands[0] === "--expand-help" || subcommands[0] === "--expandHelp")) return info;
1297
- const subcommandMarker = "$SUB_COMMAND_MARKER$";
1298
- const banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
1271
+ const subcommandMarker = "$SUB_COMMAND_MARKER$", banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
1299
1272
  function addBannerWarning(warning) {
1300
1273
  if (typeof banner?.body === "string") {
1301
1274
  if (banner?.body.includes(warning)) return;
@@ -1313,82 +1286,46 @@ function createCLI(options = {}) {
1313
1286
  // Mark the help section for the subcommands
1314
1287
  if (subcommand.startsWith("--")) options.body = options.body.split("\n").map((line) => line.trim().startsWith(subcommand) ? `${subcommandMarker}${line}` : line).join("\n");
1315
1288
  }
1316
- // Filter based on the marked options to preserve the original sort order
1317
- options.body = options.body.split("\n").map((line) => line.startsWith(subcommandMarker) ? line.split(subcommandMarker)[1] : "").filter((line) => line.length !== 0).join("\n");
1318
- if (!options.body) {
1319
- addBannerWarning("no options were found for your subcommands so we printed the whole output");
1320
- options.body = defaultOutput;
1321
- }
1289
+ if (options.body = options.body.split("\n").map((line) => line.startsWith(subcommandMarker) ? line.split(subcommandMarker)[1] : "").filter((line) => line.length !== 0).join("\n"), !options.body) addBannerWarning("no options were found for your subcommands so we printed the whole output"), options.body = defaultOutput;
1322
1290
  return info;
1323
- });
1324
- cli.command("run [...filters]", void 0, options).action(run);
1325
- cli.command("related [...filters]", void 0, options).action(runRelated);
1326
- cli.command("watch [...filters]", void 0, options).action(watch);
1327
- cli.command("dev [...filters]", void 0, options).action(watch);
1328
- addCliOptions(cli.command("bench [...filters]", void 0, options).action(benchmark), benchCliOptionsConfig);
1329
- cli.command("init <project>", void 0, options).action(init);
1330
- addCliOptions(cli.command("list [...filters]", void 0, options).action((filters, options) => collect("test", filters, options)), collectCliOptionsConfig);
1331
- cli.command("[...filters]", void 0, options).action((filters, options) => start("test", filters, options));
1332
- return cli;
1291
+ }), cli.command("run [...filters]", void 0, options).action(run), cli.command("related [...filters]", void 0, options).action(runRelated), cli.command("watch [...filters]", void 0, options).action(watch), cli.command("dev [...filters]", void 0, options).action(watch), addCliOptions(cli.command("bench [...filters]", void 0, options).action(benchmark), benchCliOptionsConfig), cli.command("init <project>", void 0, options).action(init), addCliOptions(cli.command("list [...filters]", void 0, options).action((filters, options) => collect("test", filters, options)), collectCliOptionsConfig), cli.command("[...filters]", void 0, options).action((filters, options) => start("test", filters, options)), cli;
1333
1292
  }
1334
1293
  function removeQuotes(str) {
1335
- if (typeof str !== "string") {
1336
- if (Array.isArray(str)) return str.map(removeQuotes);
1337
- return str;
1338
- }
1339
- if (str.startsWith("\"") && str.endsWith("\"")) return str.slice(1, -1);
1340
- if (str.startsWith(`'`) && str.endsWith(`'`)) return str.slice(1, -1);
1341
- return str;
1294
+ return typeof str === "string" ? str.startsWith("\"") && str.endsWith("\"") || str.startsWith(`'`) && str.endsWith(`'`) ? str.slice(1, -1) : str : Array.isArray(str) ? str.map(removeQuotes) : str;
1342
1295
  }
1343
1296
  function splitArgv(argv) {
1344
1297
  const reg = /(['"])(?:(?!\1).)+\1/g;
1345
- argv = argv.replace(reg, (match) => match.replace(/\s/g, "\0"));
1346
- return argv.split(" ").map((arg) => {
1347
- arg = arg.replace(/\0/g, " ");
1348
- return removeQuotes(arg);
1298
+ return argv = argv.replace(reg, (match) => match.replace(/\s/g, "\0")), argv.split(" ").map((arg) => {
1299
+ return arg = arg.replace(/\0/g, " "), removeQuotes(arg);
1349
1300
  });
1350
1301
  }
1351
1302
  function parseCLI(argv, config = {}) {
1352
1303
  const arrayArgs = typeof argv === "string" ? splitArgv(argv) : argv;
1353
1304
  if (arrayArgs[0] !== "vitest") throw new Error(`Expected "vitest" as the first argument, received "${arrayArgs[0]}"`);
1354
- arrayArgs[0] = "/index.js";
1355
- arrayArgs.unshift("node");
1305
+ arrayArgs[0] = "/index.js", arrayArgs.unshift("node");
1356
1306
  let { args, options } = createCLI(config).parse(arrayArgs, { run: false });
1357
1307
  if (arrayArgs[2] === "watch" || arrayArgs[2] === "dev") options.watch = true;
1358
1308
  if (arrayArgs[2] === "run" && !options.watch) options.run = true;
1359
- if (arrayArgs[2] === "related") {
1360
- options.related = args;
1361
- options.passWithNoTests ??= true;
1362
- args = [];
1363
- }
1309
+ if (arrayArgs[2] === "related") options.related = args, options.passWithNoTests ??= true, args = [];
1364
1310
  return {
1365
1311
  filter: args,
1366
1312
  options
1367
1313
  };
1368
1314
  }
1369
1315
  async function runRelated(relatedFiles, argv) {
1370
- argv.related = relatedFiles;
1371
- argv.passWithNoTests ??= true;
1372
- await start("test", [], argv);
1316
+ argv.related = relatedFiles, argv.passWithNoTests ??= true, await start("test", [], argv);
1373
1317
  }
1374
1318
  async function watch(cliFilters, options) {
1375
- options.watch = true;
1376
- await start("test", cliFilters, options);
1319
+ options.watch = true, await start("test", cliFilters, options);
1377
1320
  }
1378
1321
  async function run(cliFilters, options) {
1379
- // "vitest run --watch" should still be watch mode
1380
- options.run = !options.watch;
1381
- await start("test", cliFilters, options);
1322
+ options.run = !options.watch, await start("test", cliFilters, options);
1382
1323
  }
1383
1324
  async function benchmark(cliFilters, options) {
1384
- console.warn(c.yellow("Benchmarking is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it."));
1385
- await start("benchmark", cliFilters, options);
1325
+ console.warn(c.yellow("Benchmarking is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it.")), await start("benchmark", cliFilters, options);
1386
1326
  }
1387
1327
  function normalizeCliOptions(cliFilters, argv) {
1388
- if (argv.exclude) {
1389
- argv.cliExclude = toArray(argv.exclude);
1390
- delete argv.exclude;
1391
- }
1328
+ if (argv.exclude) argv.cliExclude = toArray(argv.exclude), delete argv.exclude;
1392
1329
  if (cliFilters.some((filter) => filter.includes(":"))) argv.includeTaskLocation ??= true;
1393
1330
  if (typeof argv.typecheck?.only === "boolean") argv.typecheck.enabled ??= true;
1394
1331
  return argv;
@@ -1398,24 +1335,17 @@ async function start(mode, cliFilters, options) {
1398
1335
  process.title = "node (vitest)";
1399
1336
  } catch {}
1400
1337
  try {
1401
- const { startVitest } = await import('./cli-api.B8xRY9Zt.js').then(function (n) { return n.f; });
1402
- const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1338
+ const { startVitest } = await import('./cli-api.CZz3evYC.js').then(function (n) { return n.f; }), ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1403
1339
  if (!ctx.shouldKeepServer()) await ctx.exit();
1404
1340
  } catch (e) {
1405
- const { errorBanner } = await import('./index.Bz6b0Ib7.js').then(function (n) { return n.u; });
1406
- console.error(`\n${errorBanner("Startup Error")}`);
1407
- console.error(e);
1408
- console.error("\n\n");
1409
- if (process.exitCode == null) process.exitCode = 1;
1341
+ const { errorBanner } = await import('./index.VNI-1z5c.js').then(function (n) { return n.u; });
1342
+ if (console.error(`\n${errorBanner("Startup Error")}`), console.error(e), console.error("\n\n"), process.exitCode == null) process.exitCode = 1;
1410
1343
  process.exit();
1411
1344
  }
1412
1345
  }
1413
1346
  async function init(project) {
1414
- if (project !== "browser") {
1415
- console.error(/* @__PURE__ */ new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project."));
1416
- process.exit(1);
1417
- }
1418
- const { create } = await import('./creator.yfA2ExGt.js');
1347
+ if (project !== "browser") console.error(/* @__PURE__ */ new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project.")), process.exit(1);
1348
+ const { create } = await import('./creator.KEg6n5IC.js');
1419
1349
  await create();
1420
1350
  }
1421
1351
  async function collect(mode, cliFilters, options) {
@@ -1423,8 +1353,7 @@ async function collect(mode, cliFilters, options) {
1423
1353
  process.title = "node (vitest)";
1424
1354
  } catch {}
1425
1355
  try {
1426
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.B8xRY9Zt.js').then(function (n) { return n.f; });
1427
- const ctx = await prepareVitest(mode, {
1356
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.CZz3evYC.js').then(function (n) { return n.f; }), ctx = await prepareVitest(mode, {
1428
1357
  ...normalizeCliOptions(cliFilters, options),
1429
1358
  watch: false,
1430
1359
  run: true
@@ -1432,10 +1361,7 @@ async function collect(mode, cliFilters, options) {
1432
1361
  if (!options.filesOnly) {
1433
1362
  const { testModules: tests, unhandledErrors: errors } = await ctx.collect(cliFilters.map(normalize));
1434
1363
  if (errors.length) {
1435
- console.error("\nThere were unhandled errors during test collection");
1436
- errors.forEach((e) => console.error(e));
1437
- console.error("\n\n");
1438
- await ctx.close();
1364
+ console.error("\nThere were unhandled errors during test collection"), errors.forEach((e) => console.error(e)), console.error("\n\n"), await ctx.close();
1439
1365
  return;
1440
1366
  }
1441
1367
  processCollected(ctx, tests, options);
@@ -1445,11 +1371,8 @@ async function collect(mode, cliFilters, options) {
1445
1371
  }
1446
1372
  await ctx.close();
1447
1373
  } catch (e) {
1448
- const { errorBanner } = await import('./index.Bz6b0Ib7.js').then(function (n) { return n.u; });
1449
- console.error(`\n${errorBanner("Collect Error")}`);
1450
- console.error(e);
1451
- console.error("\n\n");
1452
- if (process.exitCode == null) process.exitCode = 1;
1374
+ const { errorBanner } = await import('./index.VNI-1z5c.js').then(function (n) { return n.u; });
1375
+ if (console.error(`\n${errorBanner("Collect Error")}`), console.error(e), console.error("\n\n"), process.exitCode == null) process.exitCode = 1;
1453
1376
  process.exit();
1454
1377
  }
1455
1378
  }