vitest 4.0.0-beta.5 → 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 (57) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/browser.d.ts +1 -1
  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/{cac.CKnbxhn2.js → cac.WE-urWw5.js} +37 -113
  7. package/dist/chunks/{cli-api.COn58yrl.js → cli-api.CZz3evYC.js} +505 -1211
  8. package/dist/chunks/{console.Duv2dVIC.js → console.B0quX7yH.js} +32 -68
  9. package/dist/chunks/{coverage.B6cReEn1.js → coverage.BPRS6xgn.js} +210 -579
  10. package/dist/chunks/{creator.DUVZ6rfm.js → creator.KEg6n5IC.js} +28 -74
  11. package/dist/chunks/{date.Bq6ZW5rf.js → date.-jtEtIeV.js} +6 -17
  12. package/dist/chunks/{git.BVQ8w_Sw.js → git.BFNcloKD.js} +1 -2
  13. package/dist/chunks/{globals.CJQ63oO0.js → globals.lgsmH00r.js} +5 -5
  14. package/dist/chunks/{index.DgN0Zk9a.js → index.7w0eqmYM.js} +14 -24
  15. package/dist/chunks/{index.QZr3S3vQ.js → index.AR8aAkCC.js} +2 -2
  16. package/dist/chunks/{index.BRtIe7r8.js → index.BG0gqZH-.js} +39 -102
  17. package/dist/chunks/{index.oWRWx-nj.js → index.CsFXYRkW.js} +17 -36
  18. package/dist/chunks/{index.DQhAfQQU.js → index.VNI-1z5c.js} +270 -606
  19. package/dist/chunks/{inspector.C914Efll.js → inspector.CvQD-Nie.js} +10 -25
  20. package/dist/chunks/{moduleRunner.d.mmOmOGrW.d.ts → moduleRunner.d.8kKUsuDg.d.ts} +1 -1
  21. package/dist/chunks/{node.4JV5OXkt.js → node.BOqcT2jW.js} +1 -1
  22. package/dist/chunks/{plugin.d.CvOlgjxK.d.ts → plugin.d.DuiQJfUL.d.ts} +1 -1
  23. package/dist/chunks/{reporters.d.CYE9sT5z.d.ts → reporters.d.CqR9-CDJ.d.ts} +16 -33
  24. package/dist/chunks/{resolver.D5bG4zy5.js → resolver.Bx6lE0iq.js} +21 -64
  25. package/dist/chunks/{rpc.DGoW_Vl-.js → rpc.RpPylpp0.js} +7 -21
  26. package/dist/chunks/{runBaseTests.B3KcKqlF.js → runBaseTests.D6sfuWBM.js} +25 -54
  27. package/dist/chunks/{setup-common.lgPs-bYv.js → setup-common.hLGRxhC8.js} +9 -22
  28. package/dist/chunks/{startModuleRunner.C8FtT_BY.js → startModuleRunner.C8TW8zTN.js} +83 -205
  29. package/dist/chunks/{typechecker.BgoW4nTA.js → typechecker.Cd1wvxUM.js} +96 -208
  30. package/dist/chunks/{utils.CcGm2cd1.js → utils.C2YI6McM.js} +4 -13
  31. package/dist/chunks/{utils.B9FY3b73.js → utils.C7__0Iv5.js} +5 -14
  32. package/dist/chunks/{vi.DGAfBY4R.js → vi.BfdOiD4j.js} +110 -267
  33. package/dist/chunks/{vm.BKfKvaKl.js → vm.BHBje7cC.js} +73 -177
  34. package/dist/cli.js +3 -3
  35. package/dist/config.d.ts +4 -4
  36. package/dist/coverage.d.ts +1 -1
  37. package/dist/coverage.js +2 -2
  38. package/dist/environments.js +1 -1
  39. package/dist/index.js +5 -5
  40. package/dist/module-evaluator.d.ts +1 -1
  41. package/dist/module-evaluator.js +33 -84
  42. package/dist/module-runner.js +2 -2
  43. package/dist/node.d.ts +3 -3
  44. package/dist/node.js +13 -19
  45. package/dist/reporters.d.ts +2 -2
  46. package/dist/reporters.js +3 -3
  47. package/dist/runners.js +23 -51
  48. package/dist/snapshot.js +2 -2
  49. package/dist/suite.js +2 -2
  50. package/dist/worker.js +18 -34
  51. package/dist/workers/forks.js +4 -4
  52. package/dist/workers/runVmTests.js +19 -37
  53. package/dist/workers/threads.js +4 -4
  54. package/dist/workers/vmForks.js +7 -7
  55. package/dist/workers/vmThreads.js +7 -7
  56. package/dist/workers.js +11 -11
  57. 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
1
  import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.CKNVOKm0.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.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 };
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);
@@ -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.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.5";
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,
@@ -1255,11 +1241,7 @@ function addCommand(cli, name, option) {
1255
1241
  const received = value.map((s) => typeof s === "string" ? `"${s}"` : s).join(", ");
1256
1242
  throw new Error(`Expected a single value for option "${command}", received [${received}]`);
1257
1243
  }
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;
1244
+ return value = removeQuotes(value), option.transform ? option.transform(value) : option.array ? toArray(value) : option.normalize ? normalize(String(value)) : value;
1263
1245
  }
1264
1246
  const hasSubcommands = "subcommands" in option && option.subcommands;
1265
1247
  if (option.description) {
@@ -1277,24 +1259,16 @@ function addCliOptions(cli, options) {
1277
1259
  }
1278
1260
  function createCLI(options = {}) {
1279
1261
  const cli = cac("vitest");
1280
- cli.version(version);
1281
- addCliOptions(cli, cliOptionsConfig);
1282
- cli.help((info) => {
1262
+ return cli.version(version), addCliOptions(cli, cliOptionsConfig), cli.help((info) => {
1283
1263
  const helpSection = info.find((current) => current.title?.startsWith("For more info, run any command"));
1284
1264
  if (helpSection) helpSection.body += "\n $ vitest --help --expand-help";
1285
1265
  const options = info.find((current) => current.title === "Options");
1286
1266
  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");
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");
1290
1268
  // 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
- }
1269
+ if (subcommands.length === 0) return options.body = defaultOutput, info;
1295
1270
  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));
1271
+ const subcommandMarker = "$SUB_COMMAND_MARKER$", banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
1298
1272
  function addBannerWarning(warning) {
1299
1273
  if (typeof banner?.body === "string") {
1300
1274
  if (banner?.body.includes(warning)) return;
@@ -1312,82 +1286,46 @@ function createCLI(options = {}) {
1312
1286
  // Mark the help section for the subcommands
1313
1287
  if (subcommand.startsWith("--")) options.body = options.body.split("\n").map((line) => line.trim().startsWith(subcommand) ? `${subcommandMarker}${line}` : line).join("\n");
1314
1288
  }
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
- }
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;
1321
1290
  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;
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;
1332
1292
  }
1333
1293
  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;
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;
1341
1295
  }
1342
1296
  function splitArgv(argv) {
1343
1297
  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);
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);
1348
1300
  });
1349
1301
  }
1350
1302
  function parseCLI(argv, config = {}) {
1351
1303
  const arrayArgs = typeof argv === "string" ? splitArgv(argv) : argv;
1352
1304
  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");
1305
+ arrayArgs[0] = "/index.js", arrayArgs.unshift("node");
1355
1306
  let { args, options } = createCLI(config).parse(arrayArgs, { run: false });
1356
1307
  if (arrayArgs[2] === "watch" || arrayArgs[2] === "dev") options.watch = true;
1357
1308
  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
- }
1309
+ if (arrayArgs[2] === "related") options.related = args, options.passWithNoTests ??= true, args = [];
1363
1310
  return {
1364
1311
  filter: args,
1365
1312
  options
1366
1313
  };
1367
1314
  }
1368
1315
  async function runRelated(relatedFiles, argv) {
1369
- argv.related = relatedFiles;
1370
- argv.passWithNoTests ??= true;
1371
- await start("test", [], argv);
1316
+ argv.related = relatedFiles, argv.passWithNoTests ??= true, await start("test", [], argv);
1372
1317
  }
1373
1318
  async function watch(cliFilters, options) {
1374
- options.watch = true;
1375
- await start("test", cliFilters, options);
1319
+ options.watch = true, await start("test", cliFilters, options);
1376
1320
  }
1377
1321
  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);
1322
+ options.run = !options.watch, await start("test", cliFilters, options);
1381
1323
  }
1382
1324
  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);
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);
1385
1326
  }
1386
1327
  function normalizeCliOptions(cliFilters, argv) {
1387
- if (argv.exclude) {
1388
- argv.cliExclude = toArray(argv.exclude);
1389
- delete argv.exclude;
1390
- }
1328
+ if (argv.exclude) argv.cliExclude = toArray(argv.exclude), delete argv.exclude;
1391
1329
  if (cliFilters.some((filter) => filter.includes(":"))) argv.includeTaskLocation ??= true;
1392
1330
  if (typeof argv.typecheck?.only === "boolean") argv.typecheck.enabled ??= true;
1393
1331
  return argv;
@@ -1397,24 +1335,17 @@ async function start(mode, cliFilters, options) {
1397
1335
  process.title = "node (vitest)";
1398
1336
  } catch {}
1399
1337
  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));
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));
1402
1339
  if (!ctx.shouldKeepServer()) await ctx.exit();
1403
1340
  } 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;
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;
1409
1343
  process.exit();
1410
1344
  }
1411
1345
  }
1412
1346
  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');
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');
1418
1349
  await create();
1419
1350
  }
1420
1351
  async function collect(mode, cliFilters, options) {
@@ -1422,8 +1353,7 @@ async function collect(mode, cliFilters, options) {
1422
1353
  process.title = "node (vitest)";
1423
1354
  } catch {}
1424
1355
  try {
1425
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.COn58yrl.js').then(function (n) { return n.f; });
1426
- 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, {
1427
1357
  ...normalizeCliOptions(cliFilters, options),
1428
1358
  watch: false,
1429
1359
  run: true
@@ -1431,10 +1361,7 @@ async function collect(mode, cliFilters, options) {
1431
1361
  if (!options.filesOnly) {
1432
1362
  const { testModules: tests, unhandledErrors: errors } = await ctx.collect(cliFilters.map(normalize));
1433
1363
  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();
1364
+ console.error("\nThere were unhandled errors during test collection"), errors.forEach((e) => console.error(e)), console.error("\n\n"), await ctx.close();
1438
1365
  return;
1439
1366
  }
1440
1367
  processCollected(ctx, tests, options);
@@ -1444,11 +1371,8 @@ async function collect(mode, cliFilters, options) {
1444
1371
  }
1445
1372
  await ctx.close();
1446
1373
  } 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;
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;
1452
1376
  process.exit();
1453
1377
  }
1454
1378
  }