vitest 4.0.0-beta.5 → 4.0.0-beta.7

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 (64) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/browser.d.ts +3 -3
  3. package/dist/browser.js +2 -2
  4. package/dist/chunks/{base.DMfOuRWD.js → base.BXI97p6t.js} +7 -16
  5. package/dist/chunks/{benchmark.CtuRzf-i.js → benchmark.UW6Ezvxy.js} +4 -9
  6. package/dist/chunks/{browser.d.Cawq_X_N.d.ts → browser.d.DOMmqJQx.d.ts} +1 -1
  7. package/dist/chunks/{cac.CKnbxhn2.js → cac.Dsn7ixFt.js} +38 -113
  8. package/dist/chunks/{cli-api.COn58yrl.js → cli-api.DfGJyldU.js} +829 -1232
  9. package/dist/chunks/{config.d.CKNVOKm0.d.ts → config.d._GBBbReY.d.ts} +1 -0
  10. package/dist/chunks/{console.Duv2dVIC.js → console.B0quX7yH.js} +32 -68
  11. package/dist/chunks/{coverage.B6cReEn1.js → coverage.Dvxug1RM.js} +210 -579
  12. package/dist/chunks/{creator.DUVZ6rfm.js → creator.KEg6n5IC.js} +28 -74
  13. package/dist/chunks/{date.Bq6ZW5rf.js → date.-jtEtIeV.js} +6 -17
  14. package/dist/chunks/{git.BVQ8w_Sw.js → git.BFNcloKD.js} +1 -2
  15. package/dist/chunks/{globals.CJQ63oO0.js → globals.lgsmH00r.js} +5 -5
  16. package/dist/chunks/{index.QZr3S3vQ.js → index.AR8aAkCC.js} +2 -2
  17. package/dist/chunks/{index.DQhAfQQU.js → index.C3EbxYwt.js} +276 -607
  18. package/dist/chunks/{index.oWRWx-nj.js → index.CsFXYRkW.js} +17 -36
  19. package/dist/chunks/{index.DgN0Zk9a.js → index.D2B6d2vv.js} +14 -24
  20. package/dist/chunks/{index.BRtIe7r8.js → index.DfviD7lX.js} +55 -110
  21. package/dist/chunks/{inspector.C914Efll.js → inspector.CvQD-Nie.js} +10 -25
  22. package/dist/chunks/{moduleRunner.d.mmOmOGrW.d.ts → moduleRunner.d.CX4DuqOx.d.ts} +2 -2
  23. package/dist/chunks/{node.4JV5OXkt.js → node.BOqcT2jW.js} +1 -1
  24. package/dist/chunks/{plugin.d.CvOlgjxK.d.ts → plugin.d.vcD4xbMS.d.ts} +1 -1
  25. package/dist/chunks/{reporters.d.CYE9sT5z.d.ts → reporters.d.BC86JJdB.d.ts} +799 -758
  26. package/dist/chunks/{resolver.D5bG4zy5.js → resolver.Bx6lE0iq.js} +21 -64
  27. package/dist/chunks/{rpc.DGoW_Vl-.js → rpc.RpPylpp0.js} +7 -21
  28. package/dist/chunks/{runBaseTests.B3KcKqlF.js → runBaseTests.D6sfuWBM.js} +25 -54
  29. package/dist/chunks/{setup-common.lgPs-bYv.js → setup-common.hLGRxhC8.js} +9 -22
  30. package/dist/chunks/{startModuleRunner.C8FtT_BY.js → startModuleRunner.C8TW8zTN.js} +83 -205
  31. package/dist/chunks/{typechecker.BgoW4nTA.js → typechecker.DSo_maXz.js} +97 -209
  32. package/dist/chunks/{utils.CcGm2cd1.js → utils.C2YI6McM.js} +4 -13
  33. package/dist/chunks/{utils.B9FY3b73.js → utils.C7__0Iv5.js} +5 -14
  34. package/dist/chunks/{vi.DGAfBY4R.js → vi.BfdOiD4j.js} +110 -267
  35. package/dist/chunks/{vm.BKfKvaKl.js → vm.BHBje7cC.js} +73 -177
  36. package/dist/chunks/{worker.d.Db-UVmXc.d.ts → worker.d.BKu8cnnX.d.ts} +1 -1
  37. package/dist/chunks/{worker.d.D9QWnzAe.d.ts → worker.d.DYlqbejz.d.ts} +1 -1
  38. package/dist/cli.js +3 -3
  39. package/dist/config.d.ts +7 -7
  40. package/dist/coverage.d.ts +4 -4
  41. package/dist/coverage.js +2 -2
  42. package/dist/environments.js +1 -1
  43. package/dist/index.d.ts +6 -6
  44. package/dist/index.js +5 -5
  45. package/dist/module-evaluator.d.ts +3 -3
  46. package/dist/module-evaluator.js +33 -84
  47. package/dist/module-runner.js +2 -2
  48. package/dist/node.d.ts +11 -9
  49. package/dist/node.js +16 -27
  50. package/dist/reporters.d.ts +5 -5
  51. package/dist/reporters.js +3 -3
  52. package/dist/runners.d.ts +1 -1
  53. package/dist/runners.js +23 -51
  54. package/dist/snapshot.js +2 -2
  55. package/dist/suite.js +2 -2
  56. package/dist/worker.js +18 -34
  57. package/dist/workers/forks.js +4 -4
  58. package/dist/workers/runVmTests.js +19 -37
  59. package/dist/workers/threads.js +4 -4
  60. package/dist/workers/vmForks.js +7 -7
  61. package/dist/workers/vmThreads.js +7 -7
  62. package/dist/workers.d.ts +3 -3
  63. package/dist/workers.js +11 -11
  64. package/package.json +11 -11
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.CKNVOKm0.js';
1
+ import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d._GBBbReY.js';
2
2
  import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.BZtK59WP.js';
3
3
  import { SerializedDiffOptions } from '@vitest/utils/diff';
4
- import { V as VitestModuleRunner } from './chunks/moduleRunner.d.mmOmOGrW.js';
4
+ import { V as VitestModuleRunner } from './chunks/moduleRunner.d.CX4DuqOx.js';
5
5
  export { collectTests, processError, startTests } from '@vitest/runner';
6
6
  import * as spy from '@vitest/spy';
7
7
  export { spy as SpyModule };
@@ -11,7 +11,7 @@ import '@vitest/pretty-format';
11
11
  import '@vitest/snapshot';
12
12
  import 'node:vm';
13
13
  import 'vite/module-runner';
14
- import './chunks/worker.d.D9QWnzAe.js';
14
+ import './chunks/worker.d.DYlqbejz.js';
15
15
  import './chunks/environment.d.2fYMoz3o.js';
16
16
  import '@vitest/mocker';
17
17
  import './chunks/mocker.d.BE_2ls6u.js';
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.lgPs-bYv.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 };
@@ -6,4 +6,4 @@ export { format, getSafeTimers, inspect, stringify } from '@vitest/utils';
6
6
  export { TraceMap, originalPositionFor } from '@vitest/utils/source-map';
7
7
  import './chunks/coverage.D_JHT54q.js';
8
8
  import '@vitest/snapshot';
9
- import './chunks/utils.B9FY3b73.js';
9
+ import './chunks/utils.C7__0Iv5.js';
@@ -1,22 +1,15 @@
1
1
  import { EvaluatedModules } from 'vite/module-runner';
2
- import { s as startVitestModuleRunner } from './startModuleRunner.C8FtT_BY.js';
3
- import { p as provideWorkerState } from './utils.B9FY3b73.js';
2
+ import { s as startVitestModuleRunner } from './startModuleRunner.C8TW8zTN.js';
3
+ import { p as provideWorkerState } from './utils.C7__0Iv5.js';
4
4
 
5
5
  let _moduleRunner;
6
- const evaluatedModules = new EvaluatedModules();
7
- const moduleExecutionInfo = /* @__PURE__ */ new Map();
6
+ const evaluatedModules = new EvaluatedModules(), moduleExecutionInfo = /* @__PURE__ */ new Map();
8
7
  async function startModuleRunner(options) {
9
- if (_moduleRunner) return _moduleRunner;
10
- _moduleRunner = await startVitestModuleRunner(options);
11
- return _moduleRunner;
8
+ return _moduleRunner || (_moduleRunner = await startVitestModuleRunner(options), _moduleRunner);
12
9
  }
13
10
  async function runBaseTests(method, state) {
14
11
  const { ctx } = state;
15
- // state has new context, but we want to reuse existing ones
16
- state.evaluatedModules = evaluatedModules;
17
- state.moduleExecutionInfo = moduleExecutionInfo;
18
- provideWorkerState(globalThis, state);
19
- if (ctx.invalidates) ctx.invalidates.forEach((filepath) => {
12
+ if (state.evaluatedModules = evaluatedModules, state.moduleExecutionInfo = moduleExecutionInfo, provideWorkerState(globalThis, state), ctx.invalidates) ctx.invalidates.forEach((filepath) => {
20
13
  const modules = state.evaluatedModules.fileToModulesMap.get(filepath) || [];
21
14
  modules.forEach((module) => {
22
15
  state.evaluatedModules.invalidateModule(module);
@@ -25,8 +18,7 @@ async function runBaseTests(method, state) {
25
18
  // evaluatedModules.delete(`mock:${fsPath}`)
26
19
  });
27
20
  ctx.files.forEach((i) => {
28
- const filepath = typeof i === "string" ? i : i.filepath;
29
- const modules = state.evaluatedModules.fileToModulesMap.get(filepath) || [];
21
+ const filepath = typeof i === "string" ? i : i.filepath, modules = state.evaluatedModules.fileToModulesMap.get(filepath) || [];
30
22
  modules.forEach((module) => {
31
23
  state.evaluatedModules.invalidateModule(module);
32
24
  });
@@ -34,8 +26,7 @@ async function runBaseTests(method, state) {
34
26
  const [executor, { run }] = await Promise.all([startModuleRunner({
35
27
  state,
36
28
  evaluatedModules: state.evaluatedModules
37
- }), import('./runBaseTests.B3KcKqlF.js')]);
38
- const fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
29
+ }), import('./runBaseTests.D6sfuWBM.js')]), fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
39
30
  filepath: f,
40
31
  testLocations: void 0
41
32
  } : f);
@@ -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.B9FY3b73.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,11 +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);
22
19
  // vitest runner sets mode to `todo` if handler is not passed down
23
20
  // but we store handler separetly
24
- if (!this.todo && task.mode === "todo") task.mode = "run";
21
+ if (benchFns.set(task, fn), benchOptsMap.set(task, options), !this.todo && task.mode === "todo") task.mode = "run";
25
22
  });
26
23
  function createBenchmark(fn) {
27
24
  const benchmark = createChainable([
@@ -29,9 +26,7 @@ function createBenchmark(fn) {
29
26
  "only",
30
27
  "todo"
31
28
  ], fn);
32
- benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark;
33
- benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip;
34
- return benchmark;
29
+ return benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark, benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip, benchmark;
35
30
  }
36
31
  function formatName(name) {
37
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.D9QWnzAe.js';
1
+ import { T as TestExecutionMethod } from './worker.d.DYlqbejz.js';
2
2
 
3
3
  type SerializedTestSpecification = [project: {
4
4
  name: string | undefined;
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
3
3
  import { normalize } from 'pathe';
4
4
  import c from 'tinyrainbow';
5
5
  import { a as defaultPort, d as defaultBrowserPort } from './constants.D_Q9UYh-.js';
6
- import { R as ReportersMap } from './index.DQhAfQQU.js';
6
+ import { R as ReportersMap } from './index.C3EbxYwt.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.5";
622
+ var version = "4.0.0-beta.7";
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`)" },
@@ -878,6 +870,7 @@ const cliOptionsConfig = {
878
870
  description: "If connection to the browser takes longer, the test suite will fail (default: `60_000`)",
879
871
  argument: "<timeout>"
880
872
  },
873
+ trackUnhandledErrors: { description: "Control if Vitest catches uncaught exceptions so they can be reported (default: `true`)" },
881
874
  orchestratorScripts: null,
882
875
  testerScripts: null,
883
876
  commands: null,
@@ -991,18 +984,14 @@ const cliOptionsConfig = {
991
984
  description: "Enable Node.js inspector (default: `127.0.0.1:9229`)",
992
985
  argument: "[[host:]port]",
993
986
  transform(portOrEnabled) {
994
- if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes") return true;
995
- if (portOrEnabled === "false" || portOrEnabled === "no") return false;
996
- return portOrEnabled;
987
+ return portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes" ? true : portOrEnabled === "false" || portOrEnabled === "no" ? false : portOrEnabled;
997
988
  }
998
989
  },
999
990
  inspectBrk: {
1000
991
  description: "Enable Node.js inspector and break before the test starts",
1001
992
  argument: "[[host:]port]",
1002
993
  transform(portOrEnabled) {
1003
- if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes") return true;
1004
- if (portOrEnabled === "false" || portOrEnabled === "no") return false;
1005
- return portOrEnabled;
994
+ return portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes" ? true : portOrEnabled === "false" || portOrEnabled === "no" ? false : portOrEnabled;
1006
995
  }
1007
996
  },
1008
997
  inspector: null,
@@ -1126,8 +1115,7 @@ const cliOptionsConfig = {
1126
1115
  default: true,
1127
1116
  transform(cache) {
1128
1117
  if (typeof cache !== "boolean" && cache) throw new Error("--cache.dir is deprecated");
1129
- if (cache) return {};
1130
- return cache;
1118
+ return cache && {};
1131
1119
  }
1132
1120
  },
1133
1121
  maxConcurrency: {
@@ -1184,8 +1172,7 @@ const cliOptionsConfig = {
1184
1172
  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
1173
  argument: "[path]",
1186
1174
  transform(value) {
1187
- if (!value || typeof value === "boolean") return ".vitest-reports";
1188
- return value;
1175
+ return !value || typeof value === "boolean" ? ".vitest-reports" : value;
1189
1176
  }
1190
1177
  },
1191
1178
  cliExclude: null,
@@ -1255,11 +1242,7 @@ function addCommand(cli, name, option) {
1255
1242
  const received = value.map((s) => typeof s === "string" ? `"${s}"` : s).join(", ");
1256
1243
  throw new Error(`Expected a single value for option "${command}", received [${received}]`);
1257
1244
  }
1258
- value = removeQuotes(value);
1259
- if (option.transform) return option.transform(value);
1260
- if (option.array) return toArray(value);
1261
- if (option.normalize) return normalize(String(value));
1262
- return value;
1245
+ return value = removeQuotes(value), option.transform ? option.transform(value) : option.array ? toArray(value) : option.normalize ? normalize(String(value)) : value;
1263
1246
  }
1264
1247
  const hasSubcommands = "subcommands" in option && option.subcommands;
1265
1248
  if (option.description) {
@@ -1277,24 +1260,16 @@ function addCliOptions(cli, options) {
1277
1260
  }
1278
1261
  function createCLI(options = {}) {
1279
1262
  const cli = cac("vitest");
1280
- cli.version(version);
1281
- addCliOptions(cli, cliOptionsConfig);
1282
- cli.help((info) => {
1263
+ return cli.version(version), addCliOptions(cli, cliOptionsConfig), cli.help((info) => {
1283
1264
  const helpSection = info.find((current) => current.title?.startsWith("For more info, run any command"));
1284
1265
  if (helpSection) helpSection.body += "\n $ vitest --help --expand-help";
1285
1266
  const options = info.find((current) => current.title === "Options");
1286
1267
  if (typeof options !== "object") return info;
1287
- const helpIndex = process.argv.findIndex((arg) => arg === "--help");
1288
- const subcommands = process.argv.slice(helpIndex + 1);
1289
- const defaultOutput = options.body.split("\n").filter((line) => /^\s+--\S+\./.test(line) === false).join("\n");
1268
+ 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");
1290
1269
  // Filter out options with dot-notation if --help is not called with a subcommand (default behavior)
1291
- if (subcommands.length === 0) {
1292
- options.body = defaultOutput;
1293
- return info;
1294
- }
1270
+ if (subcommands.length === 0) return options.body = defaultOutput, info;
1295
1271
  if (subcommands.length === 1 && (subcommands[0] === "--expand-help" || subcommands[0] === "--expandHelp")) return info;
1296
- const subcommandMarker = "$SUB_COMMAND_MARKER$";
1297
- const banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
1272
+ const subcommandMarker = "$SUB_COMMAND_MARKER$", banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
1298
1273
  function addBannerWarning(warning) {
1299
1274
  if (typeof banner?.body === "string") {
1300
1275
  if (banner?.body.includes(warning)) return;
@@ -1312,82 +1287,46 @@ function createCLI(options = {}) {
1312
1287
  // Mark the help section for the subcommands
1313
1288
  if (subcommand.startsWith("--")) options.body = options.body.split("\n").map((line) => line.trim().startsWith(subcommand) ? `${subcommandMarker}${line}` : line).join("\n");
1314
1289
  }
1315
- // Filter based on the marked options to preserve the original sort order
1316
- options.body = options.body.split("\n").map((line) => line.startsWith(subcommandMarker) ? line.split(subcommandMarker)[1] : "").filter((line) => line.length !== 0).join("\n");
1317
- if (!options.body) {
1318
- addBannerWarning("no options were found for your subcommands so we printed the whole output");
1319
- options.body = defaultOutput;
1320
- }
1290
+ 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;
1321
1291
  return info;
1322
- });
1323
- cli.command("run [...filters]", void 0, options).action(run);
1324
- cli.command("related [...filters]", void 0, options).action(runRelated);
1325
- cli.command("watch [...filters]", void 0, options).action(watch);
1326
- cli.command("dev [...filters]", void 0, options).action(watch);
1327
- addCliOptions(cli.command("bench [...filters]", void 0, options).action(benchmark), benchCliOptionsConfig);
1328
- cli.command("init <project>", void 0, options).action(init);
1329
- addCliOptions(cli.command("list [...filters]", void 0, options).action((filters, options) => collect("test", filters, options)), collectCliOptionsConfig);
1330
- cli.command("[...filters]", void 0, options).action((filters, options) => start("test", filters, options));
1331
- return cli;
1292
+ }), 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;
1332
1293
  }
1333
1294
  function removeQuotes(str) {
1334
- if (typeof str !== "string") {
1335
- if (Array.isArray(str)) return str.map(removeQuotes);
1336
- return str;
1337
- }
1338
- if (str.startsWith("\"") && str.endsWith("\"")) return str.slice(1, -1);
1339
- if (str.startsWith(`'`) && str.endsWith(`'`)) return str.slice(1, -1);
1340
- return str;
1295
+ return typeof str === "string" ? str.startsWith("\"") && str.endsWith("\"") || str.startsWith(`'`) && str.endsWith(`'`) ? str.slice(1, -1) : str : Array.isArray(str) ? str.map(removeQuotes) : str;
1341
1296
  }
1342
1297
  function splitArgv(argv) {
1343
1298
  const reg = /(['"])(?:(?!\1).)+\1/g;
1344
- argv = argv.replace(reg, (match) => match.replace(/\s/g, "\0"));
1345
- return argv.split(" ").map((arg) => {
1346
- arg = arg.replace(/\0/g, " ");
1347
- return removeQuotes(arg);
1299
+ return argv = argv.replace(reg, (match) => match.replace(/\s/g, "\0")), argv.split(" ").map((arg) => {
1300
+ return arg = arg.replace(/\0/g, " "), removeQuotes(arg);
1348
1301
  });
1349
1302
  }
1350
1303
  function parseCLI(argv, config = {}) {
1351
1304
  const arrayArgs = typeof argv === "string" ? splitArgv(argv) : argv;
1352
1305
  if (arrayArgs[0] !== "vitest") throw new Error(`Expected "vitest" as the first argument, received "${arrayArgs[0]}"`);
1353
- arrayArgs[0] = "/index.js";
1354
- arrayArgs.unshift("node");
1306
+ arrayArgs[0] = "/index.js", arrayArgs.unshift("node");
1355
1307
  let { args, options } = createCLI(config).parse(arrayArgs, { run: false });
1356
1308
  if (arrayArgs[2] === "watch" || arrayArgs[2] === "dev") options.watch = true;
1357
1309
  if (arrayArgs[2] === "run" && !options.watch) options.run = true;
1358
- if (arrayArgs[2] === "related") {
1359
- options.related = args;
1360
- options.passWithNoTests ??= true;
1361
- args = [];
1362
- }
1310
+ if (arrayArgs[2] === "related") options.related = args, options.passWithNoTests ??= true, args = [];
1363
1311
  return {
1364
1312
  filter: args,
1365
1313
  options
1366
1314
  };
1367
1315
  }
1368
1316
  async function runRelated(relatedFiles, argv) {
1369
- argv.related = relatedFiles;
1370
- argv.passWithNoTests ??= true;
1371
- await start("test", [], argv);
1317
+ argv.related = relatedFiles, argv.passWithNoTests ??= true, await start("test", [], argv);
1372
1318
  }
1373
1319
  async function watch(cliFilters, options) {
1374
- options.watch = true;
1375
- await start("test", cliFilters, options);
1320
+ options.watch = true, await start("test", cliFilters, options);
1376
1321
  }
1377
1322
  async function run(cliFilters, options) {
1378
- // "vitest run --watch" should still be watch mode
1379
- options.run = !options.watch;
1380
- await start("test", cliFilters, options);
1323
+ options.run = !options.watch, await start("test", cliFilters, options);
1381
1324
  }
1382
1325
  async function benchmark(cliFilters, options) {
1383
- console.warn(c.yellow("Benchmarking is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it."));
1384
- await start("benchmark", cliFilters, options);
1326
+ 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);
1385
1327
  }
1386
1328
  function normalizeCliOptions(cliFilters, argv) {
1387
- if (argv.exclude) {
1388
- argv.cliExclude = toArray(argv.exclude);
1389
- delete argv.exclude;
1390
- }
1329
+ if (argv.exclude) argv.cliExclude = toArray(argv.exclude), delete argv.exclude;
1391
1330
  if (cliFilters.some((filter) => filter.includes(":"))) argv.includeTaskLocation ??= true;
1392
1331
  if (typeof argv.typecheck?.only === "boolean") argv.typecheck.enabled ??= true;
1393
1332
  return argv;
@@ -1397,24 +1336,17 @@ async function start(mode, cliFilters, options) {
1397
1336
  process.title = "node (vitest)";
1398
1337
  } catch {}
1399
1338
  try {
1400
- const { startVitest } = await import('./cli-api.COn58yrl.js').then(function (n) { return n.f; });
1401
- const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1339
+ const { startVitest } = await import('./cli-api.DfGJyldU.js').then(function (n) { return n.j; }), ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1402
1340
  if (!ctx.shouldKeepServer()) await ctx.exit();
1403
1341
  } catch (e) {
1404
- const { errorBanner } = await import('./index.DQhAfQQU.js').then(function (n) { return n.u; });
1405
- console.error(`\n${errorBanner("Startup Error")}`);
1406
- console.error(e);
1407
- console.error("\n\n");
1408
- if (process.exitCode == null) process.exitCode = 1;
1342
+ const { errorBanner } = await import('./index.C3EbxYwt.js').then(function (n) { return n.u; });
1343
+ if (console.error(`\n${errorBanner("Startup Error")}`), console.error(e), console.error("\n\n"), process.exitCode == null) process.exitCode = 1;
1409
1344
  process.exit();
1410
1345
  }
1411
1346
  }
1412
1347
  async function init(project) {
1413
- if (project !== "browser") {
1414
- console.error(/* @__PURE__ */ new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project."));
1415
- process.exit(1);
1416
- }
1417
- const { create } = await import('./creator.DUVZ6rfm.js');
1348
+ 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);
1349
+ const { create } = await import('./creator.KEg6n5IC.js');
1418
1350
  await create();
1419
1351
  }
1420
1352
  async function collect(mode, cliFilters, options) {
@@ -1422,8 +1354,7 @@ async function collect(mode, cliFilters, options) {
1422
1354
  process.title = "node (vitest)";
1423
1355
  } catch {}
1424
1356
  try {
1425
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.COn58yrl.js').then(function (n) { return n.f; });
1426
- const ctx = await prepareVitest(mode, {
1357
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.DfGJyldU.js').then(function (n) { return n.j; }), ctx = await prepareVitest(mode, {
1427
1358
  ...normalizeCliOptions(cliFilters, options),
1428
1359
  watch: false,
1429
1360
  run: true
@@ -1431,10 +1362,7 @@ async function collect(mode, cliFilters, options) {
1431
1362
  if (!options.filesOnly) {
1432
1363
  const { testModules: tests, unhandledErrors: errors } = await ctx.collect(cliFilters.map(normalize));
1433
1364
  if (errors.length) {
1434
- console.error("\nThere were unhandled errors during test collection");
1435
- errors.forEach((e) => console.error(e));
1436
- console.error("\n\n");
1437
- await ctx.close();
1365
+ console.error("\nThere were unhandled errors during test collection"), errors.forEach((e) => console.error(e)), console.error("\n\n"), await ctx.close();
1438
1366
  return;
1439
1367
  }
1440
1368
  processCollected(ctx, tests, options);
@@ -1444,11 +1372,8 @@ async function collect(mode, cliFilters, options) {
1444
1372
  }
1445
1373
  await ctx.close();
1446
1374
  } catch (e) {
1447
- const { errorBanner } = await import('./index.DQhAfQQU.js').then(function (n) { return n.u; });
1448
- console.error(`\n${errorBanner("Collect Error")}`);
1449
- console.error(e);
1450
- console.error("\n\n");
1451
- if (process.exitCode == null) process.exitCode = 1;
1375
+ const { errorBanner } = await import('./index.C3EbxYwt.js').then(function (n) { return n.u; });
1376
+ if (console.error(`\n${errorBanner("Collect Error")}`), console.error(e), console.error("\n\n"), process.exitCode == null) process.exitCode = 1;
1452
1377
  process.exit();
1453
1378
  }
1454
1379
  }