vitest 2.0.3 → 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 (78) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/browser.d.ts +21 -42
  3. package/dist/browser.js +5 -5
  4. package/dist/{vendor/base.CC6UHsNs.js → chunks/base.CC5R_kgU.js} +3 -3
  5. package/dist/{vendor/base.CTYV4Gnz.js → chunks/base.DSsbfkDg.js} +5 -4
  6. package/dist/{vendor/benchmark.B6pblCp2.js → chunks/benchmark.DDmpNjj-.js} +1 -1
  7. package/dist/chunks/benchmark.puBFxyfE.d.ts +22 -0
  8. package/dist/{vendor/cac.DUiZvzF_.js → chunks/cac.DGgmCKmU.js} +18 -21
  9. package/dist/{vendor/cli-api.CsgSG1Ir.js → chunks/cli-api.OKfd3qJ0.js} +666 -487
  10. package/dist/chunks/config.DCnyCTbs.d.ts +203 -0
  11. package/dist/chunks/{runtime-console.C2L2zykk.js → console.Bgn7_A1x.js} +11 -14
  12. package/dist/{vendor/constants.CsnA4eRy.js → chunks/constants.CaAN7icJ.js} +1 -3
  13. package/dist/{vendor/coverage.BhYSDdTT.js → chunks/coverage.CqfT4xaf.js} +4 -7
  14. package/dist/chunks/{browser-creator.CyaOd8pl.js → creator.a3OfuIEW.js} +8 -8
  15. package/dist/{vendor/env.2ltrQNq0.js → chunks/env.BU041cs9.js} +2 -3
  16. package/dist/chunks/environment.0M5R1SX_.d.ts +173 -0
  17. package/dist/{vendor/execute.Dx503nGn.js → chunks/execute.Cjlr2CRw.js} +28 -20
  18. package/dist/chunks/globals.BliuJFNR.js +31 -0
  19. package/dist/{vendor/index.Hqvcg1pf.js → chunks/index.BfeNhc0N.js} +43 -43
  20. package/dist/{vendor/index.D6GZqexG.js → chunks/index.CM5UI-4O.js} +2 -2
  21. package/dist/{vendor/index.BJmtb_7W.js → chunks/index.DYufA6CZ.js} +2 -2
  22. package/dist/{vendor/index.BCwvoAaf.js → chunks/index.JbiJutJ_.js} +516 -258
  23. package/dist/{vendor/index.CROIsoiT.js → chunks/index.R1VjssW9.js} +11 -12
  24. package/dist/{vendor/index.D4nqnQWz.js → chunks/index.lVXYBqEP.js} +1 -18
  25. package/dist/{vendor/inspector.-FCQUzqR.js → chunks/inspector.70d6emsh.js} +4 -5
  26. package/dist/chunks/{environments-node.XE5FbRPQ.js → node.DS3zEPa7.js} +2 -2
  27. package/dist/{reporters-BECoY4-b.d.ts → chunks/reporters.C_zwCd4j.d.ts} +850 -1003
  28. package/dist/{vendor/rpc.BGx7q_k2.js → chunks/rpc.B7Mfb-Yf.js} +3 -5
  29. package/dist/{vendor/run-once.Db8Hgq9X.js → chunks/run-once.Sxe67Wng.js} +1 -1
  30. package/dist/chunks/{runtime-runBaseTests.hkIOeriM.js → runBaseTests.CyvqmuC9.js} +35 -27
  31. package/dist/{vendor/setup-common.yHaxjRhz.js → chunks/setup-common.CNzatKMx.js} +2 -2
  32. package/dist/{suite-BWgaIsVn.d.ts → chunks/suite.CcK46U-P.d.ts} +1 -1
  33. package/dist/{vendor/tasks.DhVtQBtW.js → chunks/tasks.BZnCS9aT.js} +2 -3
  34. package/dist/{vendor/utils.DkxLWvS1.js → chunks/utils.C3_cBsyn.js} +3 -4
  35. package/dist/{vendor/global.7bFbnyXl.js → chunks/utils.Ck2hJTRs.js} +1 -1
  36. package/dist/{vendor/utils.DyTe1Nxn.js → chunks/utils.DpP_sDwr.js} +8 -21
  37. package/dist/{vendor/vi.DXACdGTu.js → chunks/vi.fiQ7lMRF.js} +13 -18
  38. package/dist/{vendor/vm.D1T5Rxan.js → chunks/vm.DcSuuaHr.js} +40 -68
  39. package/dist/chunks/worker.C5iHKIaJ.d.ts +144 -0
  40. package/dist/chunks/worker.DKkAC4Qw.d.ts +8 -0
  41. package/dist/cli.js +3 -3
  42. package/dist/config.cjs +6 -9
  43. package/dist/config.d.ts +10 -8
  44. package/dist/config.js +6 -9
  45. package/dist/coverage.d.ts +10 -8
  46. package/dist/coverage.js +11 -7
  47. package/dist/environments.d.ts +3 -19
  48. package/dist/environments.js +1 -1
  49. package/dist/execute.d.ts +8 -17
  50. package/dist/execute.js +2 -2
  51. package/dist/index.d.ts +267 -34
  52. package/dist/index.js +12 -12
  53. package/dist/node.d.ts +15 -9
  54. package/dist/node.js +16 -19
  55. package/dist/reporters.d.ts +10 -8
  56. package/dist/reporters.js +12 -15
  57. package/dist/runners.d.ts +7 -19
  58. package/dist/runners.js +12 -13
  59. package/dist/snapshot.js +3 -3
  60. package/dist/suite.d.ts +2 -16
  61. package/dist/suite.js +4 -4
  62. package/dist/worker.js +7 -8
  63. package/dist/workers/forks.js +5 -5
  64. package/dist/workers/runVmTests.js +32 -23
  65. package/dist/workers/threads.js +5 -5
  66. package/dist/workers/vmForks.js +8 -8
  67. package/dist/workers/vmThreads.js +8 -8
  68. package/dist/workers.d.ts +13 -8
  69. package/dist/workers.js +13 -13
  70. package/package.json +15 -15
  71. package/dist/chunks/integrations-globals.CzYWb38r.js +0 -31
  72. /package/dist/{vendor → chunks}/_commonjsHelpers.BFTU3MAI.js +0 -0
  73. /package/dist/{vendor → chunks}/date.W2xKR2qe.js +0 -0
  74. /package/dist/chunks/{node-git.ZtkbKc8u.js → git.ZtkbKc8u.js} +0 -0
  75. /package/dist/{vendor → chunks}/index.BMmMjLIQ.js +0 -0
  76. /package/dist/{vendor → chunks}/index.BpSiYbpB.js +0 -0
  77. /package/dist/chunks/{install-pkg.DNUmWFkO.js → index.DNUmWFkO.js} +0 -0
  78. /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,36 +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.DXACdGTu.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.CROIsoiT.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
- import { V as VitestIndex } from '../vendor/index.Hqvcg1pf.js';
16
- import { s as setupCommonEnv } from '../vendor/setup-common.yHaxjRhz.js';
17
- import { c as closeInspector } from '../vendor/inspector.-FCQUzqR.js';
15
+ import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
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';
18
19
  import 'std-env';
19
20
  import 'chai';
20
- import '../vendor/_commonjsHelpers.BFTU3MAI.js';
21
+ import './_commonjsHelpers.BFTU3MAI.js';
21
22
  import '@vitest/expect';
22
23
  import '@vitest/snapshot';
23
24
  import '@vitest/utils/error';
24
- import '../vendor/tasks.DhVtQBtW.js';
25
+ import './tasks.BZnCS9aT.js';
25
26
  import '@vitest/utils/source-map';
26
- import '../vendor/base.CTYV4Gnz.js';
27
- import '../vendor/date.W2xKR2qe.js';
27
+ import './base.DSsbfkDg.js';
28
+ import './date.W2xKR2qe.js';
28
29
  import '@vitest/spy';
29
30
  import '../path.js';
30
31
  import 'node:url';
31
- import '../vendor/rpc.BGx7q_k2.js';
32
- import '../vendor/index.BpSiYbpB.js';
33
- import '../vendor/benchmark.B6pblCp2.js';
34
- import '../vendor/index.BJmtb_7W.js';
35
- 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';
36
37
 
37
38
  let globalSetup = false;
38
39
  async function setupGlobalEnv(config, { environment }, executor) {
@@ -51,10 +52,13 @@ async function setupGlobalEnv(config, { environment }, executor) {
51
52
  globalSetup = true;
52
53
  if (environment.transformMode === "web") {
53
54
  const _require = createRequire(import.meta.url);
54
- _require.extensions[".css"] = () => ({});
55
- _require.extensions[".scss"] = () => ({});
56
- _require.extensions[".sass"] = () => ({});
57
- _require.extensions[".less"] = () => ({});
55
+ _require.extensions[".css"] = resolveCss;
56
+ _require.extensions[".scss"] = resolveCss;
57
+ _require.extensions[".sass"] = resolveCss;
58
+ _require.extensions[".less"] = resolveCss;
59
+ KNOWN_ASSET_TYPES.forEach((type) => {
60
+ _require.extensions[`.${type}`] = resolveAsset;
61
+ });
58
62
  process.env.SSR = "";
59
63
  } else {
60
64
  process.env.SSR = "1";
@@ -70,8 +74,14 @@ async function setupGlobalEnv(config, { environment }, executor) {
70
74
  await setupConsoleLogSpy();
71
75
  }
72
76
  }
77
+ function resolveCss(mod) {
78
+ mod.exports = "";
79
+ }
80
+ function resolveAsset(mod, url) {
81
+ mod.exports = url;
82
+ }
73
83
  async function setupConsoleLogSpy() {
74
- const { createCustomConsole } = await import('./runtime-console.C2L2zykk.js');
84
+ const { createCustomConsole } = await import('./console.Bgn7_A1x.js');
75
85
  globalThis.console = createCustomConsole();
76
86
  }
77
87
  async function withEnv({ environment }, options, fn) {
@@ -98,9 +108,8 @@ async function run(method, files, config, environment, executor) {
98
108
  }
99
109
  const runner = await resolveTestRunner(config, executor);
100
110
  workerState.onCancel.then((reason) => {
101
- var _a;
102
111
  closeInspector(config);
103
- (_a = runner.onCancel) == null ? void 0 : _a.call(runner, reason);
112
+ runner.onCancel?.(reason);
104
113
  });
105
114
  workerState.durations.prepare = performance.now() - workerState.durations.prepare;
106
115
  workerState.durations.environment = performance.now();
@@ -108,11 +117,10 @@ async function run(method, files, config, environment, executor) {
108
117
  environment,
109
118
  environment.options || config.environmentOptions || {},
110
119
  async () => {
111
- var _a, _b, _c, _d;
112
120
  workerState.durations.environment = performance.now() - workerState.durations.environment;
113
121
  for (const file of files) {
114
- const isIsolatedThreads = config.pool === "threads" && (((_b = (_a = config.poolOptions) == null ? void 0 : _a.threads) == null ? void 0 : _b.isolate) ?? true);
115
- 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);
116
124
  if (isIsolatedThreads || isIsolatedForks) {
117
125
  workerState.mockMap.clear();
118
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.CzYWb38r.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-BECoY4-b.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.CTYV4Gnz.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.CTYV4Gnz.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
  );