vitest 5.0.0-beta.7 → 5.0.0-rc.1

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 (70) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/browser.d.ts +6 -4
  3. package/dist/browser.js +10 -10
  4. package/dist/chunks/{acorn.B2iPLyUM.js → acorn.C1kjbUFw.js} +30 -30
  5. package/dist/chunks/{base.B0fUxpj9.js → base.IQV3unVv.js} +46 -42
  6. package/dist/chunks/{browser.d.BFOby8YL.d.ts → browser.d.Dp8LNQdx.d.ts} +14 -14
  7. package/dist/chunks/{cac.B41kXwyU.js → cac.CM6y_f_i.js} +51 -21
  8. package/dist/chunks/{cli-api.bqNN5viV.js → cli-api.B4r6twmv.js} +12 -11
  9. package/dist/chunks/{config.d.DsC1jkby.d.ts → config.d.BpALOMjL.d.ts} +147 -118
  10. package/dist/chunks/{console.omGxyKMT.js → console.DWNMLVgF.js} +62 -62
  11. package/dist/chunks/{coverage.BVb1JqW7.js → coverage.CPiksdSj.js} +1 -1
  12. package/dist/chunks/{coverage.BfSEMtie.js → coverage.VANpXofm.js} +1 -1
  13. package/dist/chunks/{creator.BzMFaPC-.js → creator.BW8mSwbG.js} +16 -18
  14. package/dist/chunks/{defaults.BJUmAuaO.js → defaults.D2ip7f-X.js} +4 -2
  15. package/dist/chunks/{display.CYwyMF4S.js → display.pkpxlVcY.js} +3 -1
  16. package/dist/chunks/doctor.oxixVMjH.js +465 -0
  17. package/dist/chunks/{environment.d.4-rzQgpt.d.ts → environment.d.DCnG-EPE.d.ts} +1 -1
  18. package/dist/chunks/{globals.sd6Qutmc.js → globals.Dfl9zyCz.js} +11 -11
  19. package/dist/chunks/{index.DxR-nMjO.js → index.BfU4rh_M.js} +68 -30
  20. package/dist/chunks/{index.Chj8NDwU.js → index.CCh1Pb8k.js} +6 -12
  21. package/dist/chunks/{index.JaztIWgW.js → index.CePpwRnE.js} +6 -6
  22. package/dist/chunks/{index.CLtI1k_4.js → index.DRmbsPYf.js} +7496 -7363
  23. package/dist/chunks/{index.CMESou6r.js → index.DXQx-kDM.js} +77 -81
  24. package/dist/chunks/{index.5krd73UD.js → index.DiRpHFrd.js} +1775 -607
  25. package/dist/chunks/{index.DzTmMrSM.js → index.M2dsQ_UQ.js} +8 -4
  26. package/dist/chunks/{init-forks.CXzT841o.js → init-forks.BpFQPK_m.js} +1 -1
  27. package/dist/chunks/{init-threads.Ch-Bw5j3.js → init-threads.DspSJVVe.js} +1 -1
  28. package/dist/chunks/{init.CfiYZpFg.js → init.BU4khizz.js} +38 -10
  29. package/dist/chunks/{native.BUCvPRKp.js → native.offEPk9l.js} +3 -3
  30. package/dist/chunks/{nativeModuleMocker.Uot80PXb.js → nativeModuleMocker.0CD1hdFV.js} +19 -11
  31. package/dist/chunks/{nativeModuleRunner.BDnwGb8g.js → nativeModuleRunner.Bc3kXpWn.js} +64 -32
  32. package/dist/chunks/{node.BPMnm_Q2.js → node.CS-X6Ymg.js} +2 -1
  33. package/dist/chunks/{pathe.M-eThtNZ.CbK_Vbae.js → pathe.M-eThtNZ.k2RS39sQ.js} +2 -2
  34. package/dist/chunks/{plugin.d.BOjbmxWW.d.ts → plugin.d.xikpJNpD.d.ts} +145 -63
  35. package/dist/chunks/{plugins.CsoX-42X.js → plugins.Cigb0uSy.js} +1 -1
  36. package/dist/chunks/{resolver.CERfsKE-.js → resolver.B_5CI0Kh.js} +1 -1
  37. package/dist/chunks/{rpc.iNjF664v.js → rpc.DaPTofpf.js} +8 -76
  38. package/dist/chunks/{rpc.d.BeasqWpO.d.ts → rpc.d.DWQfGdI1.d.ts} +1 -1
  39. package/dist/chunks/{artifact.DC5WoEgy.js → run.DS9d28OG.js} +262 -222
  40. package/dist/chunks/{setup-common.vxjAyUtK.js → setup-common.D_kw2djf.js} +3 -3
  41. package/dist/chunks/{setup.DasACXvo.js → setup.CXTsmSEE.js} +44 -55
  42. package/dist/chunks/{source-map.DZdIqpIJ.js → source-map.CTObTzjj.js} +5 -4
  43. package/dist/chunks/{coverage.d.ByaAMV4A.d.ts → source-map.d.DRVw4m2c.d.ts} +42 -42
  44. package/dist/chunks/{spy.B8mHA9qu.js → spy.DPpyuUIA.js} +43 -4
  45. package/dist/chunks/{task-utils.d.BKHiHxSN.d.ts → task-utils.d.B0b4kWzC.d.ts} +26 -17
  46. package/dist/chunks/{utils.CO-iLyCr.js → utils.DtdLoSPT.js} +6 -11
  47. package/dist/chunks/{vm.DoQh8CN9.js → vm.QEFtWwx4.js} +464 -86
  48. package/dist/chunks/{worker.d.s_RdeZtI.d.ts → worker.d.D7LKSMQN.d.ts} +15 -9
  49. package/dist/cli.js +2 -2
  50. package/dist/config.d.ts +10 -9
  51. package/dist/config.js +1 -1
  52. package/dist/index.d.ts +12 -11
  53. package/dist/index.js +10 -10
  54. package/dist/module-evaluator.d.ts +19 -3
  55. package/dist/module-evaluator.js +26 -19
  56. package/dist/node.d.ts +15 -14
  57. package/dist/node.js +15 -15
  58. package/dist/runtime.d.ts +4 -4
  59. package/dist/runtime.js +4 -4
  60. package/dist/spy.js +1 -1
  61. package/dist/task-utils.js +8 -22
  62. package/dist/traces.js +2 -1
  63. package/dist/worker.d.ts +6 -4
  64. package/dist/worker.js +17 -17
  65. package/dist/workers/forks.js +18 -18
  66. package/dist/workers/runVmTests.js +44 -32
  67. package/dist/workers/threads.js +18 -18
  68. package/dist/workers/vmForks.js +15 -13
  69. package/dist/workers/vmThreads.js +15 -13
  70. package/package.json +33 -35
package/LICENSE.md CHANGED
@@ -31,7 +31,7 @@ BSD-3-Clause, ISC, MIT
31
31
  ## @antfu/install-pkg
32
32
  License: MIT
33
33
  By: Anthony Fu
34
- Repository: git+https://github.com/antfu/install-pkg.git
34
+ Repository: git+https://github.com/antfu-collective/install-pkg.git
35
35
 
36
36
  > MIT License
37
37
  >
package/dist/browser.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { az as SerializedCoverageConfig, be as FileSpecification, V as VitestRunner, F as File, x as SerializedConfig, bf as SerializedDiffOptions, a8 as DiffOptions, aU as TestError } from './chunks/config.d.DsC1jkby.js';
2
- export { au as ParsedStack, bg as SpyModule, bh as StringifyOptions, bi as format, bj as inspect, bk as stringify } from './chunks/config.d.DsC1jkby.js';
3
- import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.ByaAMV4A.js';
4
- export { D as DecodedMap, g as getOriginalPosition } from './chunks/coverage.d.ByaAMV4A.js';
1
+ import { F as FileSpecification, c as SerializedDiffOptions } from './chunks/config.d.BpALOMjL.js';
2
+ import { SerializedCoverageConfig, RunnerTestFile as File, SerializedConfig, DiffOptions, TestError } from './index.js';
3
+ import { VitestRunner } from './runtime.js';
4
+ export { P as ParsedStack, _ as SpyModule, d as StringifyOptions, f as format, i as inspect, s as stringify } from './chunks/config.d.BpALOMjL.js';
5
+ import { R as RuntimeCoverageModuleLoader } from './chunks/source-map.d.DRVw4m2c.js';
6
+ export { D as DecodedMap, g as getOriginalPosition } from './chunks/source-map.d.DRVw4m2c.js';
5
7
  import 'vitest/optional-runtime-types.js';
6
8
  import 'tinybench';
7
9
 
package/dist/browser.js CHANGED
@@ -1,15 +1,15 @@
1
- export { s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/coverage.BfSEMtie.js';
2
- export { p as collectTests, a as processError, s as startTests } from './chunks/artifact.DC5WoEgy.js';
3
- export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as setupEnv } from './chunks/setup-common.vxjAyUtK.js';
4
- export { s as SpyModule } from './chunks/spy.B8mHA9qu.js';
5
- export { f as format, i as inspect, s as stringify } from './chunks/display.CYwyMF4S.js';
6
- export { g as getType } from './chunks/pathe.M-eThtNZ.CbK_Vbae.js';
7
- export { D as DecodedMap, g as getOriginalPosition, a as getSafeTimers, s as setSafeTimers } from './chunks/source-map.DZdIqpIJ.js';
8
- import './chunks/coverage.BVb1JqW7.js';
9
- import './chunks/index.DzTmMrSM.js';
1
+ export { s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/coverage.VANpXofm.js';
2
+ export { p as collectTests, a as processError, s as startTests } from './chunks/run.DS9d28OG.js';
3
+ export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as setupEnv } from './chunks/setup-common.D_kw2djf.js';
4
+ export { s as SpyModule } from './chunks/spy.DPpyuUIA.js';
5
+ export { f as format, i as inspect, s as stringify } from './chunks/display.pkpxlVcY.js';
6
+ export { g as getType } from './chunks/pathe.M-eThtNZ.k2RS39sQ.js';
7
+ export { D as DecodedMap, g as getOriginalPosition, a as getSafeTimers, s as setSafeTimers } from './chunks/source-map.CTObTzjj.js';
8
+ import './chunks/coverage.CPiksdSj.js';
9
+ import './chunks/index.M2dsQ_UQ.js';
10
10
  import './chunks/tinyrainbow.Ht9iggcq.js';
11
11
  import './task-utils.js';
12
- import './chunks/plugins.CsoX-42X.js';
12
+ import './chunks/plugins.Cigb0uSy.js';
13
13
 
14
14
  /**
15
15
  * @internal
@@ -817,10 +817,10 @@ var pp$8 = Parser.prototype;
817
817
  // to its body instead of creating a new node.
818
818
 
819
819
  pp$8.parseTopLevel = function(node) {
820
- var exports$1 = Object.create(null);
820
+ var exports = Object.create(null);
821
821
  if (!node.body) { node.body = []; }
822
822
  while (this.type !== types$1.eof) {
823
- var stmt = this.parseStatement(null, true, exports$1);
823
+ var stmt = this.parseStatement(null, true, exports);
824
824
  node.body.push(stmt);
825
825
  }
826
826
  if (this.inModule)
@@ -884,7 +884,7 @@ pp$8.isAsyncFunction = function() {
884
884
  // `if (foo) /blah/.exec(foo)`, where looking at the previous token
885
885
  // does not help.
886
886
 
887
- pp$8.parseStatement = function(context, topLevel, exports$1) {
887
+ pp$8.parseStatement = function(context, topLevel, exports) {
888
888
  var starttype = this.type, node = this.startNode(), kind;
889
889
 
890
890
  if (this.isLet(context)) {
@@ -939,7 +939,7 @@ pp$8.parseStatement = function(context, topLevel, exports$1) {
939
939
  if (!this.inModule)
940
940
  { this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); }
941
941
  }
942
- return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports$1)
942
+ return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports)
943
943
 
944
944
  // If the statement does not start with a statement keyword or a
945
945
  // brace, it's an ExpressionStatement or LabeledStatement. We
@@ -1654,11 +1654,11 @@ function checkKeyName(node, name) {
1654
1654
 
1655
1655
  // Parses module export declaration.
1656
1656
 
1657
- pp$8.parseExportAllDeclaration = function(node, exports$1) {
1657
+ pp$8.parseExportAllDeclaration = function(node, exports) {
1658
1658
  if (this.options.ecmaVersion >= 11) {
1659
1659
  if (this.eatContextual("as")) {
1660
1660
  node.exported = this.parseModuleExportName();
1661
- this.checkExport(exports$1, node.exported, this.lastTokStart);
1661
+ this.checkExport(exports, node.exported, this.lastTokStart);
1662
1662
  } else {
1663
1663
  node.exported = null;
1664
1664
  }
@@ -1670,14 +1670,14 @@ pp$8.parseExportAllDeclaration = function(node, exports$1) {
1670
1670
  return this.finishNode(node, "ExportAllDeclaration")
1671
1671
  };
1672
1672
 
1673
- pp$8.parseExport = function(node, exports$1) {
1673
+ pp$8.parseExport = function(node, exports) {
1674
1674
  this.next();
1675
1675
  // export * from '...'
1676
1676
  if (this.eat(types$1.star)) {
1677
- return this.parseExportAllDeclaration(node, exports$1)
1677
+ return this.parseExportAllDeclaration(node, exports)
1678
1678
  }
1679
1679
  if (this.eat(types$1._default)) { // export default ...
1680
- this.checkExport(exports$1, "default", this.lastTokStart);
1680
+ this.checkExport(exports, "default", this.lastTokStart);
1681
1681
  node.declaration = this.parseExportDefaultDeclaration();
1682
1682
  return this.finishNode(node, "ExportDefaultDeclaration")
1683
1683
  }
@@ -1685,14 +1685,14 @@ pp$8.parseExport = function(node, exports$1) {
1685
1685
  if (this.shouldParseExportStatement()) {
1686
1686
  node.declaration = this.parseExportDeclaration(node);
1687
1687
  if (node.declaration.type === "VariableDeclaration")
1688
- { this.checkVariableExport(exports$1, node.declaration.declarations); }
1688
+ { this.checkVariableExport(exports, node.declaration.declarations); }
1689
1689
  else
1690
- { this.checkExport(exports$1, node.declaration.id, node.declaration.id.start); }
1690
+ { this.checkExport(exports, node.declaration.id, node.declaration.id.start); }
1691
1691
  node.specifiers = [];
1692
1692
  node.source = null;
1693
1693
  } else { // export { x, y as z } [from '...']
1694
1694
  node.declaration = null;
1695
- node.specifiers = this.parseExportSpecifiers(exports$1);
1695
+ node.specifiers = this.parseExportSpecifiers(exports);
1696
1696
  if (this.eatContextual("from")) {
1697
1697
  if (this.type !== types$1.string) { this.unexpected(); }
1698
1698
  node.source = this.parseExprAtom();
@@ -1738,47 +1738,47 @@ pp$8.parseExportDefaultDeclaration = function() {
1738
1738
  }
1739
1739
  };
1740
1740
 
1741
- pp$8.checkExport = function(exports$1, name, pos) {
1742
- if (!exports$1) { return }
1741
+ pp$8.checkExport = function(exports, name, pos) {
1742
+ if (!exports) { return }
1743
1743
  if (typeof name !== "string")
1744
1744
  { name = name.type === "Identifier" ? name.name : name.value; }
1745
- if (hasOwn(exports$1, name))
1745
+ if (hasOwn(exports, name))
1746
1746
  { this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); }
1747
- exports$1[name] = true;
1747
+ exports[name] = true;
1748
1748
  };
1749
1749
 
1750
- pp$8.checkPatternExport = function(exports$1, pat) {
1750
+ pp$8.checkPatternExport = function(exports, pat) {
1751
1751
  var type = pat.type;
1752
1752
  if (type === "Identifier")
1753
- { this.checkExport(exports$1, pat, pat.start); }
1753
+ { this.checkExport(exports, pat, pat.start); }
1754
1754
  else if (type === "ObjectPattern")
1755
1755
  { for (var i = 0, list = pat.properties; i < list.length; i += 1)
1756
1756
  {
1757
1757
  var prop = list[i];
1758
1758
 
1759
- this.checkPatternExport(exports$1, prop);
1759
+ this.checkPatternExport(exports, prop);
1760
1760
  } }
1761
1761
  else if (type === "ArrayPattern")
1762
1762
  { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
1763
1763
  var elt = list$1[i$1];
1764
1764
 
1765
- if (elt) { this.checkPatternExport(exports$1, elt); }
1765
+ if (elt) { this.checkPatternExport(exports, elt); }
1766
1766
  } }
1767
1767
  else if (type === "Property")
1768
- { this.checkPatternExport(exports$1, pat.value); }
1768
+ { this.checkPatternExport(exports, pat.value); }
1769
1769
  else if (type === "AssignmentPattern")
1770
- { this.checkPatternExport(exports$1, pat.left); }
1770
+ { this.checkPatternExport(exports, pat.left); }
1771
1771
  else if (type === "RestElement")
1772
- { this.checkPatternExport(exports$1, pat.argument); }
1772
+ { this.checkPatternExport(exports, pat.argument); }
1773
1773
  };
1774
1774
 
1775
- pp$8.checkVariableExport = function(exports$1, decls) {
1776
- if (!exports$1) { return }
1775
+ pp$8.checkVariableExport = function(exports, decls) {
1776
+ if (!exports) { return }
1777
1777
  for (var i = 0, list = decls; i < list.length; i += 1)
1778
1778
  {
1779
1779
  var decl = list[i];
1780
1780
 
1781
- this.checkPatternExport(exports$1, decl.id);
1781
+ this.checkPatternExport(exports, decl.id);
1782
1782
  }
1783
1783
  };
1784
1784
 
@@ -1793,13 +1793,13 @@ pp$8.shouldParseExportStatement = function() {
1793
1793
 
1794
1794
  // Parses a comma-separated list of module exports.
1795
1795
 
1796
- pp$8.parseExportSpecifier = function(exports$1) {
1796
+ pp$8.parseExportSpecifier = function(exports) {
1797
1797
  var node = this.startNode();
1798
1798
  node.local = this.parseModuleExportName();
1799
1799
 
1800
1800
  node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
1801
1801
  this.checkExport(
1802
- exports$1,
1802
+ exports,
1803
1803
  node.exported,
1804
1804
  node.exported.start
1805
1805
  );
@@ -1807,7 +1807,7 @@ pp$8.parseExportSpecifier = function(exports$1) {
1807
1807
  return this.finishNode(node, "ExportSpecifier")
1808
1808
  };
1809
1809
 
1810
- pp$8.parseExportSpecifiers = function(exports$1) {
1810
+ pp$8.parseExportSpecifiers = function(exports) {
1811
1811
  var nodes = [], first = true;
1812
1812
  // export { x, y as z } [from '...']
1813
1813
  this.expect(types$1.braceL);
@@ -1817,7 +1817,7 @@ pp$8.parseExportSpecifiers = function(exports$1) {
1817
1817
  if (this.afterTrailingComma(types$1.braceR)) { break }
1818
1818
  } else { first = false; }
1819
1819
 
1820
- nodes.push(this.parseExportSpecifier(exports$1));
1820
+ nodes.push(this.parseExportSpecifier(exports));
1821
1821
  }
1822
1822
  return nodes
1823
1823
  };
@@ -1,21 +1,21 @@
1
1
  import { runInThisContext } from 'node:vm';
2
- import { s as spyModule } from './spy.B8mHA9qu.js';
3
- import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.JaztIWgW.js';
4
- import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.CfiYZpFg.js';
2
+ import { s as spyModule } from './spy.DPpyuUIA.js';
3
+ import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.CePpwRnE.js';
4
+ import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.BU4khizz.js';
5
5
  import { Traces } from '../traces.js';
6
- import { V as VitestEvaluatedModules } from './rpc.iNjF664v.js';
7
- import { s as startVitestModuleRunner, c as createNodeImportMeta } from './index.DxR-nMjO.js';
6
+ import { V as VitestEvaluatedModules } from './rpc.DaPTofpf.js';
7
+ import { s as startVitestModuleRunner, c as createNodeImportMeta } from './index.BfU4rh_M.js';
8
8
  import { performance as performance$1 } from 'node:perf_hooks';
9
- import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './coverage.BfSEMtie.js';
10
- import { i as index, g as globalExpect, v as vi } from './index.CLtI1k_4.js';
9
+ import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './coverage.VANpXofm.js';
10
+ import { i as index, g as globalExpect, v as vi } from './index.DRmbsPYf.js';
11
11
  import { c as closeInspector } from './inspector.CvyFGlXm.js';
12
- import { s as startTests, p as publicCollect } from './artifact.DC5WoEgy.js';
12
+ import { s as startTests, p as publicCollect } from './run.DS9d28OG.js';
13
13
  import { createRequire } from 'node:module';
14
14
  import timers from 'node:timers';
15
15
  import timersPromises from 'node:timers/promises';
16
16
  import util from 'node:util';
17
- import { K as KNOWN_ASSET_TYPES } from './pathe.M-eThtNZ.CbK_Vbae.js';
18
- import { s as setupCommonEnv, b as setupEnv } from './setup-common.vxjAyUtK.js';
17
+ import { K as KNOWN_ASSET_TYPES } from './pathe.M-eThtNZ.k2RS39sQ.js';
18
+ import { s as setupCommonEnv, b as setupEnv } from './setup-common.D_kw2djf.js';
19
19
  import { g as getWorkerState, r as resetModules, p as provideWorkerState, a as getSafeWorkerState } from './utils.DYj33du9.js';
20
20
 
21
21
  // this should only be used in Node
@@ -57,7 +57,7 @@ function resolveAsset(mod, url) {
57
57
  mod.exports = url;
58
58
  }
59
59
  async function setupConsoleLogSpy() {
60
- const { createCustomConsole } = await import('./console.omGxyKMT.js');
60
+ const { createCustomConsole } = await import('./console.DWNMLVgF.js');
61
61
  globalThis.console = createCustomConsole();
62
62
  }
63
63
 
@@ -72,30 +72,34 @@ async function run(method, files, config, moduleRunner, environment, traces) {
72
72
  if (!workerState.config.snapshotOptions.snapshotEnvironment) workerState.config.snapshotOptions.snapshotEnvironment = await resolveSnapshotEnvironment(config, moduleRunner);
73
73
  })
74
74
  ]);
75
- workerState.onCancel((reason) => {
75
+ const offCancel = workerState.onCancel((reason) => {
76
76
  closeInspector(config);
77
77
  testRunner.cancel?.(reason);
78
78
  });
79
79
  workerState.durations.prepare = performance$1.now() - workerState.durations.prepare;
80
- await traces.$(`vitest.test.runner.${method}`, async () => {
81
- for (const file of files) {
82
- if (config.isolate) {
83
- moduleRunner.mocker?.reset();
84
- resetModules(workerState.evaluatedModules, true);
80
+ try {
81
+ await traces.$(`vitest.test.runner.${method}`, async () => {
82
+ for (const file of files) {
83
+ if (config.isolate) {
84
+ moduleRunner.mocker?.reset();
85
+ resetModules(workerState.evaluatedModules, true);
86
+ }
87
+ workerState.filepath = file.filepath;
88
+ if (method === "run") {
89
+ const collectAsyncLeaks = config.detectAsyncLeaks ? detectAsyncLeaks(file.filepath, workerState.ctx.projectName) : void 0;
90
+ await traces.$(`vitest.test.runner.${method}.module`, { attributes: { "code.file.path": file.filepath } }, () => startTests([file], testRunner));
91
+ const leaks = await collectAsyncLeaks?.();
92
+ if (leaks?.length) workerState.rpc.onAsyncLeaks(leaks);
93
+ } else await traces.$(`vitest.test.runner.${method}.module`, { attributes: { "code.file.path": file.filepath } }, () => publicCollect([file], testRunner));
94
+ // reset after tests, because user might call `vi.setConfig` in setupFile
95
+ vi.resetConfig();
96
+ // mocks should not affect different files
97
+ vi.restoreAllMocks();
85
98
  }
86
- workerState.filepath = file.filepath;
87
- if (method === "run") {
88
- const collectAsyncLeaks = config.detectAsyncLeaks ? detectAsyncLeaks(file.filepath, workerState.ctx.projectName) : void 0;
89
- await traces.$(`vitest.test.runner.${method}.module`, { attributes: { "code.file.path": file.filepath } }, () => startTests([file], testRunner));
90
- const leaks = await collectAsyncLeaks?.();
91
- if (leaks?.length) workerState.rpc.onAsyncLeaks(leaks);
92
- } else await traces.$(`vitest.test.runner.${method}.module`, { attributes: { "code.file.path": file.filepath } }, () => publicCollect([file], testRunner));
93
- // reset after tests, because user might call `vi.setConfig` in setupFile
94
- vi.resetConfig();
95
- // mocks should not affect different files
96
- vi.restoreAllMocks();
97
- }
98
- });
99
+ });
100
+ } finally {
101
+ offCancel();
102
+ }
99
103
  await traces.$("vitest.runtime.coverage.stop", () => stopCoverageInsideWorker(config.coverage, moduleRunner, { isolate: config.isolate }));
100
104
  }
101
105
 
@@ -114,7 +118,7 @@ async function startModuleRunner(options) {
114
118
  let mocker;
115
119
  if (options.state.config.experimental.nodeLoader !== false) {
116
120
  // this additionally imports acorn/magic-string
117
- const { NativeModuleMocker } = await import('./nativeModuleMocker.Uot80PXb.js');
121
+ const { NativeModuleMocker } = await import('./nativeModuleMocker.0CD1hdFV.js');
118
122
  mocker = new NativeModuleMocker({
119
123
  async resolveId(id, importer) {
120
124
  // TODO: use import.meta.resolve instead
@@ -131,7 +135,7 @@ async function startModuleRunner(options) {
131
135
  }
132
136
  // imported lazily (pulls in `local-pkg`) so it stays out of the default
133
137
  // worker startup graph; only the `viteModuleRunner: false` path needs it
134
- const { NativeModuleRunner } = await import('./nativeModuleRunner.BDnwGb8g.js').then(function (n) { return n.n; });
138
+ const { NativeModuleRunner } = await import('./nativeModuleRunner.Bc3kXpWn.js').then(function (n) { return n.n; });
135
139
  _moduleRunner = new NativeModuleRunner(root, mocker);
136
140
  return _moduleRunner;
137
141
  }
@@ -143,21 +147,12 @@ let _environmentTime;
143
147
  /** @experimental */
144
148
  async function setupBaseEnvironment(context) {
145
149
  if (context.config.experimental.viteModuleRunner === false) {
146
- const { setupNodeLoaderHooks } = await import('./native.BUCvPRKp.js');
150
+ const { setupNodeLoaderHooks } = await import('./native.offEPk9l.js');
147
151
  await setupNodeLoaderHooks(context);
148
152
  }
149
153
  const startTime = performance.now();
150
154
  const { environment: { name: environmentName, options: environmentOptions }, rpc, config } = context;
151
155
  setupEnv(config.env, context.metaEnv);
152
- // we could load @vite/env, but it would take ~8ms, while this takes ~0,02ms
153
- if (context.config.serializedDefines) try {
154
- runInThisContext(`(() =>{\n${context.config.serializedDefines}})()`, {
155
- lineOffset: 1,
156
- filename: "virtual:load-defines.js"
157
- });
158
- } catch (error) {
159
- throw new Error(`Failed to load custom "defines": ${error.message}`);
160
- }
161
156
  const otel = context.traces;
162
157
  const { environment, loader } = await loadEnvironment(environmentName, config.root, rpc, otel, context.config.experimental.viteModuleRunner);
163
158
  _currentEnvironment = environment;
@@ -181,6 +176,15 @@ async function runBaseTests(method, state, traces) {
181
176
  state.evaluatedModules = evaluatedModules;
182
177
  state.moduleExecutionInfo = moduleExecutionInfo;
183
178
  provideWorkerState(globalThis, state);
179
+ // we could load @vite/env, but it would take ~8ms, while this takes ~0,02ms
180
+ if (state.config.serializedDefines) try {
181
+ runInThisContext(`(() =>{\n${state.config.serializedDefines}})()`, {
182
+ lineOffset: 1,
183
+ filename: "virtual:load-defines.js"
184
+ });
185
+ } catch (error) {
186
+ throw new Error(`Failed to load custom "defines": ${error.message}`);
187
+ }
184
188
  if (ctx.invalidates) ctx.invalidates.forEach((filepath) => {
185
189
  (state.evaluatedModules.fileToModulesMap.get(filepath) || []).forEach((module) => {
186
190
  state.evaluatedModules.invalidateModule(module);
@@ -1,17 +1,6 @@
1
- import { be as FileSpecification } from './config.d.DsC1jkby.js';
2
- import { O as OTELCarrier } from './rpc.d.BeasqWpO.js';
3
- import { T as TestExecutionMethod } from './worker.d.s_RdeZtI.js';
4
-
5
- type SerializedTestSpecification = [project: {
6
- name: string | undefined;
7
- root: string;
8
- }, file: string, options: {
9
- pool: string;
10
- testLines?: number[] | undefined;
11
- testIds?: string[] | undefined;
12
- testNamePattern?: RegExp | undefined;
13
- testTagsFilter?: string[] | undefined;
14
- }];
1
+ import { F as FileSpecification } from './config.d.BpALOMjL.js';
2
+ import { O as OTELCarrier } from './rpc.d.DWQfGdI1.js';
3
+ import { T as TestExecutionMethod } from './worker.d.D7LKSMQN.js';
15
4
 
16
5
  interface ModuleDefinitionLocation {
17
6
  line: number;
@@ -52,6 +41,17 @@ interface SourceModuleDiagnostic {
52
41
  untrackedModules: UntrackedModuleDefinitionDiagnostic[];
53
42
  }
54
43
 
44
+ type SerializedTestSpecification = [project: {
45
+ name: string | undefined;
46
+ root: string;
47
+ }, file: string, options: {
48
+ pool: string;
49
+ testLines?: number[] | undefined;
50
+ testIds?: string[] | undefined;
51
+ testNamePattern?: RegExp | undefined;
52
+ testTagsFilter?: string[] | undefined;
53
+ }];
54
+
55
55
  interface BrowserTesterOptions {
56
56
  method: TestExecutionMethod;
57
57
  files: FileSpecification[];
@@ -1,4 +1,4 @@
1
- import { n as normalize, t as toArray } from './pathe.M-eThtNZ.CbK_Vbae.js';
1
+ import { n as normalize, t as toArray } from './pathe.M-eThtNZ.k2RS39sQ.js';
2
2
  import { EventEmitter } from 'events';
3
3
  import { m } from './tinyrainbow.Ht9iggcq.js';
4
4
  import { a as isForceColor } from './env.DzFJjrmK.js';
@@ -620,7 +620,7 @@ class CAC extends EventEmitter {
620
620
 
621
621
  const cac = (name = "") => new CAC(name);
622
622
 
623
- var version = "5.0.0-beta.7";
623
+ var version = "5.0.0-rc.1";
624
624
 
625
625
  const apiConfig = (port) => ({
626
626
  port: {
@@ -1128,6 +1128,7 @@ const cliOptionsConfig = {
1128
1128
  }
1129
1129
  },
1130
1130
  project: {
1131
+ shorthand: "p",
1131
1132
  description: "The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: `--project=1 --project=2`. You can also filter projects using wildcards like `--project=packages*`, and exclude projects with `--project=!pattern`.",
1132
1133
  argument: "<name>",
1133
1134
  array: true
@@ -1145,6 +1146,7 @@ const cliOptionsConfig = {
1145
1146
  argument: "",
1146
1147
  subcommands: { dir: null },
1147
1148
  default: true,
1149
+ // cache can only be "false" or an object
1148
1150
  transform(cache) {
1149
1151
  if (typeof cache !== "boolean" && cache) throw new Error("--cache.dir is deprecated");
1150
1152
  if (cache) return {};
@@ -1195,6 +1197,7 @@ const cliOptionsConfig = {
1195
1197
  description: "The directory where attachments from `context.annotate` are stored in (default: `.vitest/attachments`)",
1196
1198
  argument: "<dir>"
1197
1199
  },
1200
+ // CLI only options
1198
1201
  run: { description: "Disable watch mode" },
1199
1202
  color: {
1200
1203
  description: "Removes colors from the console output",
@@ -1225,6 +1228,7 @@ const cliOptionsConfig = {
1225
1228
  array: true
1226
1229
  },
1227
1230
  strictTags: { description: "Should Vitest throw an error if test has a tag that is not defined in the config. (default: `true`)" },
1231
+ sharedViteServer: { description: "Let inline projects that don't modify the Vite config reuse the Vite server of the config that declares them. (default: `true`)" },
1228
1232
  experimental: {
1229
1233
  description: "Experimental features.",
1230
1234
  argument: "<features>",
@@ -1274,9 +1278,20 @@ const cliOptionsConfig = {
1274
1278
  description: "Custom provider for detecting changed files. (default: `git`)",
1275
1279
  subcommands: null
1276
1280
  },
1277
- preParse: { description: "Parse test specifications before running them. This will apply `.only` flag and test name pattern across all files without running them. (default: `false`)" }
1281
+ preParse: { description: "Parse test specifications before running them. This will apply `.only` flag and test name pattern across all files without running them. (default: `false`)" },
1282
+ diagnostics: {
1283
+ description: "Print performance hints after the run when a configuration change would make it significantly faster. Hints never suggest changing options that were set explicitly. (default: `true`)",
1284
+ argument: "",
1285
+ subcommands: {
1286
+ isolate: { description: "Print a hint estimating how much time `isolate: false` would save when `isolate: true` spends a significant amount of time spawning a worker per test file. (default: `true`)" },
1287
+ environment: { description: "Print a hint when re-creating a DOM environment for every test file dominates the run and a `vm` pool would set it up once per worker. (default: `true`)" },
1288
+ import: { description: "Print a hint when test files repeatedly evaluate the same module graph (typical for barrel-file imports) and `isolate: false` would evaluate it once per worker. (default: `true`)" },
1289
+ transform: { description: "Print a hint when transforming modules dominates the run and `fsModuleCache` would persist the results across runs. (default: `true`)" }
1290
+ }
1291
+ }
1278
1292
  }
1279
1293
  },
1294
+ // disable CLI options
1280
1295
  cliExclude: null,
1281
1296
  server: null,
1282
1297
  setupFiles: null,
@@ -1333,7 +1348,7 @@ const collectCliOptionsConfig = {
1333
1348
  }
1334
1349
  };
1335
1350
 
1336
- const a={ShellCompDirectiveError:1,ShellCompDirectiveNoSpace:2,ShellCompDirectiveNoFileComp:4,ShellCompDirectiveFilterFileExt:8,ShellCompDirectiveFilterDirs:16,ShellCompDirectiveKeepOrder:32,ShellCompDirectiveDefault:0};var o$1=class o{name;variadic;command;handler;constructor(e,t,n,r=false){this.command=e,this.name=t,this.handler=n,this.variadic=r;}},s$1=class s{value;description;command;handler;alias;isBoolean;constructor(e,t,n,r,i,a){this.command=e,this.value=t,this.description=n,this.handler=r,this.alias=i,this.isBoolean=a;}},c$1=class c{value;description;options=new Map;arguments=new Map;parent;constructor(e,t){this.value=e,this.description=t;}option(e,t,n,r){let i,a,o;typeof n==`function`?(i=n,a=r,o=false):typeof n==`string`?(i=void 0,a=n,o=true):(i=void 0,a=void 0,o=true);let c=new s$1(this,e,t,i,a,o);return this.options.set(e,c),this}argument(e,t,n=false){let r=new o$1(this,e,t,n);return this.arguments.set(e,r),this}},l$1=class l extends c$1{commands=new Map;completions=[];directive=a.ShellCompDirectiveDefault;constructor(){super(``,``);}command(e,t){let n=new c$1(e,t);return this.commands.set(e,n),n}stripOptions(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.startsWith(`-`)){n++;let t=false,i=this.findOption(this,r);if(i)t=i.isBoolean??false;else for(let[,e]of this.commands){let n=this.findOption(e,r);if(n){t=n.isBoolean??false;break}}!t&&n<e.length&&!e[n].startsWith(`-`)&&n++;}else t.push(r),n++;}return t}matchCommand(e){e=this.stripOptions(e);let t=[],n=[],r=null;for(let i=0;i<e.length;i++){let a=e[i];t.push(a);let o=this.commands.get(t.join(` `));if(o)r=o;else {n=e.slice(i,e.length);break}}return [r||this,n]}shouldCompleteFlags(e,t){if(t.startsWith(`-`))return true;if(e?.startsWith(`-`)){let t=this.findOption(this,e);if(!t){for(let[,n]of this.commands)if(t=this.findOption(n,e),t)break}return !(t&&t.isBoolean)}return false}shouldCompleteCommands(e){return !e.startsWith(`-`)}handleFlagCompletion(e,t,n,r){let i;if(n.includes(`=`)){let[e]=n.split(`=`);i=e;}else if(r?.startsWith(`-`)){let t=this.findOption(e,r);t&&!t.isBoolean&&(i=r);}if(i){let t=this.findOption(e,i);if(t?.handler){let n=[];t.handler.call(t,(e,t)=>n.push({value:e,description:t}),e.options),this.completions=n;}return}if(n.startsWith(`-`)){let t=n.startsWith(`-`)&&!n.startsWith(`--`),r=n.replace(/^-+/,``);for(let[i,a]of e.options)t&&a.alias&&`-${a.alias}`.startsWith(n)?this.completions.push({value:`-${a.alias}`,description:a.description}):!t&&i.startsWith(r)&&this.completions.push({value:`--${i}`,description:a.description});}}findOption(e,t){let n=e.options.get(t);if(n||(n=e.options.get(t.replace(/^-+/,``)),n))return n;for(let[n,r]of e.options)if(r.alias&&`-${r.alias}`===t)return r}handleCommandCompletion(e,t){let n=this.stripOptions(e);for(let[e,r]of this.commands){if(e===``)continue;let i=e.split(` `);i.slice(0,n.length).every((e,t)=>e===n[t])&&i[n.length]?.startsWith(t)&&this.completions.push({value:i[n.length],description:r.description});}}handlePositionalCompletion(e,t){let n=e.value.split(` `).length,r=Math.max(0,t.length-n),i=Array.from(e.arguments.entries());if(i.length>0){let t;if(r<i.length){let[e,n]=i[r];t=n;}else {let e=i[i.length-1][1];e.variadic&&(t=e);}if(t&&t.handler&&typeof t.handler==`function`){let n=[];t.handler.call(t,(e,t)=>n.push({value:e,description:t}),e.options),this.completions.push(...n);}}}complete(e){this.directive=a.ShellCompDirectiveNoFileComp;let t=new Set;this.completions.filter(e=>t.has(e.value)?false:(t.add(e.value),true)).filter(t=>{if(e.includes(`=`)){let[,n]=e.split(`=`);return t.value.startsWith(n)}return t.value.startsWith(e)}).forEach(e=>console.log(`${e.value}\t${e.description??``}`)),console.log(`:${this.directive}`);}parse(e){this.completions=[];let t=e[e.length-1]===``;t&&e.pop();let n=e[e.length-1]||``,r=e.slice(0,-1);t&&(n!==``&&r.push(n),n=``);let[i]=this.matchCommand(r),a=r[r.length-1];if(this.shouldCompleteFlags(a,n))this.handleFlagCompletion(i,r,n,a);else {if(a?.startsWith(`-`)&&n===``&&t){let e=this.findOption(this,a);if(!e){for(let[,t]of this.commands)if(e=this.findOption(t,a),e)break}if(e&&e.isBoolean){this.complete(n);return}}this.shouldCompleteCommands(n)&&this.handleCommandCompletion(r,n),i&&i.arguments.size>0&&this.handlePositionalCompletion(i,r);}this.complete(n);}setup(a,o,s){switch(assert(s===`zsh`||s===`bash`||s===`fish`||s===`powershell`,`Unsupported shell`),s){case `zsh`:{let t$1=t(a,o);console.log(t$1);break}case `bash`:{let e=n(a,o);console.log(e);break}case `fish`:{let e=r(a,o);console.log(e);break}case `powershell`:{let e=i(a,o);console.log(e);break}}}};const u$1=new l$1;
1351
+ const a={ShellCompDirectiveError:1,ShellCompDirectiveNoSpace:2,ShellCompDirectiveNoFileComp:4,ShellCompDirectiveFilterFileExt:8,ShellCompDirectiveFilterDirs:16,ShellCompDirectiveKeepOrder:32,ShellCompDirectiveDefault:0};var o$1=class o{name;variadic;command;handler;constructor(e,t,n,r=false){this.command=e,this.name=t,this.handler=n,this.variadic=r;}},s$1=class s{value;description;command;handler;alias;isBoolean;constructor(e,t,n,r,i,a){this.command=e,this.value=t,this.description=n,this.handler=r,this.alias=i,this.isBoolean=a;}},c$1=class c{value;description;options=new Map;arguments=new Map;parent;constructor(e,t){this.value=e,this.description=t;}option(e,t,n,r){let i,a,o;typeof n==`function`?(i=n,a=r,o=false):typeof n==`string`?(i=void 0,a=n,o=true):(i=void 0,a=void 0,o=true);let c=new s$1(this,e,t,i,a,o);return this.options.set(e,c),this}argument(e,t,n=false){let r=new o$1(this,e,t,n);return this.arguments.set(e,r),this}},l$1=class l extends c$1{commands=new Map;completions=[];directive=a.ShellCompDirectiveDefault;constructor(){super(``,``);}command(e,t){let n=new c$1(e,t);return this.commands.set(e,n),n}stripOptions(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.startsWith(`-`)){n++;let t=false,i=this.findOption(this,r);if(i)t=i.isBoolean??false;else for(let[,e]of this.commands){let n=this.findOption(e,r);if(n){t=n.isBoolean??false;break}}!t&&n<e.length&&!e[n].startsWith(`-`)&&n++;}else t.push(r),n++;}return t}matchCommand(e){e=this.stripOptions(e);let t=[],n=[],r=null;for(let i=0;i<e.length;i++){let a=e[i];t.push(a);let o=this.commands.get(t.join(` `));if(o)r=o;else {n=e.slice(i,e.length);break}}return [r||this,n]}shouldCompleteFlags(e,t){if(t.startsWith(`-`))return true;if(e?.startsWith(`-`)){let t=this.findOption(this,e);if(!t){for(let[,n]of this.commands)if(t=this.findOption(n,e),t)break}return !(t&&t.isBoolean)}return false}shouldCompleteCommands(e){return !e.startsWith(`-`)}handleFlagCompletion(e,t,n,r){let i;if(n.includes(`=`)){let[e]=n.split(`=`);i=e;}else if(r?.startsWith(`-`)){let t=this.findOption(e,r);t&&!t.isBoolean&&(i=r);}if(i){let t=this.findOption(e,i);if(t?.handler){let n=[];t.handler.call(t,(e,t)=>n.push({value:e,description:t}),e.options),this.completions=n;}return}if(n.startsWith(`-`)){let t=n.startsWith(`-`)&&!n.startsWith(`--`),r=n.replace(/^-+/,``);for(let[i,a]of e.options)t&&a.alias&&`-${a.alias}`.startsWith(n)?this.completions.push({value:`-${a.alias}`,description:a.description}):!t&&i.startsWith(r)&&this.completions.push({value:`--${i}`,description:a.description});}}findOption(e,t){let n=e.options.get(t);if(n||(n=e.options.get(t.replace(/^-+/,``)),n))return n;for(let[n,r]of e.options)if(r.alias&&`-${r.alias}`===t)return r}handleCommandCompletion(e,t){let n=this.stripOptions(e);for(let[e,r]of this.commands){if(e===``)continue;let i=e.split(` `);i.slice(0,n.length).every((e,t)=>e===n[t])&&i[n.length]?.startsWith(t)&&this.completions.push({value:i[n.length],description:r.description});}}handlePositionalCompletion(e,t){let n=this.stripOptions(t),r=e.value.split(` `).length,i=Math.max(0,n.length-r),a=Array.from(e.arguments.entries());if(a.length>0){let t;if(i<a.length){let[e,n]=a[i];t=n;}else {let e=a[a.length-1][1];e.variadic&&(t=e);}if(t&&t.handler&&typeof t.handler==`function`){let n=[];t.handler.call(t,(e,t)=>n.push({value:e,description:t}),e.options),this.completions.push(...n);}}}complete(e){this.directive=a.ShellCompDirectiveNoFileComp;let t=new Set;this.completions.filter(e=>t.has(e.value)?false:(t.add(e.value),true)).filter(t=>{if(e.includes(`=`)){let[,n]=e.split(`=`);return t.value.startsWith(n)}return t.value.startsWith(e)}).forEach(e=>console.log(`${e.value}\t${e.description??``}`)),console.log(`:${this.directive}`);}parse(e){this.completions=[];let t=e[e.length-1]===``;t&&e.pop();let n=e[e.length-1]||``,r=e.slice(0,-1);t&&(n!==``&&r.push(n),n=``);let[i]=this.matchCommand(r),a=r[r.length-1];this.shouldCompleteFlags(a,n)?this.handleFlagCompletion(i,r,n,a):(this.shouldCompleteCommands(n)&&this.handleCommandCompletion(r,n),i&&i.arguments.size>0&&this.handlePositionalCompletion(i,r)),this.complete(n);}setup(a,o,s){switch(assert(s===`zsh`||s===`bash`||s===`fish`||s===`powershell`,`Unsupported shell`),s){case `zsh`:{let t$1=t(a,o);console.log(t$1);break}case `bash`:{let e=n(a,o);console.log(e);break}case `fish`:{let e=r(a,o);console.log(e);break}case `powershell`:{let e=i(a,o);console.log(e);break}}}};const u=new l$1;
1337
1352
 
1338
1353
  function t(t,n){return `#compdef ${t}
1339
1354
  compdef _${t} ${t}
@@ -1382,7 +1397,7 @@ _${t}() {
1382
1397
 
1383
1398
  # Prepare the command to obtain completions, ensuring arguments are quoted for eval
1384
1399
  local -a args_to_quote=("\${(@)words[2,-1]}")
1385
- if [ "\${lastChar}" = "" ]; then
1400
+ if [ "\${lastChar}" = "" ] && [ "\${args_to_quote[-1]}" != "" ]; then
1386
1401
  # If the last parameter is complete (there is a space following it)
1387
1402
  # We add an extra empty parameter so we can indicate this to the go completion code.
1388
1403
  __${t}_debug "Adding extra empty parameter"
@@ -1664,17 +1679,15 @@ function __${r}_perform_completion
1664
1679
 
1665
1680
  # Extract all args except the last one
1666
1681
  set -l args (commandline -opc)
1667
- # Extract the last arg and escape it in case it is a space or wildcard
1668
- set -l lastArg (string escape -- (commandline -ct))
1682
+ # Extract the token currently being completed (may be empty on a trailing space)
1683
+ set -l lastArg (commandline -ct)
1669
1684
 
1670
1685
  __${r}_debug "args: $args"
1671
1686
  __${r}_debug "last arg: $lastArg"
1672
1687
 
1673
- # Build the completion request command
1674
- set -l requestComp "${n} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg"
1675
-
1676
- __${r}_debug "Calling $requestComp"
1677
- set -l results (eval $requestComp 2> /dev/null)
1688
+ # Pass each arg as its own token (no string join/eval, which would collapse multi-segment paths); quote "$lastArg" so an empty trailing token is still sent.
1689
+ __${r}_debug "Calling ${n} complete -- $args[2..-1] $lastArg"
1690
+ set -l results (${n} complete -- $args[2..-1] "$lastArg" 2> /dev/null)
1678
1691
 
1679
1692
  # Some programs may output extra empty lines after the directive.
1680
1693
  # Let's ignore them or else it will break completion.
@@ -1955,8 +1968,10 @@ complete -k -c ${t} -n '__${r}_requires_order_preservation && __${r}_prepare_com
1955
1968
  # Remove the flag part
1956
1969
  $Flag, $WordToComplete = $WordToComplete.Split("=", 2)
1957
1970
  }
1958
-
1959
- if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag )) {
1971
+ $HasTrailingEmptyArg = $QuotedArgs -match "(^| )''$"
1972
+ __${t}_debug "HasTrailingEmptyArg: $HasTrailingEmptyArg"
1973
+
1974
+ if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag ) -And ( -Not $HasTrailingEmptyArg )) {
1960
1975
  # If the last parameter is complete (there is a space following it)
1961
1976
  # We add an extra empty parameter so we can indicate this to the go method.
1962
1977
  __${t}_debug "Adding extra empty parameter"
@@ -2136,10 +2151,10 @@ Register-ArgumentCompleter -CommandName '${t}' -ScriptBlock $__${r}CompleterBloc
2136
2151
 
2137
2152
  function e(e=`cli`){if(process.argv.indexOf(`--`)===-1){let t=`Error: You need to use -- to separate completion arguments.\nExample: ${e} complete -- <args>`;console.error(t),process.exit(1);}}
2138
2153
 
2139
- const o=process.execPath,s=process.argv.slice(1),c=f(o),l=s.map(f),u=`${c} ${process.execArgv.map(f).join(` `)} ${l[0]}`,d=/<[^>]+>|\[[^\]]+\]/;function f(e){return e.includes(` `)?`'${e}'`:e}async function p(c,l){for(let e of [c.globalCommand,...c.commands]){if(e.name===`complete`)continue;let t=(e.rawName.match(/\[.*?\]|<.*?>/g)||[]).map(e=>e.startsWith(`[`)),n=e.name===`@@global@@`,r=n?l:l?.subCommands?.[e.name],a=n?``:e.name,o=n?u$1:u$1.command(a,e.description||``);if(o){let n=(e.rawName.match(/<([^>]+)>|\[\.\.\.([^\]]+)\]/g)||[]).map(e=>e.startsWith(`<`)&&e.endsWith(`>`)?e.slice(1,-1):e.startsWith(`[...`)&&e.endsWith(`]`)?e.slice(4,-1):e);t.forEach((e,t)=>{let i=n[t]||`arg${t}`,a=r?.args?.[i];a?o.argument(i,a,e):o.argument(i,void 0,e);});}for(let t of [...c.globalCommand.options,...e.options]){let e=t.rawName.match(/^-([a-zA-Z]), --/)?.[1],a=t.name,s=n?u$1:o;if(s){let n=r?.options?.[a],i=t.required||d.test(t.rawName);n?e?s.option(a,t.description||``,n,e):s.option(a,t.description||``,n):i?e?s.option(a,t.description||``,async()=>[],e):s.option(a,t.description||``,async()=>[]):e?s.option(a,t.description||``,e):s.option(a,t.description||``);}}}return c.command(`complete [shell]`).action(async(l,d)=>{switch(l){case `zsh`:{let t$1=t(c.name,u);console.log(t$1);break}case `bash`:{let e=n(c.name,u);console.log(e);break}case `fish`:{let e=r(c.name,u);console.log(e);break}case `powershell`:{let e=i(c.name,u);console.log(e);break}default:{e(c.name);let e$1=d[`--`]||[];return c.showHelpOnExit=false,c.unsetMatchedCommand(),c.parse([o,s[0],...e$1],{run:false}),u$1.parse(e$1)}}}),u$1}
2154
+ const o=process.execPath,s=process.argv.slice(1),c=/<[^>]+>|\[[^\]]+\]/;async function l(l,u$1){for(let e of [l.globalCommand,...l.commands]){if(e.name===`complete`)continue;let t=(e.rawName.match(/\[.*?\]|<.*?>/g)||[]).map(e=>e.startsWith(`[`)),n=e.name===`@@global@@`,r=n?u$1:u$1?.subCommands?.[e.name],a=n?``:e.name,o=n?u:u.command(a,e.description||``);if(o){let n=(e.rawName.match(/<([^>]+)>|\[\.\.\.([^\]]+)\]/g)||[]).map(e=>e.startsWith(`<`)&&e.endsWith(`>`)?e.slice(1,-1):e.startsWith(`[...`)&&e.endsWith(`]`)?e.slice(4,-1):e);t.forEach((e,t)=>{let i=n[t]||`arg${t}`,a=r?.args?.[i];a?o.argument(i,a,e):o.argument(i,void 0,e);});}for(let t of [...l.globalCommand.options,...e.options]){let e=t.rawName.match(/^-([a-zA-Z]), --/)?.[1],a=t.name,s=n?u:o;if(s){let n=r?.options?.[a],i=t.required||c.test(t.rawName);n?e?s.option(a,t.description||``,n,e):s.option(a,t.description||``,n):i?e?s.option(a,t.description||``,async()=>[],e):s.option(a,t.description||``,async()=>[]):e?s.option(a,t.description||``,e):s.option(a,t.description||``);}}}return l.command(`complete [shell]`).action(async(c,u$1)=>{let d=l.name;switch(c){case `zsh`:{let t$1=t(l.name,d);console.log(t$1);break}case `bash`:{let e=n(l.name,d);console.log(e);break}case `fish`:{let e=r(l.name,d);console.log(e);break}case `powershell`:{let e=i(l.name,d);console.log(e);break}default:{e(l.name);let e$1=u$1[`--`]||[];return l.showHelpOnExit=false,l.unsetMatchedCommand(),l.parse([o,s[0],...e$1],{run:false}),u.parse(e$1)}}}),u}
2140
2155
 
2141
2156
  async function setupTabCompletions(cli) {
2142
- await p(cli, {
2157
+ await l(cli, {
2143
2158
  subCommands: {},
2144
2159
  options: {
2145
2160
  environment(complete) {
@@ -2273,6 +2288,7 @@ function createCLI(options = {}) {
2273
2288
  cli.command("dev [...filters]", void 0, options).action(watch);
2274
2289
  cli.command("bench [...filters]", void 0, options).action(benchmark);
2275
2290
  cli.command("init <project>", void 0, options).action(init);
2291
+ cli.command("doctor [...filters]", void 0, options).action(doctorCommand);
2276
2292
  addCliOptions(cli.command("list [...filters]", void 0, options).action((filters, options) => collect(filters, options)), collectCliOptionsConfig);
2277
2293
  cli.command("[...filters]", void 0, options).action((filters, options) => start(filters, options));
2278
2294
  setupTabCompletions(cli);
@@ -2347,11 +2363,11 @@ function normalizeCliOptions(cliFilters, argv) {
2347
2363
  }
2348
2364
  async function start(cliFilters, options) {
2349
2365
  try {
2350
- const { startVitest } = await import('./cli-api.bqNN5viV.js').then(function (n) { return n.a; });
2366
+ const { startVitest } = await import('./cli-api.B4r6twmv.js').then(function (n) { return n.a; });
2351
2367
  const ctx = await startVitest(cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
2352
2368
  if (!ctx.shouldKeepServer()) await ctx.exit();
2353
2369
  } catch (e) {
2354
- const { errorBanner } = await import('./utils.CO-iLyCr.js').then(function (n) { return n.u; });
2370
+ const { errorBanner } = await import('./utils.DtdLoSPT.js').then(function (n) { return n.u; });
2355
2371
  console.error(`\n${errorBanner("Startup Error")}`);
2356
2372
  console.error(e);
2357
2373
  console.error("\n\n");
@@ -2359,17 +2375,31 @@ async function start(cliFilters, options) {
2359
2375
  process.exit();
2360
2376
  }
2361
2377
  }
2378
+ async function doctorCommand(cliFilters, options) {
2379
+ try {
2380
+ const { doctor } = await import('./doctor.oxixVMjH.js');
2381
+ await doctor(cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
2382
+ process.exit();
2383
+ } catch (e) {
2384
+ const { errorBanner } = await import('./utils.DtdLoSPT.js').then(function (n) { return n.u; });
2385
+ console.error(`\n${errorBanner("Doctor Error")}`);
2386
+ console.error(e);
2387
+ console.error("\n\n");
2388
+ process.exitCode ??= 1;
2389
+ process.exit();
2390
+ }
2391
+ }
2362
2392
  async function init(project) {
2363
2393
  if (project !== "browser") {
2364
2394
  console.error(/* @__PURE__ */ new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project."));
2365
2395
  process.exit(1);
2366
2396
  }
2367
- const { create } = await import('./creator.BzMFaPC-.js');
2397
+ const { create } = await import('./creator.BW8mSwbG.js');
2368
2398
  await create();
2369
2399
  }
2370
2400
  async function collect(cliFilters, options) {
2371
2401
  try {
2372
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.bqNN5viV.js').then(function (n) { return n.a; });
2402
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.B4r6twmv.js').then(function (n) { return n.a; });
2373
2403
  const ctx = await prepareVitest({
2374
2404
  ...normalizeCliOptions(cliFilters, options),
2375
2405
  watch: false,
@@ -2391,7 +2421,7 @@ async function collect(cliFilters, options) {
2391
2421
  } else outputFileList(await ctx.getRelevantTestSpecifications(cliFilters.map(normalize)), options);
2392
2422
  await ctx.close();
2393
2423
  } catch (e) {
2394
- const { errorBanner } = await import('./utils.CO-iLyCr.js').then(function (n) { return n.u; });
2424
+ const { errorBanner } = await import('./utils.DtdLoSPT.js').then(function (n) { return n.u; });
2395
2425
  console.error(`\n${errorBanner("Collect Error")}`);
2396
2426
  console.error(e);
2397
2427
  console.error("\n\n");