vitest 2.0.4 → 2.0.5

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 (77) hide show
  1. package/dist/browser.d.ts +21 -42
  2. package/dist/browser.js +5 -5
  3. package/dist/{vendor/base.Csk7BT3h.js → chunks/base.CC5R_kgU.js} +3 -3
  4. package/dist/{vendor/base.DRHPZCCj.js → chunks/base.DSsbfkDg.js} +1 -1
  5. package/dist/{vendor/benchmark.B6pblCp2.js → chunks/benchmark.DDmpNjj-.js} +1 -1
  6. package/dist/chunks/benchmark.puBFxyfE.d.ts +22 -0
  7. package/dist/{vendor/cac.DFtWvZc2.js → chunks/cac.DGgmCKmU.js} +17 -20
  8. package/dist/{vendor/cli-api.CTkP2Ier.js → chunks/cli-api.OKfd3qJ0.js} +416 -423
  9. package/dist/chunks/config.DCnyCTbs.d.ts +203 -0
  10. package/dist/chunks/{runtime-console.C2L2zykk.js → console.Bgn7_A1x.js} +11 -14
  11. package/dist/{vendor/constants.CsnA4eRy.js → chunks/constants.CaAN7icJ.js} +1 -3
  12. package/dist/{vendor/coverage.BhYSDdTT.js → chunks/coverage.CqfT4xaf.js} +4 -7
  13. package/dist/chunks/{browser-creator.CyaOd8pl.js → creator.a3OfuIEW.js} +8 -8
  14. package/dist/{vendor/env.2ltrQNq0.js → chunks/env.BU041cs9.js} +2 -3
  15. package/dist/chunks/environment.0M5R1SX_.d.ts +173 -0
  16. package/dist/{vendor/execute.jzOWtys_.js → chunks/execute.Cjlr2CRw.js} +27 -19
  17. package/dist/chunks/globals.BliuJFNR.js +31 -0
  18. package/dist/{vendor/index.DI9daj1Q.js → chunks/index.BfeNhc0N.js} +43 -43
  19. package/dist/{vendor/index.D6GZqexG.js → chunks/index.CM5UI-4O.js} +2 -2
  20. package/dist/{vendor/index.BJmtb_7W.js → chunks/index.DYufA6CZ.js} +2 -2
  21. package/dist/{vendor/index.CuuL9y4g.js → chunks/index.JbiJutJ_.js} +515 -255
  22. package/dist/{vendor/index.CVqMv71L.js → chunks/index.R1VjssW9.js} +11 -12
  23. package/dist/{vendor/index.D4nqnQWz.js → chunks/index.lVXYBqEP.js} +1 -18
  24. package/dist/{vendor/inspector.-FCQUzqR.js → chunks/inspector.70d6emsh.js} +4 -5
  25. package/dist/chunks/{environments-node.XE5FbRPQ.js → node.DS3zEPa7.js} +2 -2
  26. package/dist/{reporters-B7ebVMkT.d.ts → chunks/reporters.C_zwCd4j.d.ts} +847 -1000
  27. package/dist/{vendor/rpc.BGx7q_k2.js → chunks/rpc.B7Mfb-Yf.js} +3 -5
  28. package/dist/{vendor/run-once.Db8Hgq9X.js → chunks/run-once.Sxe67Wng.js} +1 -1
  29. package/dist/chunks/{runtime-runBaseTests.Dq_sJZq9.js → runBaseTests.CyvqmuC9.js} +21 -23
  30. package/dist/{vendor/setup-common.symvFZPh.js → chunks/setup-common.CNzatKMx.js} +2 -2
  31. package/dist/{suite-CRLAhsm0.d.ts → chunks/suite.CcK46U-P.d.ts} +1 -1
  32. package/dist/{vendor/tasks.DhVtQBtW.js → chunks/tasks.BZnCS9aT.js} +2 -3
  33. package/dist/{vendor/utils.DkxLWvS1.js → chunks/utils.C3_cBsyn.js} +3 -4
  34. package/dist/{vendor/global.7bFbnyXl.js → chunks/utils.Ck2hJTRs.js} +1 -1
  35. package/dist/{vendor/utils.BySfPUwy.js → chunks/utils.DpP_sDwr.js} +8 -21
  36. package/dist/{vendor/vi.Elqer9-7.js → chunks/vi.fiQ7lMRF.js} +13 -18
  37. package/dist/{vendor/vm.img-AOox.js → chunks/vm.DcSuuaHr.js} +40 -68
  38. package/dist/chunks/worker.C5iHKIaJ.d.ts +144 -0
  39. package/dist/chunks/worker.DKkAC4Qw.d.ts +8 -0
  40. package/dist/cli.js +3 -3
  41. package/dist/config.cjs +6 -8
  42. package/dist/config.d.ts +10 -8
  43. package/dist/config.js +6 -8
  44. package/dist/coverage.d.ts +10 -8
  45. package/dist/coverage.js +2 -2
  46. package/dist/environments.d.ts +3 -19
  47. package/dist/environments.js +1 -1
  48. package/dist/execute.d.ts +5 -14
  49. package/dist/execute.js +2 -2
  50. package/dist/index.d.ts +267 -34
  51. package/dist/index.js +12 -12
  52. package/dist/node.d.ts +15 -9
  53. package/dist/node.js +16 -19
  54. package/dist/reporters.d.ts +10 -8
  55. package/dist/reporters.js +12 -15
  56. package/dist/runners.d.ts +7 -19
  57. package/dist/runners.js +12 -13
  58. package/dist/snapshot.js +3 -3
  59. package/dist/suite.d.ts +2 -16
  60. package/dist/suite.js +4 -4
  61. package/dist/worker.js +7 -8
  62. package/dist/workers/forks.js +5 -5
  63. package/dist/workers/runVmTests.js +18 -19
  64. package/dist/workers/threads.js +5 -5
  65. package/dist/workers/vmForks.js +8 -8
  66. package/dist/workers/vmThreads.js +8 -8
  67. package/dist/workers.d.ts +13 -8
  68. package/dist/workers.js +13 -13
  69. package/package.json +13 -13
  70. package/dist/chunks/integrations-globals.nDMtdOcn.js +0 -31
  71. /package/dist/{vendor → chunks}/_commonjsHelpers.BFTU3MAI.js +0 -0
  72. /package/dist/{vendor → chunks}/date.W2xKR2qe.js +0 -0
  73. /package/dist/chunks/{node-git.ZtkbKc8u.js → git.ZtkbKc8u.js} +0 -0
  74. /package/dist/{vendor → chunks}/index.BMmMjLIQ.js +0 -0
  75. /package/dist/{vendor → chunks}/index.BpSiYbpB.js +0 -0
  76. /package/dist/chunks/{install-pkg.DNUmWFkO.js → index.DNUmWFkO.js} +0 -0
  77. /package/dist/{vendor → chunks}/spy.Cf_4R5Oe.js +0 -0
@@ -1,16 +1,15 @@
1
1
  import { getSafeTimers } from '@vitest/utils';
2
2
  import { c as createBirpc } from './index.BpSiYbpB.js';
3
- import { g as getWorkerState } from './global.7bFbnyXl.js';
3
+ import { g as getWorkerState } from './utils.Ck2hJTRs.js';
4
4
 
5
5
  const { get } = Reflect;
6
6
  function withSafeTimers(fn) {
7
- var _a;
8
7
  const { setTimeout, clearTimeout, nextTick, setImmediate, clearImmediate } = getSafeTimers();
9
8
  const currentSetTimeout = globalThis.setTimeout;
10
9
  const currentClearTimeout = globalThis.clearTimeout;
11
10
  const currentSetImmediate = globalThis.setImmediate;
12
11
  const currentClearImmediate = globalThis.clearImmediate;
13
- const currentNextTick = (_a = globalThis.process) == null ? void 0 : _a.nextTick;
12
+ const currentNextTick = globalThis.process?.nextTick;
14
13
  try {
15
14
  globalThis.setTimeout = setTimeout;
16
15
  globalThis.clearTimeout = clearTimeout;
@@ -60,13 +59,12 @@ function createRuntimeRpc(options) {
60
59
  "onCancel"
61
60
  ],
62
61
  onTimeoutError(functionName, args) {
63
- var _a;
64
62
  let message = `[vitest-worker]: Timeout calling "${functionName}"`;
65
63
  if (functionName === "fetch" || functionName === "transform" || functionName === "resolveId") {
66
64
  message += ` with "${JSON.stringify(args)}"`;
67
65
  }
68
66
  if (functionName === "onUnhandledError") {
69
- message += ` with "${((_a = args[0]) == null ? void 0 : _a.message) || args[0]}"`;
67
+ message += ` with "${args[0]?.message || args[0]}"`;
70
68
  }
71
69
  throw new Error(message);
72
70
  },
@@ -1,4 +1,4 @@
1
- import { g as getWorkerState } from './global.7bFbnyXl.js';
1
+ import { g as getWorkerState } from './utils.Ck2hJTRs.js';
2
2
 
3
3
  const filesCount = /* @__PURE__ */ new Map();
4
4
  const cache = /* @__PURE__ */ new Map();
@@ -3,37 +3,37 @@ import { startTests, collectTests } from '@vitest/runner';
3
3
  import 'pathe';
4
4
  import '@vitest/runner/utils';
5
5
  import { getSafeTimers } from '@vitest/utils';
6
- import { g as getWorkerState } from '../vendor/global.7bFbnyXl.js';
7
- import '../vendor/env.2ltrQNq0.js';
8
- import { a as globalExpect, r as resetModules, v as vi } from '../vendor/vi.Elqer9-7.js';
9
- import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from '../vendor/coverage.BhYSDdTT.js';
10
- import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '../vendor/index.CVqMv71L.js';
6
+ import { g as getWorkerState } from './utils.Ck2hJTRs.js';
7
+ import './env.BU041cs9.js';
8
+ import { a as globalExpect, r as resetModules, v as vi } from './vi.fiQ7lMRF.js';
9
+ import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from './coverage.CqfT4xaf.js';
10
+ import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.R1VjssW9.js';
11
11
  import { createRequire } from 'node:module';
12
12
  import util from 'node:util';
13
13
  import timers from 'node:timers';
14
14
  import { installSourcemapsSupport } from 'vite-node/source-map';
15
15
  import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
16
- import { V as VitestIndex } from '../vendor/index.DI9daj1Q.js';
17
- import { s as setupCommonEnv } from '../vendor/setup-common.symvFZPh.js';
18
- import { c as closeInspector } from '../vendor/inspector.-FCQUzqR.js';
16
+ import { V as VitestIndex } from './index.BfeNhc0N.js';
17
+ import { s as setupCommonEnv } from './setup-common.CNzatKMx.js';
18
+ import { c as closeInspector } from './inspector.70d6emsh.js';
19
19
  import 'std-env';
20
20
  import 'chai';
21
- import '../vendor/_commonjsHelpers.BFTU3MAI.js';
21
+ import './_commonjsHelpers.BFTU3MAI.js';
22
22
  import '@vitest/expect';
23
23
  import '@vitest/snapshot';
24
24
  import '@vitest/utils/error';
25
- import '../vendor/tasks.DhVtQBtW.js';
25
+ import './tasks.BZnCS9aT.js';
26
26
  import '@vitest/utils/source-map';
27
- import '../vendor/base.DRHPZCCj.js';
28
- import '../vendor/date.W2xKR2qe.js';
27
+ import './base.DSsbfkDg.js';
28
+ import './date.W2xKR2qe.js';
29
29
  import '@vitest/spy';
30
30
  import '../path.js';
31
31
  import 'node:url';
32
- import '../vendor/rpc.BGx7q_k2.js';
33
- import '../vendor/index.BpSiYbpB.js';
34
- import '../vendor/benchmark.B6pblCp2.js';
35
- import '../vendor/index.BJmtb_7W.js';
36
- import '../vendor/run-once.Db8Hgq9X.js';
32
+ import './rpc.B7Mfb-Yf.js';
33
+ import './index.BpSiYbpB.js';
34
+ import './benchmark.DDmpNjj-.js';
35
+ import './index.DYufA6CZ.js';
36
+ import './run-once.Sxe67Wng.js';
37
37
 
38
38
  let globalSetup = false;
39
39
  async function setupGlobalEnv(config, { environment }, executor) {
@@ -81,7 +81,7 @@ function resolveAsset(mod, url) {
81
81
  mod.exports = url;
82
82
  }
83
83
  async function setupConsoleLogSpy() {
84
- const { createCustomConsole } = await import('./runtime-console.C2L2zykk.js');
84
+ const { createCustomConsole } = await import('./console.Bgn7_A1x.js');
85
85
  globalThis.console = createCustomConsole();
86
86
  }
87
87
  async function withEnv({ environment }, options, fn) {
@@ -108,9 +108,8 @@ async function run(method, files, config, environment, executor) {
108
108
  }
109
109
  const runner = await resolveTestRunner(config, executor);
110
110
  workerState.onCancel.then((reason) => {
111
- var _a;
112
111
  closeInspector(config);
113
- (_a = runner.onCancel) == null ? void 0 : _a.call(runner, reason);
112
+ runner.onCancel?.(reason);
114
113
  });
115
114
  workerState.durations.prepare = performance.now() - workerState.durations.prepare;
116
115
  workerState.durations.environment = performance.now();
@@ -118,11 +117,10 @@ async function run(method, files, config, environment, executor) {
118
117
  environment,
119
118
  environment.options || config.environmentOptions || {},
120
119
  async () => {
121
- var _a, _b, _c, _d;
122
120
  workerState.durations.environment = performance.now() - workerState.durations.environment;
123
121
  for (const file of files) {
124
- const isIsolatedThreads = config.pool === "threads" && (((_b = (_a = config.poolOptions) == null ? void 0 : _a.threads) == null ? void 0 : _b.isolate) ?? true);
125
- const isIsolatedForks = config.pool === "forks" && (((_d = (_c = config.poolOptions) == null ? void 0 : _c.forks) == null ? void 0 : _d.isolate) ?? true);
122
+ const isIsolatedThreads = config.pool === "threads" && (config.poolOptions?.threads?.isolate ?? true);
123
+ const isIsolatedForks = config.pool === "forks" && (config.poolOptions?.forks?.isolate ?? true);
126
124
  if (isIsolatedThreads || isIsolatedForks) {
127
125
  workerState.mockMap.clear();
128
126
  resetModules(workerState.moduleCache, true);
@@ -1,6 +1,6 @@
1
1
  import { setSafeTimers } from '@vitest/utils';
2
2
  import { addSerializer } from '@vitest/snapshot';
3
- import { r as resetRunOnceCounter } from './run-once.Db8Hgq9X.js';
3
+ import { r as resetRunOnceCounter } from './run-once.Sxe67Wng.js';
4
4
 
5
5
  let globalSetup = false;
6
6
  async function setupCommonEnv(config) {
@@ -13,7 +13,7 @@ async function setupCommonEnv(config) {
13
13
  globalSetup = true;
14
14
  setSafeTimers();
15
15
  if (config.globals) {
16
- (await import('../chunks/integrations-globals.nDMtdOcn.js')).registerApiGlobally();
16
+ (await import('./globals.BliuJFNR.js')).registerApiGlobally();
17
17
  }
18
18
  }
19
19
  function setupDefines(defines) {
@@ -1,6 +1,6 @@
1
1
  import { Custom } from '@vitest/runner';
2
2
  import '@vitest/runner/utils';
3
- import { ah as BenchFunction, ai as BenchmarkAPI } from './reporters-B7ebVMkT.js';
3
+ import { b as BenchFunction, c as BenchmarkAPI } from './benchmark.puBFxyfE.js';
4
4
  import { Options } from 'tinybench';
5
5
 
6
6
  declare function getBenchOptions(key: Custom): Options;
@@ -3,9 +3,8 @@ import '@vitest/utils';
3
3
 
4
4
  function hasFailedSnapshot(suite) {
5
5
  return getTests(suite).some((s) => {
6
- var _a, _b;
7
- return (_b = (_a = s.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.some(
8
- (e) => typeof (e == null ? void 0 : e.message) === "string" && e.message.match(/Snapshot .* mismatched/)
6
+ return s.result?.errors?.some(
7
+ (e) => typeof e?.message === "string" && e.message.match(/Snapshot .* mismatched/)
9
8
  );
10
9
  });
11
10
  }
@@ -1,9 +1,8 @@
1
1
  import { parseRegexp } from '@vitest/utils';
2
2
 
3
- var _a, _b;
4
3
  const REGEXP_WRAP_PREFIX = "$$vitest:";
5
- const processSend = (_a = process.send) == null ? void 0 : _a.bind(process);
6
- const processOn = (_b = process.on) == null ? void 0 : _b.bind(process);
4
+ const processSend = process.send?.bind(process);
5
+ const processOn = process.on?.bind(process);
7
6
  function createThreadsRpcOptions({
8
7
  port
9
8
  }) {
@@ -25,7 +24,7 @@ function createForksRpcOptions(nodeV8) {
25
24
  },
26
25
  on(fn) {
27
26
  processOn("message", (message, ...extras) => {
28
- if (message == null ? void 0 : message.__tinypool_worker_message__) {
27
+ if (message?.__tinypool_worker_message__) {
29
28
  return;
30
29
  }
31
30
  return fn(message, ...extras);
@@ -17,7 +17,7 @@ function provideWorkerState(context, state) {
17
17
  }
18
18
  function getCurrentEnvironment() {
19
19
  const state = getWorkerState();
20
- return state == null ? void 0 : state.environment.name;
20
+ return state?.environment.name;
21
21
  }
22
22
 
23
23
  export { getCurrentEnvironment as a, getWorkerState as g, provideWorkerState as p };
@@ -1,6 +1,6 @@
1
1
  import { isAbsolute, relative, dirname, basename } from 'pathe';
2
2
  import c from 'tinyrainbow';
3
- import { a as slash } from './base.DRHPZCCj.js';
3
+ import { a as slash } from './base.DSsbfkDg.js';
4
4
 
5
5
  const F_RIGHT = "\u2192";
6
6
  const F_DOWN = "\u2193";
@@ -43,8 +43,7 @@ const taskFail = c.red(F_CROSS);
43
43
  const suiteFail = c.red(F_POINTER);
44
44
  const pending = c.gray("\xB7");
45
45
  function getCols(delta = 0) {
46
- var _a;
47
- let length = (_a = process.stdout) == null ? void 0 : _a.columns;
46
+ let length = process.stdout?.columns;
48
47
  if (!length || Number.isNaN(length)) {
49
48
  length = 30;
50
49
  }
@@ -67,12 +66,11 @@ function divider(text, left, right) {
67
66
  return F_LONG_DASH.repeat(cols);
68
67
  }
69
68
  function formatTestPath(root, path) {
70
- var _a;
71
69
  if (isAbsolute(path)) {
72
70
  path = relative(root, path);
73
71
  }
74
72
  const dir = dirname(path);
75
- const ext = ((_a = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)) == null ? void 0 : _a[0]) || "";
73
+ const ext = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)?.[0] || "";
76
74
  const base = basename(path, ext);
77
75
  return slash(c.dim(`${dir}/`) + c.bold(base)) + c.dim(ext);
78
76
  }
@@ -124,23 +122,14 @@ function renderSnapshotSummary(rootDir, snapshots) {
124
122
  return summary;
125
123
  }
126
124
  function countTestErrors(tasks) {
127
- return tasks.reduce((c2, i) => {
128
- var _a, _b;
129
- return c2 + (((_b = (_a = i.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.length) || 0);
130
- }, 0);
125
+ return tasks.reduce((c2, i) => c2 + (i.result?.errors?.length || 0), 0);
131
126
  }
132
127
  function getStateString(tasks, name = "tests", showTotal = true) {
133
128
  if (tasks.length === 0) {
134
129
  return c.dim(`no ${name}`);
135
130
  }
136
- const passed = tasks.filter((i) => {
137
- var _a;
138
- return ((_a = i.result) == null ? void 0 : _a.state) === "pass";
139
- });
140
- const failed = tasks.filter((i) => {
141
- var _a;
142
- return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
143
- });
131
+ const passed = tasks.filter((i) => i.result?.state === "pass");
132
+ const failed = tasks.filter((i) => i.result?.state === "fail");
144
133
  const skipped2 = tasks.filter((i) => i.mode === "skip");
145
134
  const todo = tasks.filter((i) => i.mode === "todo");
146
135
  return [
@@ -151,7 +140,6 @@ function getStateString(tasks, name = "tests", showTotal = true) {
151
140
  ].filter(Boolean).join(c.dim(" | ")) + (showTotal ? c.gray(` (${tasks.length})`) : "");
152
141
  }
153
142
  function getStateSymbol(task) {
154
- var _a;
155
143
  if (task.mode === "skip" || task.mode === "todo") {
156
144
  return skipped;
157
145
  }
@@ -170,7 +158,7 @@ function getStateSymbol(task) {
170
158
  return c.yellow(spinner());
171
159
  }
172
160
  if (task.result.state === "pass") {
173
- return ((_a = task.meta) == null ? void 0 : _a.benchmark) ? benchmarkPass : testPass;
161
+ return task.meta?.benchmark ? benchmarkPass : testPass;
174
162
  }
175
163
  if (task.result.state === "fail") {
176
164
  return task.type === "suite" ? suiteFail : taskFail;
@@ -178,8 +166,7 @@ function getStateSymbol(task) {
178
166
  return " ";
179
167
  }
180
168
  function getHookStateSymbol(task, hookName) {
181
- var _a, _b;
182
- const state = (_b = (_a = task.result) == null ? void 0 : _a.hooks) == null ? void 0 : _b[hookName];
169
+ const state = task.result?.hooks?.[hookName];
183
170
  if (state && state === "run") {
184
171
  let spinnerMap2 = hookSpinnerMap.get(task);
185
172
  if (!spinnerMap2) {
@@ -5,13 +5,13 @@ import { stripSnapshotIndentation, addSerializer, SnapshotClient } from '@vitest
5
5
  import { getNames } from '@vitest/runner/utils';
6
6
  import '@vitest/utils/error';
7
7
  import { getCurrentTest } from '@vitest/runner';
8
- import { g as getTestName } from './tasks.DhVtQBtW.js';
9
- import { g as getWorkerState, a as getCurrentEnvironment } from './global.7bFbnyXl.js';
8
+ import { g as getTestName } from './tasks.BZnCS9aT.js';
9
+ import { g as getWorkerState, a as getCurrentEnvironment } from './utils.Ck2hJTRs.js';
10
10
  import { getSafeTimers, assertTypes, createSimpleStackTrace } from '@vitest/utils';
11
11
  import 'pathe';
12
- import './env.2ltrQNq0.js';
12
+ import './env.BU041cs9.js';
13
13
  import { parseSingleStack } from '@vitest/utils/source-map';
14
- import { i as isChildProcess } from './base.DRHPZCCj.js';
14
+ import { i as isChildProcess } from './base.DSsbfkDg.js';
15
15
  import { R as RealDate, r as resetDate, m as mockDate } from './date.W2xKR2qe.js';
16
16
  import { spyOn, fn, isMockFunction, mocks } from '@vitest/spy';
17
17
 
@@ -256,13 +256,12 @@ const SnapshotPlugin = (chai, utils) => {
256
256
  chai.Assertion.prototype,
257
257
  "toMatchInlineSnapshot",
258
258
  function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
259
- var _a;
260
259
  const isNot = utils.flag(this, "negate");
261
260
  if (isNot) {
262
261
  throw new Error('toMatchInlineSnapshot cannot be used with "not"');
263
262
  }
264
263
  const test = utils.flag(this, "vitest-test");
265
- const isInsideEach = test && (test.each || ((_a = test.suite) == null ? void 0 : _a.each));
264
+ const isInsideEach = test && (test.each || test.suite?.each);
266
265
  if (isInsideEach) {
267
266
  throw new Error(
268
267
  "InlineSnapshot cannot be used inside of test.each or describe.each"
@@ -317,7 +316,6 @@ const SnapshotPlugin = (chai, utils) => {
317
316
  chai.Assertion.prototype,
318
317
  "toThrowErrorMatchingInlineSnapshot",
319
318
  function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
320
- var _a;
321
319
  const isNot = utils.flag(this, "negate");
322
320
  if (isNot) {
323
321
  throw new Error(
@@ -325,7 +323,7 @@ const SnapshotPlugin = (chai, utils) => {
325
323
  );
326
324
  }
327
325
  const test = utils.flag(this, "vitest-test");
328
- const isInsideEach = test && (test.each || ((_a = test.suite) == null ? void 0 : _a.each));
326
+ const isInsideEach = test && (test.each || test.suite?.each);
329
327
  if (isInsideEach) {
330
328
  throw new Error(
331
329
  "InlineSnapshot cannot be used inside of test.each or describe.each"
@@ -380,9 +378,8 @@ const unsupported = [
380
378
  ];
381
379
  function createExpectPoll(expect) {
382
380
  return function poll(fn, options = {}) {
383
- var _a;
384
381
  const state = getWorkerState();
385
- const defaults = ((_a = state.config.expect) == null ? void 0 : _a.poll) ?? {};
382
+ const defaults = state.config.expect?.poll ?? {};
386
383
  const {
387
384
  interval = defaults.interval ?? 50,
388
385
  timeout = defaults.timeout ?? 1e3,
@@ -3247,7 +3244,6 @@ class FakeTimers {
3247
3244
  }
3248
3245
  }
3249
3246
  useFakeTimers() {
3250
- var _a, _b, _c;
3251
3247
  if (this._fakingDate) {
3252
3248
  throw new Error(
3253
3249
  '"setSystemTime" was called already and date was mocked. Reset timers using `vi.useRealTimers()` if you want to use fake timers again.'
@@ -3257,12 +3253,12 @@ class FakeTimers {
3257
3253
  const toFake = Object.keys(this._fakeTimers.timers).filter(
3258
3254
  (timer) => timer !== "nextTick"
3259
3255
  );
3260
- if (((_b = (_a = this._userConfig) == null ? void 0 : _a.toFake) == null ? void 0 : _b.includes("nextTick")) && isChildProcess()) {
3256
+ if (this._userConfig?.toFake?.includes("nextTick") && isChildProcess()) {
3261
3257
  throw new Error(
3262
3258
  "process.nextTick cannot be mocked inside child_process"
3263
3259
  );
3264
3260
  }
3265
- const existingFakedMethods = (((_c = this._userConfig) == null ? void 0 : _c.toFake) || toFake).filter(
3261
+ const existingFakedMethods = (this._userConfig?.toFake || toFake).filter(
3266
3262
  (method) => {
3267
3263
  switch (method) {
3268
3264
  case "setImmediate":
@@ -3482,10 +3478,10 @@ function createVitest() {
3482
3478
  }
3483
3479
  const workerState = getWorkerState();
3484
3480
  let _timers;
3485
- const timers = () => _timers || (_timers = new FakeTimers({
3481
+ const timers = () => _timers ||= new FakeTimers({
3486
3482
  global: globalThis,
3487
3483
  config: workerState.config.fakeTimers
3488
- }));
3484
+ });
3489
3485
  const _stubsGlobal = /* @__PURE__ */ new Map();
3490
3486
  const _stubsEnv = /* @__PURE__ */ new Map();
3491
3487
  const _envBooleans = ["PROD", "DEV", "SSR"];
@@ -3496,13 +3492,12 @@ function createVitest() {
3496
3492
  return stack2.includes(` at Object.${name}`) || stack2.includes(`${name}@`);
3497
3493
  });
3498
3494
  const stack = parseSingleStack(stackArray[importerStackIndex + 1]);
3499
- return (stack == null ? void 0 : stack.file) || "";
3495
+ return stack?.file || "";
3500
3496
  };
3501
3497
  const utils = {
3502
3498
  useFakeTimers(config) {
3503
- var _a, _b, _c, _d;
3504
3499
  if (isChildProcess()) {
3505
- if (((_a = config == null ? void 0 : config.toFake) == null ? void 0 : _a.includes("nextTick")) || ((_d = (_c = (_b = workerState.config) == null ? void 0 : _b.fakeTimers) == null ? void 0 : _c.toFake) == null ? void 0 : _d.includes("nextTick"))) {
3500
+ if (config?.toFake?.includes("nextTick") || workerState.config?.fakeTimers?.toFake?.includes("nextTick")) {
3506
3501
  throw new Error(
3507
3502
  'vi.useFakeTimers({ toFake: ["nextTick"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.'
3508
3503
  );
@@ -1,8 +1,8 @@
1
1
  import vm, { isContext } from 'node:vm';
2
2
  import { fileURLToPath, pathToFileURL } from 'node:url';
3
3
  import { dirname, basename, extname, normalize, join, resolve } from 'pathe';
4
- import { createCustomConsole } from '../chunks/runtime-console.C2L2zykk.js';
5
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.jzOWtys_.js';
4
+ import { createCustomConsole } from './console.Bgn7_A1x.js';
5
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.Cjlr2CRw.js';
6
6
  import { distDir } from '../path.js';
7
7
  import { dirname as dirname$1 } from 'node:path';
8
8
  import fs from 'node:fs';
@@ -11,8 +11,8 @@ import { createRequire, Module } from 'node:module';
11
11
  import { CSS_LANGS_RE, KNOWN_ASSET_RE } from 'vite-node/constants';
12
12
  import '@vitest/runner/utils';
13
13
  import '@vitest/utils';
14
- import { p as provideWorkerState } from './global.7bFbnyXl.js';
15
- import './env.2ltrQNq0.js';
14
+ import { p as provideWorkerState } from './utils.Ck2hJTRs.js';
15
+ import './env.BU041cs9.js';
16
16
 
17
17
  const _require = createRequire(import.meta.url);
18
18
  const requiresCache = /* @__PURE__ */ new WeakMap();
@@ -84,7 +84,7 @@ class CommonjsExecutor {
84
84
  }
85
85
  // exposed for external use, Node.js does the opposite
86
86
  static _load = (request, parent, _isMain) => {
87
- const require = Module$1.createRequire((parent == null ? void 0 : parent.filename) ?? request);
87
+ const require = Module$1.createRequire(parent?.filename ?? request);
88
88
  return require(request);
89
89
  };
90
90
  static wrap = (script) => {
@@ -240,8 +240,7 @@ function interopCommonJsModule(interopDefault, mod) {
240
240
  keys: Array.from(allKeys),
241
241
  moduleExports: new Proxy(mod, {
242
242
  get(mod2, prop) {
243
- var _a;
244
- return mod2[prop] ?? ((_a = mod2.default) == null ? void 0 : _a[prop]);
243
+ return mod2[prop] ?? mod2.default?.[prop];
245
244
  }
246
245
  }),
247
246
  defaultExport: mod
@@ -256,26 +255,16 @@ function interopCommonJsModule(interopDefault, mod) {
256
255
  const SyntheticModule$1 = vm.SyntheticModule;
257
256
  const SourceTextModule = vm.SourceTextModule;
258
257
 
259
- var __defProp$1 = Object.defineProperty;
260
- var __typeError$1 = (msg) => {
261
- throw TypeError(msg);
262
- };
263
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
264
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
265
- var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
266
- var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
267
- var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
268
- var _httpIp;
269
258
  const dataURIRegex = /^data:(?<mime>text\/javascript|application\/json|application\/wasm)(?:;(?<encoding>charset=utf-8|base64))?,(?<code>.*)$/;
270
259
  class EsmExecutor {
271
260
  constructor(executor, options) {
272
261
  this.executor = executor;
273
- __publicField$1(this, "moduleCache", /* @__PURE__ */ new Map());
274
- __publicField$1(this, "esmLinkMap", /* @__PURE__ */ new WeakMap());
275
- __publicField$1(this, "context");
276
- __privateAdd$1(this, _httpIp, IPnumber("127.0.0.0"));
277
262
  this.context = options.context;
278
263
  }
264
+ moduleCache = /* @__PURE__ */ new Map();
265
+ esmLinkMap = /* @__PURE__ */ new WeakMap();
266
+ context;
267
+ #httpIp = IPnumber("127.0.0.0");
279
268
  async evaluateModule(m) {
280
269
  if (m.status === "unlinked") {
281
270
  this.esmLinkMap.set(
@@ -344,7 +333,7 @@ class EsmExecutor {
344
333
  async createNetworkModule(fileUrl) {
345
334
  if (fileUrl.startsWith("http:")) {
346
335
  const url = new URL(fileUrl);
347
- if (url.hostname !== "localhost" && url.hostname !== "::1" && (IPnumber(url.hostname) & IPmask(8)) !== __privateGet$1(this, _httpIp)) {
336
+ if (url.hostname !== "localhost" && url.hostname !== "::1" && (IPnumber(url.hostname) & IPmask(8)) !== this.#httpIp) {
348
337
  throw new Error(
349
338
  // we don't know the importer, so it's undefined (the same happens in --pool=threads)
350
339
  `import of '${fileUrl}' by undefined is not supported: http can only be used to load local resources (use https instead).`
@@ -447,7 +436,6 @@ class EsmExecutor {
447
436
  return this.createEsModule(identifier, () => code);
448
437
  }
449
438
  }
450
- _httpIp = new WeakMap();
451
439
  function IPnumber(address) {
452
440
  const ip = address.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
453
441
  if (ip) {
@@ -484,7 +472,7 @@ class ViteExecutor {
484
472
  getPackageName(modulePath) {
485
473
  const path = normalize(modulePath);
486
474
  let name = path.split("/node_modules/").pop() || "";
487
- if (name == null ? void 0 : name.startsWith("@")) {
475
+ if (name?.startsWith("@")) {
488
476
  name = name.split("/").slice(0, 2).join("/");
489
477
  } else {
490
478
  name = name.split("/")[0];
@@ -530,7 +518,6 @@ class ViteExecutor {
530
518
  return module;
531
519
  }
532
520
  canResolve = (fileUrl) => {
533
- var _a;
534
521
  const transformMode = this.workerState.environment.transformMode;
535
522
  if (transformMode !== "web") {
536
523
  return false;
@@ -538,7 +525,7 @@ class ViteExecutor {
538
525
  if (fileUrl === CLIENT_FILE) {
539
526
  return true;
540
527
  }
541
- const config = ((_a = this.workerState.config.deps) == null ? void 0 : _a.web) || {};
528
+ const config = this.workerState.config.deps?.web || {};
542
529
  const [modulePath] = fileUrl.split("?");
543
530
  if (config.transformCss && CSS_LANGS_RE.test(modulePath)) {
544
531
  return true;
@@ -555,42 +542,12 @@ class ViteExecutor {
555
542
  };
556
543
  }
557
544
 
558
- var __defProp = Object.defineProperty;
559
- var __typeError = (msg) => {
560
- throw TypeError(msg);
561
- };
562
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
563
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
564
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
565
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
566
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
567
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
568
- var _networkSupported;
569
545
  const SyntheticModule = vm.SyntheticModule;
570
546
  const { existsSync, statSync } = fs;
571
547
  const nativeResolve = import.meta.resolve;
572
548
  class ExternalModulesExecutor {
573
549
  constructor(options) {
574
550
  this.options = options;
575
- __publicField(this, "cjs");
576
- __publicField(this, "esm");
577
- __publicField(this, "vite");
578
- __publicField(this, "context");
579
- __publicField(this, "fs");
580
- __publicField(this, "resolvers", []);
581
- __privateAdd(this, _networkSupported, null);
582
- // dynamic import can be used in both ESM and CJS, so we have it in the executor
583
- __publicField(this, "importModuleDynamically", async (specifier, referencer) => {
584
- const module = await this.resolveModule(specifier, referencer.identifier);
585
- return await this.esm.evaluateModule(module);
586
- });
587
- __publicField(this, "resolveModule", async (specifier, referencer) => {
588
- let identifier = this.resolve(specifier, referencer);
589
- if (identifier instanceof Promise) {
590
- identifier = await identifier;
591
- }
592
- return await this.createModule(identifier);
593
- });
594
551
  this.context = options.context;
595
552
  this.fs = options.fileMap;
596
553
  this.esm = new EsmExecutor(this, {
@@ -609,6 +566,13 @@ class ExternalModulesExecutor {
609
566
  });
610
567
  this.resolvers = [this.vite.resolve];
611
568
  }
569
+ cjs;
570
+ esm;
571
+ vite;
572
+ context;
573
+ fs;
574
+ resolvers = [];
575
+ #networkSupported = null;
612
576
  async import(identifier) {
613
577
  const module = await this.createModule(identifier);
614
578
  await this.esm.evaluateModule(module);
@@ -620,6 +584,18 @@ class ExternalModulesExecutor {
620
584
  createRequire(identifier) {
621
585
  return this.cjs.createRequire(identifier);
622
586
  }
587
+ // dynamic import can be used in both ESM and CJS, so we have it in the executor
588
+ importModuleDynamically = async (specifier, referencer) => {
589
+ const module = await this.resolveModule(specifier, referencer.identifier);
590
+ return await this.esm.evaluateModule(module);
591
+ };
592
+ resolveModule = async (specifier, referencer) => {
593
+ let identifier = this.resolve(specifier, referencer);
594
+ if (identifier instanceof Promise) {
595
+ identifier = await identifier;
596
+ }
597
+ return await this.createModule(identifier);
598
+ };
623
599
  resolve(specifier, parent) {
624
600
  for (const resolver of this.resolvers) {
625
601
  const id = resolver(specifier, parent);
@@ -630,7 +606,6 @@ class ExternalModulesExecutor {
630
606
  return nativeResolve(specifier, parent);
631
607
  }
632
608
  findNearestPackageData(basedir) {
633
- var _a;
634
609
  const originalBasedir = basedir;
635
610
  const packageCache = this.options.packageCache;
636
611
  while (basedir) {
@@ -640,7 +615,7 @@ class ExternalModulesExecutor {
640
615
  }
641
616
  const pkgPath = join(basedir, "package.json");
642
617
  try {
643
- if ((_a = statSync(pkgPath, { throwIfNoEntry: false })) == null ? void 0 : _a.isFile()) {
618
+ if (statSync(pkgPath, { throwIfNoEntry: false })?.isFile()) {
644
619
  const pkgData = JSON.parse(this.fs.readFile(pkgPath));
645
620
  if (packageCache) {
646
621
  setCacheData(packageCache, pkgData, basedir, originalBasedir);
@@ -756,20 +731,18 @@ class ExternalModulesExecutor {
756
731
  }
757
732
  }
758
733
  get isNetworkSupported() {
759
- var _a;
760
- if (__privateGet(this, _networkSupported) == null) {
734
+ if (this.#networkSupported == null) {
761
735
  if (process.execArgv.includes("--experimental-network-imports")) {
762
- __privateSet(this, _networkSupported, true);
763
- } else if ((_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--experimental-network-imports")) {
764
- __privateSet(this, _networkSupported, true);
736
+ this.#networkSupported = true;
737
+ } else if (process.env.NODE_OPTIONS?.includes("--experimental-network-imports")) {
738
+ this.#networkSupported = true;
765
739
  } else {
766
- __privateSet(this, _networkSupported, false);
740
+ this.#networkSupported = false;
767
741
  }
768
742
  }
769
- return __privateGet(this, _networkSupported);
743
+ return this.#networkSupported;
770
744
  }
771
745
  }
772
- _networkSupported = new WeakMap();
773
746
 
774
747
  const { promises, readFileSync } = fs;
775
748
  class FileMap {
@@ -808,7 +781,6 @@ const entryFile = pathToFileURL(resolve(distDir, "workers/runVmTests.js")).href;
808
781
  const fileMap = new FileMap();
809
782
  const packageCache = /* @__PURE__ */ new Map();
810
783
  async function runVmTests(method, state) {
811
- var _a;
812
784
  const { environment, ctx, rpc } = state;
813
785
  if (!environment.setupVM) {
814
786
  const envName = ctx.environment.name;
@@ -862,7 +834,7 @@ async function runVmTests(method, state) {
862
834
  try {
863
835
  await run(method, ctx.files, ctx.config, executor);
864
836
  } finally {
865
- await ((_a = vm.teardown) == null ? void 0 : _a.call(vm));
837
+ await vm.teardown?.();
866
838
  state.environmentTeardownRun = true;
867
839
  }
868
840
  }