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

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.C1WTaPOM.js} +49 -44
  6. package/dist/chunks/{browser.d.BFOby8YL.d.ts → browser.d.C9OF2Et_.d.ts} +14 -14
  7. package/dist/chunks/{cac.B41kXwyU.js → cac.D09XQ6pO.js} +51 -21
  8. package/dist/chunks/{cli-api.bqNN5viV.js → cli-api.te-1Pvjs.js} +38 -29
  9. package/dist/chunks/{config.d.DsC1jkby.d.ts → config.d.CU_b-wJj.d.ts} +160 -138
  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.Cqwo9lsW.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.CNpBUniZ.js +465 -0
  17. package/dist/chunks/{environment.d.4-rzQgpt.d.ts → environment.d.C0fjmVGG.d.ts} +1 -1
  18. package/dist/chunks/{globals.sd6Qutmc.js → globals.C5MA6F-b.js} +11 -11
  19. package/dist/chunks/{index.CLtI1k_4.js → index.BH4BaN4R.js} +7518 -7384
  20. package/dist/chunks/{index.DxR-nMjO.js → index.BfU4rh_M.js} +68 -30
  21. package/dist/chunks/{index.JaztIWgW.js → index.C0qliBI-.js} +6 -6
  22. package/dist/chunks/{index.Chj8NDwU.js → index.CCh1Pb8k.js} +6 -12
  23. package/dist/chunks/{index.CMESou6r.js → index.DXQx-kDM.js} +77 -81
  24. package/dist/chunks/{index.5krd73UD.js → index.DzzDnMj8.js} +2050 -792
  25. package/dist/chunks/{index.DzTmMrSM.js → index.M2dsQ_UQ.js} +8 -4
  26. package/dist/chunks/{init-forks.CXzT841o.js → init-forks.Bo2g6tWs.js} +7 -10
  27. package/dist/chunks/{init-threads.Ch-Bw5j3.js → init-threads.BSTHIk3P.js} +1 -1
  28. package/dist/chunks/{init.CfiYZpFg.js → init.i_K8EJrW.js} +40 -12
  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.CNqvINDS.d.ts} +151 -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.DA9Utv4e.d.ts} +1 -1
  39. package/dist/chunks/{artifact.DC5WoEgy.js → run.COOMV-72.js} +265 -223
  40. package/dist/chunks/{setup-common.vxjAyUtK.js → setup-common.AcXJaDWq.js} +3 -3
  41. package/dist/chunks/{setup.DasACXvo.js → setup.CBDqPUzi.js} +52 -56
  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.YqWNcp4e.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.BZm4GSQD.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.FXMbMqlj.js} +466 -87
  48. package/dist/chunks/{worker.d.s_RdeZtI.d.ts → worker.d.XSpk7g5N.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 +13 -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 +22 -15
  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.CU_b-wJj.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.CU_b-wJj.js';
5
+ import { R as RuntimeCoverageModuleLoader } from './chunks/source-map.d.YqWNcp4e.js';
6
+ export { D as DecodedMap, g as getOriginalPosition } from './chunks/source-map.d.YqWNcp4e.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.COOMV-72.js';
3
+ export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as setupEnv } from './chunks/setup-common.AcXJaDWq.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.C0qliBI-.js';
4
+ import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.i_K8EJrW.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.BH4BaN4R.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.COOMV-72.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.AcXJaDWq.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
 
@@ -104,17 +108,18 @@ const evaluatedModules = new VitestEvaluatedModules();
104
108
  const moduleExecutionInfo = /* @__PURE__ */ new Map();
105
109
  async function startModuleRunner(options) {
106
110
  if (_moduleRunner) return _moduleRunner;
111
+ const state = () => getSafeWorkerState() || options.state;
107
112
  process.exit = (code = process.exitCode || 0) => {
108
- throw new Error(`process.exit unexpectedly called with "${code}"`);
113
+ const filepath = state().filepath;
114
+ throw new Error(`process.exit unexpectedly called with "${code}"${filepath ? ` (test file: ${filepath})` : ""}`);
109
115
  };
110
- const state = () => getSafeWorkerState() || options.state;
111
116
  listenForErrors(state);
112
117
  if (options.state.config.experimental.viteModuleRunner === false) {
113
118
  const root = options.state.config.root;
114
119
  let mocker;
115
120
  if (options.state.config.experimental.nodeLoader !== false) {
116
121
  // this additionally imports acorn/magic-string
117
- const { NativeModuleMocker } = await import('./nativeModuleMocker.Uot80PXb.js');
122
+ const { NativeModuleMocker } = await import('./nativeModuleMocker.0CD1hdFV.js');
118
123
  mocker = new NativeModuleMocker({
119
124
  async resolveId(id, importer) {
120
125
  // TODO: use import.meta.resolve instead
@@ -131,7 +136,7 @@ async function startModuleRunner(options) {
131
136
  }
132
137
  // imported lazily (pulls in `local-pkg`) so it stays out of the default
133
138
  // worker startup graph; only the `viteModuleRunner: false` path needs it
134
- const { NativeModuleRunner } = await import('./nativeModuleRunner.BDnwGb8g.js').then(function (n) { return n.n; });
139
+ const { NativeModuleRunner } = await import('./nativeModuleRunner.Bc3kXpWn.js').then(function (n) { return n.n; });
135
140
  _moduleRunner = new NativeModuleRunner(root, mocker);
136
141
  return _moduleRunner;
137
142
  }
@@ -143,21 +148,12 @@ let _environmentTime;
143
148
  /** @experimental */
144
149
  async function setupBaseEnvironment(context) {
145
150
  if (context.config.experimental.viteModuleRunner === false) {
146
- const { setupNodeLoaderHooks } = await import('./native.BUCvPRKp.js');
151
+ const { setupNodeLoaderHooks } = await import('./native.offEPk9l.js');
147
152
  await setupNodeLoaderHooks(context);
148
153
  }
149
154
  const startTime = performance.now();
150
155
  const { environment: { name: environmentName, options: environmentOptions }, rpc, config } = context;
151
156
  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
157
  const otel = context.traces;
162
158
  const { environment, loader } = await loadEnvironment(environmentName, config.root, rpc, otel, context.config.experimental.viteModuleRunner);
163
159
  _currentEnvironment = environment;
@@ -181,6 +177,15 @@ async function runBaseTests(method, state, traces) {
181
177
  state.evaluatedModules = evaluatedModules;
182
178
  state.moduleExecutionInfo = moduleExecutionInfo;
183
179
  provideWorkerState(globalThis, state);
180
+ // we could load @vite/env, but it would take ~8ms, while this takes ~0,02ms
181
+ if (state.config.serializedDefines) try {
182
+ runInThisContext(`(() =>{\n${state.config.serializedDefines}})()`, {
183
+ lineOffset: 1,
184
+ filename: "virtual:load-defines.js"
185
+ });
186
+ } catch (error) {
187
+ throw new Error(`Failed to load custom "defines": ${error.message}`);
188
+ }
184
189
  if (ctx.invalidates) ctx.invalidates.forEach((filepath) => {
185
190
  (state.evaluatedModules.fileToModulesMap.get(filepath) || []).forEach((module) => {
186
191
  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.CU_b-wJj.js';
2
+ import { O as OTELCarrier } from './rpc.d.DA9Utv4e.js';
3
+ import { T as TestExecutionMethod } from './worker.d.XSpk7g5N.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[];