vitest 3.2.4 → 4.0.0-beta.10

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 (88) hide show
  1. package/LICENSE.md +2 -2
  2. package/dist/browser.d.ts +13 -16
  3. package/dist/browser.js +6 -5
  4. package/dist/chunks/base.Cjha6usc.js +129 -0
  5. package/dist/chunks/{benchmark.CYdenmiT.js → benchmark.CJUa-Hsa.js} +6 -8
  6. package/dist/chunks/{benchmark.d.BwvBVTda.d.ts → benchmark.d.DAaHLpsq.d.ts} +4 -4
  7. package/dist/chunks/browser.d.yFAklsD1.d.ts +18 -0
  8. package/dist/chunks/{cac.Cb-PYCCB.js → cac.DCxo_nSu.js} +72 -163
  9. package/dist/chunks/{cli-api.BkDphVBG.js → cli-api.BJJXh9BV.js} +1331 -1678
  10. package/dist/chunks/{config.d.D2ROskhv.d.ts → config.d.B_LthbQq.d.ts} +59 -65
  11. package/dist/chunks/{console.CtFJOzRO.js → console.7h5kHUIf.js} +34 -70
  12. package/dist/chunks/{constants.DnKduX2e.js → constants.D_Q9UYh-.js} +1 -9
  13. package/dist/chunks/{coverage.DL5VHqXY.js → coverage.BCU-r2QL.js} +538 -765
  14. package/dist/chunks/{coverage.DVF1vEu8.js → coverage.D_JHT54q.js} +2 -2
  15. package/dist/chunks/{coverage.d.S9RMNXIe.d.ts → coverage.d.BZtK59WP.d.ts} +10 -8
  16. package/dist/chunks/{creator.GK6I-cL4.js → creator.08Gi-vCA.js} +93 -77
  17. package/dist/chunks/{date.Bq6ZW5rf.js → date.-jtEtIeV.js} +6 -17
  18. package/dist/chunks/{defaults.B7q_naMc.js → defaults.CXFFjsi8.js} +2 -42
  19. package/dist/chunks/environment.d.BsToaxti.d.ts +65 -0
  20. package/dist/chunks/{git.BVQ8w_Sw.js → git.BFNcloKD.js} +1 -2
  21. package/dist/chunks/{global.d.MAmajcmJ.d.ts → global.d.BK3X7FW1.d.ts} +7 -32
  22. package/dist/chunks/{globals.DEHgCU4V.js → globals.DG-S3xFe.js} +8 -8
  23. package/dist/chunks/{index.VByaPkjc.js → index.BIP7prJq.js} +472 -803
  24. package/dist/chunks/{index.B521nVV-.js → index.Bgo3tNWt.js} +23 -4
  25. package/dist/chunks/{index.BCWujgDG.js → index.BjKEiSn0.js} +14 -24
  26. package/dist/chunks/{index.CdQS2e2Q.js → index.CMfqw92x.js} +7 -8
  27. package/dist/chunks/{index.CmSc2RE5.js → index.DIWhzsUh.js} +72 -118
  28. package/dist/chunks/{inspector.C914Efll.js → inspector.CvQD-Nie.js} +10 -25
  29. package/dist/chunks/moduleRunner.d.D9nBoC4p.d.ts +201 -0
  30. package/dist/chunks/moduleTransport.I-bgQy0S.js +19 -0
  31. package/dist/chunks/{node.fjCdwEIl.js → node.CyipiPvJ.js} +1 -1
  32. package/dist/chunks/plugin.d.BMVSnsGV.d.ts +9 -0
  33. package/dist/chunks/{reporters.d.BFLkQcL6.d.ts → reporters.d.BUWjmRYq.d.ts} +2086 -2146
  34. package/dist/chunks/resolveSnapshotEnvironment.Bkht6Yor.js +81 -0
  35. package/dist/chunks/resolver.Bx6lE0iq.js +119 -0
  36. package/dist/chunks/rpc.BKr6mtxz.js +65 -0
  37. package/dist/chunks/{setup-common.Dd054P77.js → setup-common.uiMcU3cv.js} +17 -29
  38. package/dist/chunks/startModuleRunner.p67gbNo9.js +665 -0
  39. package/dist/chunks/{suite.d.FvehnV49.d.ts → suite.d.BJWk38HB.d.ts} +1 -1
  40. package/dist/chunks/test.BiqSKISg.js +214 -0
  41. package/dist/chunks/{typechecker.DRKU1-1g.js → typechecker.DB-fIMaH.js} +165 -234
  42. package/dist/chunks/{utils.CAioKnHs.js → utils.C2YI6McM.js} +5 -14
  43. package/dist/chunks/{utils.XdZDrNZV.js → utils.D2R2NiOH.js} +8 -27
  44. package/dist/chunks/{vi.bdSIJ99Y.js → vi.ZPgvtBao.js} +156 -305
  45. package/dist/chunks/{vm.BThCzidc.js → vm.Ca0Y0W5f.js} +116 -226
  46. package/dist/chunks/{worker.d.1GmBbd7G.d.ts → worker.d.BDsXGkwh.d.ts} +31 -32
  47. package/dist/chunks/{worker.d.CKwWzBSj.d.ts → worker.d.BNcX_2mH.d.ts} +1 -1
  48. package/dist/cli.js +10 -10
  49. package/dist/config.cjs +5 -58
  50. package/dist/config.d.ts +72 -71
  51. package/dist/config.js +3 -9
  52. package/dist/coverage.d.ts +31 -24
  53. package/dist/coverage.js +9 -9
  54. package/dist/environments.d.ts +9 -14
  55. package/dist/environments.js +1 -1
  56. package/dist/index.d.ts +52 -213
  57. package/dist/index.js +7 -9
  58. package/dist/module-evaluator.d.ts +13 -0
  59. package/dist/module-evaluator.js +276 -0
  60. package/dist/module-runner.js +15 -0
  61. package/dist/node.d.ts +62 -51
  62. package/dist/node.js +26 -42
  63. package/dist/reporters.d.ts +11 -12
  64. package/dist/reporters.js +12 -12
  65. package/dist/runners.d.ts +3 -4
  66. package/dist/runners.js +13 -231
  67. package/dist/snapshot.js +2 -2
  68. package/dist/suite.d.ts +2 -2
  69. package/dist/suite.js +2 -2
  70. package/dist/worker.js +90 -47
  71. package/dist/workers/forks.js +34 -10
  72. package/dist/workers/runVmTests.js +36 -56
  73. package/dist/workers/threads.js +34 -10
  74. package/dist/workers/vmForks.js +11 -10
  75. package/dist/workers/vmThreads.js +11 -10
  76. package/dist/workers.d.ts +5 -7
  77. package/dist/workers.js +35 -17
  78. package/globals.d.ts +17 -17
  79. package/package.json +32 -31
  80. package/dist/chunks/base.DfmxU-tU.js +0 -38
  81. package/dist/chunks/environment.d.cL3nLXbE.d.ts +0 -119
  82. package/dist/chunks/execute.B7h3T_Hc.js +0 -708
  83. package/dist/chunks/index.CwejwG0H.js +0 -105
  84. package/dist/chunks/rpc.-pEldfrD.js +0 -83
  85. package/dist/chunks/runBaseTests.9Ij9_de-.js +0 -129
  86. package/dist/chunks/vite.d.CMLlLIFP.d.ts +0 -25
  87. package/dist/execute.d.ts +0 -150
  88. package/dist/execute.js +0 -13
@@ -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.DnKduX2e.js';
6
- import { R as ReportersMap } from './index.VByaPkjc.js';
5
+ import { a as defaultPort, d as defaultBrowserPort } from './constants.D_Q9UYh-.js';
6
+ import { R as ReportersMap } from './index.BIP7prJq.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 = "3.2.4";
622
+ var version = "4.0.0-beta.10";
623
623
 
624
624
  const apiConfig = (port) => ({
625
625
  port: {
@@ -632,41 +632,29 @@ 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: {
640
639
  description: "Maximum number or percentage of threads to run tests in",
641
640
  argument: "<workers>"
642
641
  },
643
- minThreads: {
644
- description: "Minimum number or percentage of threads to run tests in",
645
- argument: "<workers>"
646
- },
647
642
  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
643
  execArgv: null
649
- };
650
- const poolForksCommands = {
644
+ }, poolForksCommands = {
651
645
  isolate: { description: "Isolate tests in forks pool (default: `true`)" },
652
646
  singleFork: { description: "Run tests inside a single child_process (default: `false`)" },
653
647
  maxForks: {
654
648
  description: "Maximum number or percentage of processes to run tests in",
655
649
  argument: "<workers>"
656
650
  },
657
- minForks: {
658
- description: "Minimum number or percentage of processes to run tests in",
659
- argument: "<workers>"
660
- },
661
651
  execArgv: null
662
652
  };
663
653
  function watermarkTransform(value) {
664
- if (typeof value === "string") return value.split(",").map(Number);
665
- return value;
654
+ return typeof value === "string" ? value.split(",").map(Number) : value;
666
655
  }
667
656
  function transformNestedBoolean(value) {
668
- if (typeof value === "boolean") return { enabled: value };
669
- return value;
657
+ return typeof value === "boolean" ? { enabled: value } : value;
670
658
  }
671
659
  const cliOptionsConfig = {
672
660
  root: {
@@ -734,30 +722,21 @@ const cliOptionsConfig = {
734
722
  argument: "",
735
723
  transform: transformNestedBoolean,
736
724
  subcommands: {
737
- all: {
738
- description: "Whether to include all files, including the untested ones into report",
739
- default: true
740
- },
741
725
  provider: {
742
726
  description: "Select the tool for coverage collection, available values are: \"v8\", \"istanbul\" and \"custom\"",
743
727
  argument: "<name>"
744
728
  },
745
729
  enabled: { description: "Enables coverage collection. Can be overridden using the `--coverage` CLI option (default: `false`)" },
746
730
  include: {
747
- description: "Files included in coverage as glob patterns. May be specified more than once when using multiple patterns (default: `**`)",
731
+ description: "Files included in coverage as glob patterns. May be specified more than once when using multiple patterns. By default only files covered by tests are included.",
748
732
  argument: "<pattern>",
749
733
  array: true
750
734
  },
751
735
  exclude: {
752
- description: "Files to be excluded in coverage. May be specified more than once when using multiple extensions (default: Visit [`coverage.exclude`](https://vitest.dev/config/#coverage-exclude))",
736
+ description: "Files to be excluded in coverage. May be specified more than once when using multiple extensions.",
753
737
  argument: "<pattern>",
754
738
  array: true
755
739
  },
756
- extension: {
757
- description: "Extension to be included in coverage. May be specified more than once when using multiple extensions (default: `[\".js\", \".cjs\", \".mjs\", \".ts\", \".mts\", \".tsx\", \".jsx\", \".vue\", \".svelte\"]`)",
758
- argument: "<extension>",
759
- array: true
760
- },
761
740
  clean: { description: "Clean coverage results before running tests (default: true)" },
762
741
  cleanOnRerun: { description: "Clean coverage report on watch rerun (default: true)" },
763
742
  reportsDirectory: {
@@ -779,7 +758,14 @@ const cliOptionsConfig = {
779
758
  argument: "",
780
759
  subcommands: {
781
760
  perFile: { description: "Check thresholds per file. See `--coverage.thresholds.lines`, `--coverage.thresholds.functions`, `--coverage.thresholds.branches` and `--coverage.thresholds.statements` for the actual thresholds (default: `false`)" },
782
- autoUpdate: { description: "Update threshold values: \"lines\", \"functions\", \"branches\" and \"statements\" to configuration file when current coverage is above the configured thresholds (default: `false`)" },
761
+ autoUpdate: {
762
+ description: "Update threshold values: \"lines\", \"functions\", \"branches\" and \"statements\" to configuration file when current coverage is above the configured thresholds (default: `false`)",
763
+ argument: "<boolean|function>",
764
+ subcommands: null,
765
+ transform(value) {
766
+ return value === "true" || value === "yes" || value === true ? true : value === "false" || value === "no" || value === false ? false : value;
767
+ }
768
+ },
783
769
  lines: {
784
770
  description: "Threshold for lines. Visit [istanbuljs](https://github.com/istanbuljs/nyc#coverage-thresholds) for more information. This option is not available for custom providers",
785
771
  argument: "<number>"
@@ -845,11 +831,6 @@ const cliOptionsConfig = {
845
831
  description: "Override Vite mode (default: `test` or `benchmark`)",
846
832
  argument: "<name>"
847
833
  },
848
- workspace: {
849
- description: "[deprecated] Path to a workspace configuration file",
850
- argument: "<path>",
851
- normalize: true
852
- },
853
834
  isolate: { description: "Run every test file in isolation. To disable isolation, use `--no-isolate` (default: `true`)" },
854
835
  globals: { description: "Inject apis globally" },
855
836
  dom: { description: "Mock browser API with happy-dom" },
@@ -857,11 +838,7 @@ const cliOptionsConfig = {
857
838
  description: "Run tests in the browser. Equivalent to `--browser.enabled` (default: `false`)",
858
839
  argument: "<name>",
859
840
  transform(browser) {
860
- if (typeof browser === "boolean") return { enabled: browser };
861
- if (browser === "true" || browser === "false") return { enabled: browser === "true" };
862
- if (browser === "yes" || browser === "no") return { enabled: browser === "yes" };
863
- if (typeof browser === "string") return { name: browser };
864
- return browser;
841
+ 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;
865
842
  },
866
843
  subcommands: {
867
844
  enabled: { description: "Run tests in the browser. Equivalent to `--browser.enabled` (default: `false`)" },
@@ -878,12 +855,19 @@ const cliOptionsConfig = {
878
855
  provider: {
879
856
  description: "Provider used to run browser tests. Some browsers are only available for specific providers. Can be \"webdriverio\", \"playwright\", \"preview\", or the path to a custom provider. Visit [`browser.provider`](https://vitest.dev/guide/browser/config.html#browser-provider) for more information (default: `\"preview\"`)",
880
857
  argument: "<name>",
881
- subcommands: null
882
- },
883
- providerOptions: {
884
- description: "Options that are passed down to a browser provider. Visit [`browser.providerOptions`](https://vitest.dev/config/#browser-provideroptions) for more information",
885
- argument: "<options>",
886
- subcommands: null
858
+ subcommands: null,
859
+ transform(value) {
860
+ const supported = [
861
+ "playwright",
862
+ "webdriverio",
863
+ "preview"
864
+ ];
865
+ if (typeof value !== "string" || !supported.includes(value)) throw new Error(`Unsupported browser provider: ${value}. Supported providers are: ${supported.join(", ")}`);
866
+ return {
867
+ name: value,
868
+ _cli: true
869
+ };
870
+ }
887
871
  },
888
872
  isolate: { description: "Run every browser test file in isolation. To disable isolation, use `--browser.isolate=false` (default: `true`)" },
889
873
  ui: { description: "Show Vitest UI when running tests (default: `!process.env.CI`)" },
@@ -892,15 +876,16 @@ const cliOptionsConfig = {
892
876
  description: "If connection to the browser takes longer, the test suite will fail (default: `60_000`)",
893
877
  argument: "<timeout>"
894
878
  },
879
+ trackUnhandledErrors: { description: "Control if Vitest catches uncaught exceptions so they can be reported (default: `true`)" },
895
880
  orchestratorScripts: null,
896
- testerScripts: null,
897
881
  commands: null,
898
882
  viewport: null,
899
883
  screenshotDirectory: null,
900
884
  screenshotFailures: null,
901
885
  locators: null,
902
886
  testerHtmlPath: null,
903
- instances: null
887
+ instances: null,
888
+ expect: null
904
889
  }
905
890
  },
906
891
  pool: {
@@ -951,10 +936,6 @@ const cliOptionsConfig = {
951
936
  description: "Maximum number or percentage of workers to run tests in",
952
937
  argument: "<workers>"
953
938
  },
954
- minWorkers: {
955
- description: "Minimum number or percentage of workers to run tests in",
956
- argument: "<workers>"
957
- },
958
939
  environment: {
959
940
  description: "Specify runner environment, if not running in the browser (default: `node`)",
960
941
  argument: "<name>",
@@ -1004,18 +985,14 @@ const cliOptionsConfig = {
1004
985
  description: "Enable Node.js inspector (default: `127.0.0.1:9229`)",
1005
986
  argument: "[[host:]port]",
1006
987
  transform(portOrEnabled) {
1007
- if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes") return true;
1008
- if (portOrEnabled === "false" || portOrEnabled === "no") return false;
1009
- return portOrEnabled;
988
+ return portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes" ? true : portOrEnabled === "false" || portOrEnabled === "no" ? false : portOrEnabled;
1010
989
  }
1011
990
  },
1012
991
  inspectBrk: {
1013
992
  description: "Enable Node.js inspector and break before the test starts",
1014
993
  argument: "[[host:]port]",
1015
994
  transform(portOrEnabled) {
1016
- if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes") return true;
1017
- if (portOrEnabled === "false" || portOrEnabled === "no") return false;
1018
- return portOrEnabled;
995
+ return portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes" ? true : portOrEnabled === "false" || portOrEnabled === "no" ? false : portOrEnabled;
1019
996
  }
1020
997
  },
1021
998
  inspector: null,
@@ -1139,8 +1116,7 @@ const cliOptionsConfig = {
1139
1116
  default: true,
1140
1117
  transform(cache) {
1141
1118
  if (typeof cache !== "boolean" && cache) throw new Error("--cache.dir is deprecated");
1142
- if (cache) return {};
1143
- return cache;
1119
+ return cache && {};
1144
1120
  }
1145
1121
  },
1146
1122
  maxConcurrency: {
@@ -1192,13 +1168,12 @@ const cliOptionsConfig = {
1192
1168
  description: "Use `bundle` to bundle the config with esbuild or `runner` (experimental) to process it on the fly. This is only available in vite version 6.1.0 and above. (default: `bundle`)",
1193
1169
  argument: "<loader>"
1194
1170
  },
1195
- standalone: { description: "Start Vitest without running tests. File filters will be ignored, tests will be running only on change (default: `false`)" },
1171
+ standalone: { description: "Start Vitest without running tests. Tests will be running only on change. This option is ignored when CLI file filters are passed. (default: `false`)" },
1196
1172
  mergeReports: {
1197
1173
  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",
1198
1174
  argument: "[path]",
1199
1175
  transform(value) {
1200
- if (!value || typeof value === "boolean") return ".vitest-reports";
1201
- return value;
1176
+ return !value || typeof value === "boolean" ? ".vitest-reports" : value;
1202
1177
  }
1203
1178
  },
1204
1179
  cliExclude: null,
@@ -1210,7 +1185,6 @@ const cliOptionsConfig = {
1210
1185
  includeSource: null,
1211
1186
  alias: null,
1212
1187
  env: null,
1213
- environmentMatchGlobs: null,
1214
1188
  environmentOptions: null,
1215
1189
  unstubEnvs: null,
1216
1190
  related: null,
@@ -1222,12 +1196,10 @@ const cliOptionsConfig = {
1222
1196
  uiBase: null,
1223
1197
  benchmark: null,
1224
1198
  include: null,
1225
- testTransformMode: null,
1226
1199
  fakeTimers: null,
1227
1200
  chaiConfig: null,
1228
1201
  clearMocks: null,
1229
1202
  css: null,
1230
- poolMatchGlobs: null,
1231
1203
  deps: null,
1232
1204
  name: null,
1233
1205
  snapshotEnvironment: null,
@@ -1250,11 +1222,16 @@ const benchCliOptionsConfig = {
1250
1222
  }
1251
1223
  };
1252
1224
  const collectCliOptionsConfig = {
1225
+ ...cliOptionsConfig,
1253
1226
  json: {
1254
1227
  description: "Print collected tests as JSON or write to a file (Default: false)",
1255
1228
  argument: "[true/path]"
1256
1229
  },
1257
- filesOnly: { description: "Print only test files with out the test cases" }
1230
+ filesOnly: { description: "Print only test files with out the test cases" },
1231
+ changed: {
1232
+ description: "Print only tests that are affected by the changed files (default: `false`)",
1233
+ argument: "[since]"
1234
+ }
1258
1235
  };
1259
1236
 
1260
1237
  function addCommand(cli, name, option) {
@@ -1266,11 +1243,7 @@ function addCommand(cli, name, option) {
1266
1243
  const received = value.map((s) => typeof s === "string" ? `"${s}"` : s).join(", ");
1267
1244
  throw new Error(`Expected a single value for option "${command}", received [${received}]`);
1268
1245
  }
1269
- value = removeQuotes(value);
1270
- if (option.transform) return option.transform(value);
1271
- if (option.array) return toArray(value);
1272
- if (option.normalize) return normalize(String(value));
1273
- return value;
1246
+ return value = removeQuotes(value), option.transform ? option.transform(value) : option.array ? toArray(value) : option.normalize ? normalize(String(value)) : value;
1274
1247
  }
1275
1248
  const hasSubcommands = "subcommands" in option && option.subcommands;
1276
1249
  if (option.description) {
@@ -1288,24 +1261,16 @@ function addCliOptions(cli, options) {
1288
1261
  }
1289
1262
  function createCLI(options = {}) {
1290
1263
  const cli = cac("vitest");
1291
- cli.version(version);
1292
- addCliOptions(cli, cliOptionsConfig);
1293
- cli.help((info) => {
1264
+ return cli.version(version), addCliOptions(cli, cliOptionsConfig), cli.help((info) => {
1294
1265
  const helpSection = info.find((current) => current.title?.startsWith("For more info, run any command"));
1295
1266
  if (helpSection) helpSection.body += "\n $ vitest --help --expand-help";
1296
1267
  const options = info.find((current) => current.title === "Options");
1297
1268
  if (typeof options !== "object") return info;
1298
- const helpIndex = process.argv.findIndex((arg) => arg === "--help");
1299
- const subcommands = process.argv.slice(helpIndex + 1);
1300
- const defaultOutput = options.body.split("\n").filter((line) => /^\s+--\S+\./.test(line) === false).join("\n");
1269
+ 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");
1301
1270
  // Filter out options with dot-notation if --help is not called with a subcommand (default behavior)
1302
- if (subcommands.length === 0) {
1303
- options.body = defaultOutput;
1304
- return info;
1305
- }
1271
+ if (subcommands.length === 0) return options.body = defaultOutput, info;
1306
1272
  if (subcommands.length === 1 && (subcommands[0] === "--expand-help" || subcommands[0] === "--expandHelp")) return info;
1307
- const subcommandMarker = "$SUB_COMMAND_MARKER$";
1308
- const banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
1273
+ const subcommandMarker = "$SUB_COMMAND_MARKER$", banner = info.find((current) => /^vitest\/\d+\.\d+\.\d+$/.test(current.body));
1309
1274
  function addBannerWarning(warning) {
1310
1275
  if (typeof banner?.body === "string") {
1311
1276
  if (banner?.body.includes(warning)) return;
@@ -1323,129 +1288,76 @@ function createCLI(options = {}) {
1323
1288
  // Mark the help section for the subcommands
1324
1289
  if (subcommand.startsWith("--")) options.body = options.body.split("\n").map((line) => line.trim().startsWith(subcommand) ? `${subcommandMarker}${line}` : line).join("\n");
1325
1290
  }
1326
- // Filter based on the marked options to preserve the original sort order
1327
- options.body = options.body.split("\n").map((line) => line.startsWith(subcommandMarker) ? line.split(subcommandMarker)[1] : "").filter((line) => line.length !== 0).join("\n");
1328
- if (!options.body) {
1329
- addBannerWarning("no options were found for your subcommands so we printed the whole output");
1330
- options.body = defaultOutput;
1331
- }
1291
+ 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;
1332
1292
  return info;
1333
- });
1334
- cli.command("run [...filters]", void 0, options).action(run);
1335
- cli.command("related [...filters]", void 0, options).action(runRelated);
1336
- cli.command("watch [...filters]", void 0, options).action(watch);
1337
- cli.command("dev [...filters]", void 0, options).action(watch);
1338
- addCliOptions(cli.command("bench [...filters]", void 0, options).action(benchmark), benchCliOptionsConfig);
1339
- cli.command("init <project>", void 0, options).action(init);
1340
- addCliOptions(cli.command("list [...filters]", void 0, options).action((filters, options) => collect("test", filters, options)), collectCliOptionsConfig);
1341
- cli.command("[...filters]", void 0, options).action((filters, options) => start("test", filters, options));
1342
- return cli;
1293
+ }), 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;
1343
1294
  }
1344
1295
  function removeQuotes(str) {
1345
- if (typeof str !== "string") {
1346
- if (Array.isArray(str)) return str.map(removeQuotes);
1347
- return str;
1348
- }
1349
- if (str.startsWith("\"") && str.endsWith("\"")) return str.slice(1, -1);
1350
- if (str.startsWith(`'`) && str.endsWith(`'`)) return str.slice(1, -1);
1351
- return str;
1296
+ return typeof str === "string" ? str.startsWith("\"") && str.endsWith("\"") || str.startsWith(`'`) && str.endsWith(`'`) ? str.slice(1, -1) : str : Array.isArray(str) ? str.map(removeQuotes) : str;
1352
1297
  }
1353
1298
  function splitArgv(argv) {
1354
1299
  const reg = /(['"])(?:(?!\1).)+\1/g;
1355
- argv = argv.replace(reg, (match) => match.replace(/\s/g, "\0"));
1356
- return argv.split(" ").map((arg) => {
1357
- arg = arg.replace(/\0/g, " ");
1358
- return removeQuotes(arg);
1300
+ return argv = argv.replace(reg, (match) => match.replace(/\s/g, "\0")), argv.split(" ").map((arg) => {
1301
+ return arg = arg.replace(/\0/g, " "), removeQuotes(arg);
1359
1302
  });
1360
1303
  }
1361
1304
  function parseCLI(argv, config = {}) {
1362
1305
  const arrayArgs = typeof argv === "string" ? splitArgv(argv) : argv;
1363
1306
  if (arrayArgs[0] !== "vitest") throw new Error(`Expected "vitest" as the first argument, received "${arrayArgs[0]}"`);
1364
- arrayArgs[0] = "/index.js";
1365
- arrayArgs.unshift("node");
1307
+ arrayArgs[0] = "/index.js", arrayArgs.unshift("node");
1366
1308
  let { args, options } = createCLI(config).parse(arrayArgs, { run: false });
1367
1309
  if (arrayArgs[2] === "watch" || arrayArgs[2] === "dev") options.watch = true;
1368
1310
  if (arrayArgs[2] === "run" && !options.watch) options.run = true;
1369
- if (arrayArgs[2] === "related") {
1370
- options.related = args;
1371
- options.passWithNoTests ??= true;
1372
- args = [];
1373
- }
1311
+ if (arrayArgs[2] === "related") options.related = args, options.passWithNoTests ??= true, args = [];
1374
1312
  return {
1375
1313
  filter: args,
1376
1314
  options
1377
1315
  };
1378
1316
  }
1379
1317
  async function runRelated(relatedFiles, argv) {
1380
- argv.related = relatedFiles;
1381
- argv.passWithNoTests ??= true;
1382
- await start("test", [], argv);
1318
+ argv.related = relatedFiles, argv.passWithNoTests ??= true, await start("test", [], argv);
1383
1319
  }
1384
1320
  async function watch(cliFilters, options) {
1385
- options.watch = true;
1386
- await start("test", cliFilters, options);
1321
+ options.watch = true, await start("test", cliFilters, options);
1387
1322
  }
1388
1323
  async function run(cliFilters, options) {
1389
- // "vitest run --watch" should still be watch mode
1390
- options.run = !options.watch;
1391
- await start("test", cliFilters, options);
1324
+ options.run = !options.watch, await start("test", cliFilters, options);
1392
1325
  }
1393
1326
  async function benchmark(cliFilters, options) {
1394
- console.warn(c.yellow("Benchmarking is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it."));
1395
- await start("benchmark", cliFilters, options);
1327
+ 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);
1396
1328
  }
1397
1329
  function normalizeCliOptions(cliFilters, argv) {
1398
- if (argv.exclude) {
1399
- argv.cliExclude = toArray(argv.exclude);
1400
- delete argv.exclude;
1401
- }
1330
+ if (argv.exclude) argv.cliExclude = toArray(argv.exclude), delete argv.exclude;
1402
1331
  if (cliFilters.some((filter) => filter.includes(":"))) argv.includeTaskLocation ??= true;
1403
1332
  if (typeof argv.typecheck?.only === "boolean") argv.typecheck.enabled ??= true;
1404
1333
  return argv;
1405
1334
  }
1406
1335
  async function start(mode, cliFilters, options) {
1407
1336
  try {
1408
- process.title = "node (vitest)";
1409
- } catch {}
1410
- try {
1411
- const { startVitest } = await import('./cli-api.BkDphVBG.js').then(function (n) { return n.f; });
1412
- const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1337
+ const { startVitest } = await import('./cli-api.BJJXh9BV.js').then(function (n) { return n.j; }), ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1413
1338
  if (!ctx.shouldKeepServer()) await ctx.exit();
1414
1339
  } catch (e) {
1415
- const { errorBanner } = await import('./index.VByaPkjc.js').then(function (n) { return n.u; });
1416
- console.error(`\n${errorBanner("Startup Error")}`);
1417
- console.error(e);
1418
- console.error("\n\n");
1419
- if (process.exitCode == null) process.exitCode = 1;
1340
+ const { errorBanner } = await import('./index.BIP7prJq.js').then(function (n) { return n.u; });
1341
+ if (console.error(`\n${errorBanner("Startup Error")}`), console.error(e), console.error("\n\n"), process.exitCode == null) process.exitCode = 1;
1420
1342
  process.exit();
1421
1343
  }
1422
1344
  }
1423
1345
  async function init(project) {
1424
- if (project !== "browser") {
1425
- console.error(new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project."));
1426
- process.exit(1);
1427
- }
1428
- const { create } = await import('./creator.GK6I-cL4.js');
1346
+ 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);
1347
+ const { create } = await import('./creator.08Gi-vCA.js');
1429
1348
  await create();
1430
1349
  }
1431
1350
  async function collect(mode, cliFilters, options) {
1432
1351
  try {
1433
- process.title = "node (vitest)";
1434
- } catch {}
1435
- try {
1436
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.BkDphVBG.js').then(function (n) { return n.f; });
1437
- const ctx = await prepareVitest(mode, {
1352
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.BJJXh9BV.js').then(function (n) { return n.j; }), ctx = await prepareVitest(mode, {
1438
1353
  ...normalizeCliOptions(cliFilters, options),
1439
1354
  watch: false,
1440
1355
  run: true
1441
- });
1356
+ }, void 0, void 0, cliFilters);
1442
1357
  if (!options.filesOnly) {
1443
1358
  const { testModules: tests, unhandledErrors: errors } = await ctx.collect(cliFilters.map(normalize));
1444
1359
  if (errors.length) {
1445
- console.error("\nThere were unhandled errors during test collection");
1446
- errors.forEach((e) => console.error(e));
1447
- console.error("\n\n");
1448
- await ctx.close();
1360
+ console.error("\nThere were unhandled errors during test collection"), errors.forEach((e) => console.error(e)), console.error("\n\n"), await ctx.close();
1449
1361
  return;
1450
1362
  }
1451
1363
  processCollected(ctx, tests, options);
@@ -1455,11 +1367,8 @@ async function collect(mode, cliFilters, options) {
1455
1367
  }
1456
1368
  await ctx.close();
1457
1369
  } catch (e) {
1458
- const { errorBanner } = await import('./index.VByaPkjc.js').then(function (n) { return n.u; });
1459
- console.error(`\n${errorBanner("Collect Error")}`);
1460
- console.error(e);
1461
- console.error("\n\n");
1462
- if (process.exitCode == null) process.exitCode = 1;
1370
+ const { errorBanner } = await import('./index.BIP7prJq.js').then(function (n) { return n.u; });
1371
+ if (console.error(`\n${errorBanner("Collect Error")}`), console.error(e), console.error("\n\n"), process.exitCode == null) process.exitCode = 1;
1463
1372
  process.exit();
1464
1373
  }
1465
1374
  }