vitest 2.0.0-beta.8 → 2.0.0

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 (73) hide show
  1. package/LICENSE.md +1 -22
  2. package/dist/browser.d.ts +24 -7
  3. package/dist/browser.js +5 -19
  4. package/dist/chunks/browser-creator.DSqYDthP.js +673 -0
  5. package/dist/chunks/{environments-node.39w4gmlF.js → environments-node.XE5FbRPQ.js} +1 -1
  6. package/dist/chunks/{integrations-globals.BK0Cn4q1.js → integrations-globals.CzYWb38r.js} +10 -9
  7. package/dist/chunks/{node-git.CCI8evVZ.js → node-git.ZtkbKc8u.js} +14 -15
  8. package/dist/chunks/{runtime-console.DiVMr5d4.js → runtime-console.O41g23Zj.js} +26 -11
  9. package/dist/chunks/{runtime-runBaseTests.C-Bkopka.js → runtime-runBaseTests.DX3h28Mp.js} +47 -34
  10. package/dist/cli.js +3 -3
  11. package/dist/config.cjs +48 -23
  12. package/dist/config.d.ts +2 -1
  13. package/dist/config.js +48 -24
  14. package/dist/coverage.d.ts +6 -4
  15. package/dist/coverage.js +102 -38
  16. package/dist/environments.d.ts +2 -1
  17. package/dist/environments.js +1 -1
  18. package/dist/execute.d.ts +4 -3
  19. package/dist/execute.js +2 -2
  20. package/dist/index.d.ts +1437 -7
  21. package/dist/index.js +10 -9
  22. package/dist/node.d.ts +34 -7
  23. package/dist/node.js +31 -20
  24. package/dist/path.js +4 -1
  25. package/dist/{reporters-DaDey3o0.d.ts → reporters-DrhyxxXt.d.ts} +213 -206
  26. package/dist/reporters.d.ts +2 -1
  27. package/dist/reporters.js +8 -8
  28. package/dist/runners.d.ts +3 -1
  29. package/dist/runners.js +100 -61
  30. package/dist/snapshot.js +2 -2
  31. package/dist/{suite-BHSUxUib.d.ts → suite-DCPwkk7G.d.ts} +1 -1
  32. package/dist/suite.d.ts +3 -2
  33. package/dist/suite.js +3 -3
  34. package/dist/utils.d.ts +1 -5
  35. package/dist/utils.js +1 -6
  36. package/dist/vendor/{base._gnK9Slw.js → base.CTYV4Gnz.js} +24 -17
  37. package/dist/vendor/{base.D4XK-wRp.js → base.CdA1i5tB.js} +6 -4
  38. package/dist/vendor/{benchmark.BNLebNi5.js → benchmark.B6pblCp2.js} +13 -14
  39. package/dist/vendor/{cac.B8p8r_GP.js → cac.5nBDv26-.js} +142 -47
  40. package/dist/vendor/{cli-api.AbX6UpUw.js → cli-api.BT4NJtxX.js} +4162 -9514
  41. package/dist/vendor/{constants.TCjCaw2D.js → constants.CsnA4eRy.js} +5 -23
  42. package/dist/vendor/{coverage.ChSqD-qS.js → coverage.BhYSDdTT.js} +27 -11
  43. package/dist/vendor/{date.BKM1wewY.js → date.W2xKR2qe.js} +5 -3
  44. package/dist/vendor/env.2ltrQNq0.js +8 -0
  45. package/dist/vendor/{execute.BHj6OMh4.js → execute.Dx503nGn.js} +186 -64
  46. package/dist/vendor/{index.TBU3GqRP.js → index.3x3MdmUV.js} +1075 -526
  47. package/dist/vendor/{index._7XLd8Kd.js → index.BJmtb_7W.js} +3 -2
  48. package/dist/vendor/{index.DP-km6lF.js → index.BMmMjLIQ.js} +64 -51
  49. package/dist/vendor/{index.DHRpy7zp.js → index.CROIsoiT.js} +18 -10
  50. package/dist/vendor/{index.DeR1hhfY.js → index.D4nqnQWz.js} +71 -74
  51. package/dist/vendor/index.D6GZqexG.js +6575 -0
  52. package/dist/vendor/{index.DwR86H5i.js → index.Hqvcg1pf.js} +4 -27
  53. package/dist/vendor/{rpc.DRDE9Pu1.js → rpc.BGx7q_k2.js} +30 -19
  54. package/dist/vendor/run-once.Db8Hgq9X.js +28 -0
  55. package/dist/vendor/{setup-common.BhJvzjns.js → setup-common.yHaxjRhz.js} +30 -15
  56. package/dist/vendor/spy.Cf_4R5Oe.js +22 -0
  57. package/dist/vendor/{tasks.WC7M-K-v.js → tasks.DhVtQBtW.js} +3 -1
  58. package/dist/vendor/{utils.YuQ3LT2a.js → utils.BVMrsl6E.js} +55 -30
  59. package/dist/vendor/{utils.CUjzkRH7.js → utils.DkxLWvS1.js} +12 -5
  60. package/dist/vendor/{vi.C6AfDXK6.js → vi.DXACdGTu.js} +269 -136
  61. package/dist/vendor/{vm.Ow-X2mkS.js → vm.BrDS6p7h.js} +157 -90
  62. package/dist/worker.js +41 -18
  63. package/dist/workers/forks.js +12 -6
  64. package/dist/workers/runVmTests.js +22 -16
  65. package/dist/workers/threads.js +8 -5
  66. package/dist/workers/vmForks.js +15 -9
  67. package/dist/workers/vmThreads.js +11 -8
  68. package/dist/workers.d.ts +8 -5
  69. package/dist/workers.js +11 -11
  70. package/package.json +22 -21
  71. package/suppress-warnings.cjs +2 -4
  72. package/dist/index-B0dCycbN.d.ts +0 -1571
  73. package/dist/vendor/env.bmJgw1qP.js +0 -7
@@ -1,4 +1,4 @@
1
- export { b3 as BaseReporter, aW as BasicReporter, bb as BenchmarkBuiltinReporters, ba as BenchmarkReportsMap, b6 as BuiltinReporterOptions, b5 as BuiltinReporters, aV as DefaultReporter, aX as DotReporter, b2 as GithubActionsReporter, b1 as HangingProcessReporter, a$ as JUnitReporter, b7 as JsonAssertionResult, aY as JsonReporter, b8 as JsonTestResult, b9 as JsonTestResults, aj as Reporter, b4 as ReportersMap, b0 as TapFlatReporter, a_ as TapReporter, aZ as VerboseReporter } from './reporters-DaDey3o0.js';
1
+ export { b8 as BaseReporter, a$ as BasicReporter, bg as BenchmarkBuiltinReporters, bf as BenchmarkReportsMap, bb as BuiltinReporterOptions, ba as BuiltinReporters, a_ as DefaultReporter, b0 as DotReporter, b7 as GithubActionsReporter, b6 as HangingProcessReporter, b4 as JUnitReporter, bc as JsonAssertionResult, b1 as JsonReporter, bd as JsonTestResult, be as JsonTestResults, k as Reporter, b9 as ReportersMap, b5 as TapFlatReporter, b3 as TapReporter, b2 as VerboseReporter } from './reporters-DrhyxxXt.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
@@ -12,5 +12,6 @@ import 'vite-node/client';
12
12
  import '@vitest/snapshot/manager';
13
13
  import 'vite-node/server';
14
14
  import 'node:worker_threads';
15
+ import '@vitest/utils/source-map';
15
16
  import 'node:fs';
16
17
  import 'chai';
package/dist/reporters.js CHANGED
@@ -1,23 +1,23 @@
1
- export { a as BasicReporter, e as BenchmarkReportsMap, D as DefaultReporter, b as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, c as JUnitReporter, J as JsonReporter, R as ReportersMap, d as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/index.TBU3GqRP.js';
1
+ export { B as BasicReporter, d as BenchmarkReportsMap, D as DefaultReporter, a as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, b as JUnitReporter, J as JsonReporter, R as ReportersMap, c as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/index.3x3MdmUV.js';
2
2
  import 'node:fs';
3
3
  import 'picocolors';
4
4
  import 'pathe';
5
- import './vendor/tasks.WC7M-K-v.js';
5
+ import './vendor/tasks.DhVtQBtW.js';
6
6
  import '@vitest/runner/utils';
7
7
  import '@vitest/utils';
8
- import './vendor/env.bmJgw1qP.js';
8
+ import './vendor/env.2ltrQNq0.js';
9
9
  import 'std-env';
10
- import './vendor/utils.YuQ3LT2a.js';
11
- import './vendor/base._gnK9Slw.js';
10
+ import './vendor/utils.BVMrsl6E.js';
11
+ import './vendor/base.CTYV4Gnz.js';
12
12
  import 'node:perf_hooks';
13
13
  import '@vitest/utils/source-map';
14
- import './vendor/index._7XLd8Kd.js';
14
+ import './vendor/index.BJmtb_7W.js';
15
15
  import './vendor/global.7bFbnyXl.js';
16
- import './chunks/runtime-console.DiVMr5d4.js';
16
+ import './chunks/runtime-console.O41g23Zj.js';
17
17
  import 'node:stream';
18
18
  import 'node:console';
19
19
  import 'node:path';
20
- import './vendor/date.BKM1wewY.js';
20
+ import './vendor/date.W2xKR2qe.js';
21
21
  import 'node:os';
22
22
  import 'node:fs/promises';
23
23
  import 'execa';
package/dist/runners.d.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import { R as ResolvedConfig, P as Pool } from './reporters-DrhyxxXt.js';
1
2
  import { VitestRunner, VitestRunnerImportSource, File, Suite, Task, CancelReason, Test, Custom, TaskContext, ExtendedContext } from '@vitest/runner';
2
- import { R as ResolvedConfig } from './reporters-DaDey3o0.js';
3
3
  import * as tinybench from 'tinybench';
4
4
  import 'vite';
5
5
  import 'vite-node';
@@ -12,6 +12,7 @@ import 'vite-node/client';
12
12
  import '@vitest/snapshot/manager';
13
13
  import 'vite-node/server';
14
14
  import 'node:worker_threads';
15
+ import '@vitest/utils/source-map';
15
16
  import 'node:fs';
16
17
  import 'chai';
17
18
 
@@ -22,6 +23,7 @@ declare class VitestTestRunner implements VitestRunner {
22
23
  private __vitest_executor;
23
24
  private cancelRun;
24
25
  private assertionsErrors;
26
+ pool: Pool;
25
27
  constructor(config: ResolvedConfig);
26
28
  importFile(filepath: string, source: VitestRunnerImportSource): unknown;
27
29
  onCollectStart(file: File): void;
package/dist/runners.js CHANGED
@@ -1,25 +1,25 @@
1
1
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
2
- import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.C6AfDXK6.js';
2
+ import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.DXACdGTu.js';
3
3
  import 'pathe';
4
- import { g as getTestName } from './vendor/tasks.WC7M-K-v.js';
4
+ import { g as getTestName } from './vendor/tasks.DhVtQBtW.js';
5
5
  import { createDefer, getSafeTimers } from '@vitest/utils';
6
6
  import { g as getWorkerState } from './vendor/global.7bFbnyXl.js';
7
- import './vendor/env.bmJgw1qP.js';
8
- import { r as rpc } from './vendor/rpc.DRDE9Pu1.js';
7
+ import './vendor/env.2ltrQNq0.js';
8
+ import { r as rpc } from './vendor/rpc.BGx7q_k2.js';
9
9
  import { getTests, getNames } from '@vitest/runner/utils';
10
10
  import { updateTask } from '@vitest/runner';
11
- import { a as getBenchOptions, g as getBenchFn } from './vendor/benchmark.BNLebNi5.js';
11
+ import { a as getBenchOptions, g as getBenchFn } from './vendor/benchmark.B6pblCp2.js';
12
12
  import 'chai';
13
13
  import './vendor/_commonjsHelpers.BFTU3MAI.js';
14
14
  import '@vitest/snapshot';
15
15
  import '@vitest/utils/error';
16
16
  import '@vitest/utils/source-map';
17
- import './vendor/base._gnK9Slw.js';
18
- import './vendor/date.BKM1wewY.js';
17
+ import './vendor/base.CTYV4Gnz.js';
18
+ import './vendor/date.W2xKR2qe.js';
19
19
  import '@vitest/spy';
20
20
  import 'std-env';
21
21
  import './vendor/index.BpSiYbpB.js';
22
- import './vendor/index._7XLd8Kd.js';
22
+ import './vendor/index.BJmtb_7W.js';
23
23
 
24
24
  class VitestTestRunner {
25
25
  constructor(config) {
@@ -30,9 +30,11 @@ class VitestTestRunner {
30
30
  __vitest_executor;
31
31
  cancelRun = false;
32
32
  assertionsErrors = /* @__PURE__ */ new WeakMap();
33
+ pool = this.workerState.ctx.pool;
33
34
  importFile(filepath, source) {
34
- if (source === "setup")
35
+ if (source === "setup") {
35
36
  this.workerState.moduleCache.delete(filepath);
37
+ }
36
38
  return this.__vitest_executor.executeId(filepath);
37
39
  }
38
40
  onCollectStart(file) {
@@ -45,8 +47,9 @@ class VitestTestRunner {
45
47
  this.workerState.current = void 0;
46
48
  }
47
49
  async onAfterRunSuite(suite) {
48
- if (this.config.logHeapUsage && typeof process !== "undefined")
50
+ if (this.config.logHeapUsage && typeof process !== "undefined") {
49
51
  suite.result.heap = process.memoryUsage().heapUsed;
52
+ }
50
53
  if (suite.mode !== "skip" && "filepath" in suite) {
51
54
  for (const test of getTests(suite)) {
52
55
  if (test.mode === "skip") {
@@ -55,47 +58,59 @@ class VitestTestRunner {
55
58
  }
56
59
  }
57
60
  const result = await this.snapshotClient.finishCurrentRun();
58
- if (result)
61
+ if (result) {
59
62
  await rpc().snapshotSaved(result);
63
+ }
60
64
  }
61
65
  this.workerState.current = suite.suite || suite.file;
62
66
  }
63
67
  onAfterRunTask(test) {
64
68
  this.snapshotClient.clearTest();
65
- if (this.config.logHeapUsage && typeof process !== "undefined")
69
+ if (this.config.logHeapUsage && typeof process !== "undefined") {
66
70
  test.result.heap = process.memoryUsage().heapUsed;
71
+ }
67
72
  this.workerState.current = test.suite || test.file;
68
73
  }
69
74
  onCancel(_reason) {
70
75
  this.cancelRun = true;
71
76
  }
72
77
  async onBeforeRunTask(test) {
73
- if (this.cancelRun)
78
+ if (this.cancelRun) {
74
79
  test.mode = "skip";
75
- if (test.mode !== "run")
80
+ }
81
+ if (test.mode !== "run") {
76
82
  return;
83
+ }
77
84
  clearModuleMocks(this.config);
78
85
  this.workerState.current = test;
79
86
  }
80
87
  async onBeforeRunSuite(suite) {
81
- if (this.cancelRun)
88
+ if (this.cancelRun) {
82
89
  suite.mode = "skip";
90
+ }
83
91
  if (suite.mode !== "skip" && "filepath" in suite) {
84
- await this.snapshotClient.startCurrentRun(suite.filepath, "__default_name_", this.workerState.config.snapshotOptions);
92
+ await this.snapshotClient.startCurrentRun(
93
+ suite.filepath,
94
+ "__default_name_",
95
+ this.workerState.config.snapshotOptions
96
+ );
85
97
  }
86
98
  this.workerState.current = suite;
87
99
  }
88
100
  onBeforeTryTask(test) {
89
- setState({
90
- assertionCalls: 0,
91
- isExpectingAssertions: false,
92
- isExpectingAssertionsError: null,
93
- expectedAssertionsNumber: null,
94
- expectedAssertionsNumberErrorGen: null,
95
- testPath: test.file.filepath,
96
- currentTestName: getTestName(test),
97
- snapshotState: this.snapshotClient.snapshotState
98
- }, globalThis[GLOBAL_EXPECT]);
101
+ setState(
102
+ {
103
+ assertionCalls: 0,
104
+ isExpectingAssertions: false,
105
+ isExpectingAssertionsError: null,
106
+ expectedAssertionsNumber: null,
107
+ expectedAssertionsNumberErrorGen: null,
108
+ testPath: test.file.filepath,
109
+ currentTestName: getTestName(test),
110
+ snapshotState: this.snapshotClient.snapshotState
111
+ },
112
+ globalThis[GLOBAL_EXPECT]
113
+ );
99
114
  }
100
115
  onAfterTryTask(test) {
101
116
  const {
@@ -104,23 +119,30 @@ class VitestTestRunner {
104
119
  expectedAssertionsNumberErrorGen,
105
120
  isExpectingAssertions,
106
121
  isExpectingAssertionsError
107
- // @ts-expect-error _local is untyped
108
122
  } = "context" in test && test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
109
- if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber)
123
+ if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber) {
110
124
  throw expectedAssertionsNumberErrorGen();
111
- if (isExpectingAssertions === true && assertionCalls === 0)
125
+ }
126
+ if (isExpectingAssertions === true && assertionCalls === 0) {
112
127
  throw isExpectingAssertionsError;
113
- if (this.config.expect.requireAssertions && assertionCalls === 0)
128
+ }
129
+ if (this.config.expect.requireAssertions && assertionCalls === 0) {
114
130
  throw this.assertionsErrors.get(test);
131
+ }
115
132
  }
116
133
  extendTaskContext(context) {
117
- if (this.config.expect.requireAssertions)
118
- this.assertionsErrors.set(context.task, new Error("expected any number of assertion, but got none"));
134
+ if (this.config.expect.requireAssertions) {
135
+ this.assertionsErrors.set(
136
+ context.task,
137
+ new Error("expected any number of assertion, but got none")
138
+ );
139
+ }
119
140
  let _expect;
120
141
  Object.defineProperty(context, "expect", {
121
142
  get() {
122
- if (!_expect)
143
+ if (!_expect) {
123
144
  _expect = createExpect(context.task);
145
+ }
124
146
  return _expect;
125
147
  }
126
148
  });
@@ -134,16 +156,19 @@ class VitestTestRunner {
134
156
  }
135
157
  function clearModuleMocks(config) {
136
158
  const { clearMocks, mockReset, restoreMocks, unstubEnvs, unstubGlobals } = config;
137
- if (restoreMocks)
159
+ if (restoreMocks) {
138
160
  vi.restoreAllMocks();
139
- else if (mockReset)
161
+ } else if (mockReset) {
140
162
  vi.resetAllMocks();
141
- else if (clearMocks)
163
+ } else if (clearMocks) {
142
164
  vi.clearAllMocks();
143
- if (unstubEnvs)
165
+ }
166
+ if (unstubEnvs) {
144
167
  vi.unstubAllEnvs();
145
- if (unstubGlobals)
168
+ }
169
+ if (unstubGlobals) {
146
170
  vi.unstubAllGlobals();
171
+ }
147
172
  }
148
173
 
149
174
  function createBenchmarkResult(name) {
@@ -162,15 +187,18 @@ async function runBenchmarkSuite(suite, runner) {
162
187
  const benchmarkGroup = [];
163
188
  const benchmarkSuiteGroup = [];
164
189
  for (const task of suite.tasks) {
165
- if (task.mode !== "run")
190
+ if (task.mode !== "run") {
166
191
  continue;
167
- if ((_a = task.meta) == null ? void 0 : _a.benchmark)
192
+ }
193
+ if ((_a = task.meta) == null ? void 0 : _a.benchmark) {
168
194
  benchmarkGroup.push(task);
169
- else if (task.type === "suite")
195
+ } else if (task.type === "suite") {
170
196
  benchmarkSuiteGroup.push(task);
197
+ }
171
198
  }
172
- for (const subSuite of benchmarkSuiteGroup)
199
+ for (const subSuite of benchmarkSuiteGroup) {
173
200
  await runBenchmarkSuite(subSuite, runner);
201
+ }
174
202
  if (benchmarkGroup.length) {
175
203
  const defer = createDefer();
176
204
  suite.result = {
@@ -180,21 +208,29 @@ async function runBenchmarkSuite(suite, runner) {
180
208
  };
181
209
  updateTask$1(suite);
182
210
  const addBenchTaskListener = (task, benchmark) => {
183
- task.addEventListener("complete", (e) => {
184
- const task2 = e.task;
185
- const taskRes = task2.result;
186
- const result = benchmark.result.benchmark;
187
- Object.assign(result, taskRes);
188
- updateTask$1(benchmark);
189
- }, {
190
- once: true
191
- });
192
- task.addEventListener("error", (e) => {
193
- const task2 = e.task;
194
- defer.reject(benchmark ? task2.result.error : e);
195
- }, {
196
- once: true
197
- });
211
+ task.addEventListener(
212
+ "complete",
213
+ (e) => {
214
+ const task2 = e.task;
215
+ const taskRes = task2.result;
216
+ const result = benchmark.result.benchmark;
217
+ Object.assign(result, taskRes);
218
+ updateTask$1(benchmark);
219
+ },
220
+ {
221
+ once: true
222
+ }
223
+ );
224
+ task.addEventListener(
225
+ "error",
226
+ (e) => {
227
+ const task2 = e.task;
228
+ defer.reject(benchmark ? task2.result.error : e);
229
+ },
230
+ {
231
+ once: true
232
+ }
233
+ );
198
234
  };
199
235
  benchmarkGroup.forEach((benchmark) => {
200
236
  const options = getBenchOptions(benchmark);
@@ -216,9 +252,11 @@ async function runBenchmarkSuite(suite, runner) {
216
252
  const task = benchmarkTasks.get(benchmark);
217
253
  await task.warmup();
218
254
  tasks.push([
219
- await new Promise((resolve) => setTimeout(async () => {
220
- resolve(await task.run());
221
- })),
255
+ await new Promise(
256
+ (resolve) => setTimeout(async () => {
257
+ resolve(await task.run());
258
+ })
259
+ ),
222
260
  benchmark
223
261
  ]);
224
262
  }
@@ -249,8 +287,9 @@ class NodeBenchmarkRunner {
249
287
  return await import('tinybench');
250
288
  }
251
289
  importFile(filepath, source) {
252
- if (source === "setup")
290
+ if (source === "setup") {
253
291
  getWorkerState().moduleCache.delete(filepath);
292
+ }
254
293
  return this.__vitest_executor.executeId(filepath);
255
294
  }
256
295
  async runSuite(suite) {
package/dist/snapshot.js CHANGED
@@ -1,8 +1,8 @@
1
- export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/environments-node.39w4gmlF.js';
1
+ export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/environments-node.XE5FbRPQ.js';
2
2
  import '@vitest/snapshot/environment';
3
3
  import 'pathe';
4
4
  import '@vitest/runner/utils';
5
5
  import '@vitest/utils';
6
6
  import './vendor/global.7bFbnyXl.js';
7
- import './vendor/env.bmJgw1qP.js';
7
+ import './vendor/env.2ltrQNq0.js';
8
8
  import 'std-env';
@@ -1,6 +1,6 @@
1
1
  import { Custom } from '@vitest/runner';
2
2
  import '@vitest/runner/utils';
3
- import { D as BenchFunction, I as BenchmarkAPI } from './reporters-DaDey3o0.js';
3
+ import { ah as BenchFunction, ai as BenchmarkAPI } from './reporters-DrhyxxXt.js';
4
4
  import { Options } from 'tinybench';
5
5
 
6
6
  declare function getBenchOptions(key: Custom): Options;
package/dist/suite.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
2
2
  export { createChainable } from '@vitest/runner/utils';
3
- export { g as getBenchFn, a as getBenchOptions } from './suite-BHSUxUib.js';
4
- import './reporters-DaDey3o0.js';
3
+ export { g as getBenchFn, a as getBenchOptions } from './suite-DCPwkk7G.js';
4
+ import './reporters-DrhyxxXt.js';
5
5
  import 'vite';
6
6
  import 'vite-node';
7
7
  import '@vitest/snapshot';
@@ -13,5 +13,6 @@ import 'vite-node/client';
13
13
  import '@vitest/snapshot/manager';
14
14
  import 'vite-node/server';
15
15
  import 'node:worker_threads';
16
+ import '@vitest/utils/source-map';
16
17
  import 'node:fs';
17
18
  import 'chai';
package/dist/suite.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export { createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
2
2
  export { createChainable } from '@vitest/runner/utils';
3
- export { g as getBenchFn, a as getBenchOptions } from './vendor/benchmark.BNLebNi5.js';
3
+ export { g as getBenchFn, a as getBenchOptions } from './vendor/benchmark.B6pblCp2.js';
4
4
  import '@vitest/utils';
5
- import './vendor/index._7XLd8Kd.js';
5
+ import './vendor/index.BJmtb_7W.js';
6
6
  import 'pathe';
7
7
  import './vendor/global.7bFbnyXl.js';
8
- import './vendor/env.bmJgw1qP.js';
8
+ import './vendor/env.2ltrQNq0.js';
9
9
  import 'std-env';
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,2 @@
1
- import * as _vitest_utils_source_map from '@vitest/utils/source-map';
2
1
  export * from '@vitest/utils';
3
-
4
- declare function loadSourceMapUtils(): Promise<typeof _vitest_utils_source_map>;
5
-
6
- export { loadSourceMapUtils };
2
+ export * from '@vitest/utils/source-map';
package/dist/utils.js CHANGED
@@ -1,7 +1,2 @@
1
1
  export * from '@vitest/utils';
2
-
3
- function loadSourceMapUtils() {
4
- return import('@vitest/utils/source-map');
5
- }
6
-
7
- export { loadSourceMapUtils };
2
+ export * from '@vitest/utils/source-map';
@@ -17,28 +17,25 @@ function isPrimitive(value) {
17
17
  return value === null || typeof value !== "function" && typeof value !== "object";
18
18
  }
19
19
  function getAllMockableProperties(obj, isModule, constructors) {
20
- const {
21
- Map,
22
- Object: Object2,
23
- Function,
24
- RegExp: RegExp2,
25
- Array: Array2
26
- } = constructors;
20
+ const { Map, Object: Object2, Function, RegExp: RegExp2, Array: Array2 } = constructors;
27
21
  const allProps = new Map();
28
22
  let curr = obj;
29
23
  do {
30
- if (curr === Object2.prototype || curr === Function.prototype || curr === RegExp2.prototype)
24
+ if (curr === Object2.prototype || curr === Function.prototype || curr === RegExp2.prototype) {
31
25
  break;
26
+ }
32
27
  collectOwnProperties(curr, (key) => {
33
28
  const descriptor = Object2.getOwnPropertyDescriptor(curr, key);
34
- if (descriptor)
29
+ if (descriptor) {
35
30
  allProps.set(key, { key, descriptor });
31
+ }
36
32
  });
37
33
  } while (curr = Object2.getPrototypeOf(curr));
38
34
  if (isModule && !allProps.has("default") && "default" in obj) {
39
35
  const descriptor = Object2.getOwnPropertyDescriptor(obj, "default");
40
- if (descriptor)
36
+ if (descriptor) {
41
37
  allProps.set("default", { key: "default", descriptor });
38
+ }
42
39
  }
43
40
  return Array2.from(allProps.values());
44
41
  }
@@ -48,10 +45,12 @@ function slash(str) {
48
45
  function noop() {
49
46
  }
50
47
  function toArray(array) {
51
- if (array === null || array === void 0)
48
+ if (array === null || array === void 0) {
52
49
  array = [];
53
- if (Array.isArray(array))
50
+ }
51
+ if (Array.isArray(array)) {
54
52
  return array;
53
+ }
55
54
  return [array];
56
55
  }
57
56
  function toString(v) {
@@ -61,16 +60,19 @@ function isPlainObject(val) {
61
60
  return toString(val) === "[object Object]" && (!val.constructor || val.constructor.name === "Object");
62
61
  }
63
62
  function deepMerge(target, ...sources) {
64
- if (!sources.length)
63
+ if (!sources.length) {
65
64
  return target;
65
+ }
66
66
  const source = sources.shift();
67
- if (source === void 0)
67
+ if (source === void 0) {
68
68
  return target;
69
+ }
69
70
  if (isMergeableObject(target) && isMergeableObject(source)) {
70
71
  Object.keys(source).forEach((key) => {
71
72
  if (isMergeableObject(source[key])) {
72
- if (!target[key])
73
+ if (!target[key]) {
73
74
  target[key] = {};
75
+ }
74
76
  deepMerge(target[key], source[key]);
75
77
  } else {
76
78
  target[key] = source[key];
@@ -105,13 +107,18 @@ function escapeRegExp(s) {
105
107
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
106
108
  }
107
109
  function wildcardPatternToRegExp(pattern) {
108
- return new RegExp(`^${pattern.split("*").map(escapeRegExp).join(".*")}$`, "i");
110
+ return new RegExp(
111
+ `^${pattern.split("*").map(escapeRegExp).join(".*")}$`,
112
+ "i"
113
+ );
109
114
  }
110
115
  const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
111
116
  function nanoid(size = 21) {
112
117
  let id = "";
113
118
  let i = size;
114
- while (i--) id += urlAlphabet[Math.random() * 64 | 0];
119
+ while (i--) {
120
+ id += urlAlphabet[Math.random() * 64 | 0];
121
+ }
115
122
  return id;
116
123
  }
117
124
 
@@ -1,17 +1,18 @@
1
1
  import { ModuleCacheMap } from 'vite-node/client';
2
2
  import { p as provideWorkerState } from './global.7bFbnyXl.js';
3
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.BHj6OMh4.js';
3
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.Dx503nGn.js';
4
4
 
5
5
  let _viteNode;
6
6
  const moduleCache = new ModuleCacheMap();
7
7
  const mockMap = /* @__PURE__ */ new Map();
8
8
  async function startViteNode(options) {
9
- if (_viteNode)
9
+ if (_viteNode) {
10
10
  return _viteNode;
11
+ }
11
12
  _viteNode = await startVitestExecutor(options);
12
13
  return _viteNode;
13
14
  }
14
- async function runBaseTests(state) {
15
+ async function runBaseTests(method, state) {
15
16
  const { ctx } = state;
16
17
  state.moduleCache = moduleCache;
17
18
  state.mockMap = mockMap;
@@ -25,9 +26,10 @@ async function runBaseTests(state) {
25
26
  ctx.files.forEach((i) => state.moduleCache.delete(i));
26
27
  const [executor, { run }] = await Promise.all([
27
28
  startViteNode({ state, requestStubs: getDefaultRequestStubs() }),
28
- import('../chunks/runtime-runBaseTests.C-Bkopka.js')
29
+ import('../chunks/runtime-runBaseTests.DX3h28Mp.js')
29
30
  ]);
30
31
  await run(
32
+ method,
31
33
  ctx.files,
32
34
  ctx.config,
33
35
  { environment: state.environment, options: ctx.environment.options },
@@ -1,7 +1,7 @@
1
1
  import { getCurrentSuite } from '@vitest/runner';
2
2
  import { createChainable } from '@vitest/runner/utils';
3
3
  import { noop } from '@vitest/utils';
4
- import { i as isRunningInBenchmark } from './index._7XLd8Kd.js';
4
+ import { i as isRunningInBenchmark } from './index.BJmtb_7W.js';
5
5
 
6
6
  const benchFns = /* @__PURE__ */ new WeakMap();
7
7
  const benchOptsMap = /* @__PURE__ */ new WeakMap();
@@ -11,20 +11,19 @@ function getBenchOptions(key) {
11
11
  function getBenchFn(key) {
12
12
  return benchFns.get(key);
13
13
  }
14
- const bench = createBenchmark(
15
- function(name, fn = noop, options = {}) {
16
- if (!isRunningInBenchmark())
17
- throw new Error("`bench()` is only available in benchmark mode.");
18
- const task = getCurrentSuite().task(formatName(name), {
19
- ...this,
20
- meta: {
21
- benchmark: true
22
- }
23
- });
24
- benchFns.set(task, fn);
25
- benchOptsMap.set(task, options);
14
+ const bench = createBenchmark(function(name, fn = noop, options = {}) {
15
+ if (!isRunningInBenchmark()) {
16
+ throw new Error("`bench()` is only available in benchmark mode.");
26
17
  }
27
- );
18
+ const task = getCurrentSuite().task(formatName(name), {
19
+ ...this,
20
+ meta: {
21
+ benchmark: true
22
+ }
23
+ });
24
+ benchFns.set(task, fn);
25
+ benchOptsMap.set(task, options);
26
+ });
28
27
  function createBenchmark(fn) {
29
28
  const benchmark = createChainable(
30
29
  ["skip", "only", "todo"],