vitest 3.1.0-beta.1 → 3.1.0-beta.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 (85) hide show
  1. package/dist/browser.js +4 -4
  2. package/dist/chunks/base.CylSMlTD.js +41 -0
  3. package/dist/chunks/benchmark.BKUatJGy.js +39 -0
  4. package/dist/chunks/cac.JtTXbKz0.js +1525 -0
  5. package/dist/chunks/{cli-api.BwkkJsRe.js → cli-api.BTtPTYMs.js} +4638 -5072
  6. package/dist/chunks/console.D6t261w0.js +173 -0
  7. package/dist/chunks/constants.BZZyIeIE.js +43 -0
  8. package/dist/chunks/coverage.0iPg4Wrz.js +33 -0
  9. package/dist/chunks/{coverage.gV8doR2Y.js → coverage.C2ohxaN0.js} +2216 -2479
  10. package/dist/chunks/creator.BEXek7yQ.js +640 -0
  11. package/dist/chunks/date.CDOsz-HY.js +53 -0
  12. package/dist/chunks/defaults.DmfNPoe5.js +114 -0
  13. package/dist/chunks/{env.D4Lgay0q.js → env.Dq0hM4Xv.js} +1 -1
  14. package/dist/chunks/execute.DZKwfrTs.js +791 -0
  15. package/dist/chunks/git.DXfdBEfR.js +74 -0
  16. package/dist/chunks/{globals.BEpDe-k3.js → globals.DCbUWjip.js} +10 -10
  17. package/dist/chunks/{index.D7Ny8f_s.js → index.BDobFbcz.js} +6 -7
  18. package/dist/chunks/index.DFXFpH3w.js +607 -0
  19. package/dist/chunks/index.VfYQ6MXY.js +104 -0
  20. package/dist/chunks/index.ZIOEXBQB.js +2382 -0
  21. package/dist/chunks/inspector.DbDkSkFn.js +54 -0
  22. package/dist/chunks/node.IqGoMrm4.js +15 -0
  23. package/dist/chunks/{reporters.d.r7poTZjA.d.ts → reporters.d.5g6jXhoW.d.ts} +14 -3
  24. package/dist/chunks/rpc.DGgL5dw7.js +92 -0
  25. package/dist/chunks/run-once.I7PpBOk1.js +47 -0
  26. package/dist/chunks/runBaseTests.CqmKSG99.js +134 -0
  27. package/dist/chunks/setup-common.DEGDGBiA.js +88 -0
  28. package/dist/chunks/{typechecker.BlF3eHsb.js → typechecker.C2IpOhid.js} +620 -622
  29. package/dist/chunks/utils.BfxieIyZ.js +66 -0
  30. package/dist/chunks/utils.CtocqOoE.js +72 -0
  31. package/dist/chunks/utils.OLmtDstN.js +194 -0
  32. package/dist/chunks/{vi.nSCvwQ7l.js → vi.B-PuvDzu.js} +878 -1019
  33. package/dist/chunks/vite.d.Dh1jE-_V.d.ts +23 -0
  34. package/dist/chunks/vm.BW5voG-u.js +789 -0
  35. package/dist/cli.js +2 -2
  36. package/dist/config.cjs +97 -103
  37. package/dist/config.d.ts +3 -3
  38. package/dist/config.js +6 -6
  39. package/dist/coverage.d.ts +1 -1
  40. package/dist/coverage.js +6 -6
  41. package/dist/environments.js +1 -1
  42. package/dist/execute.js +1 -1
  43. package/dist/index.d.ts +2 -2
  44. package/dist/index.js +6 -6
  45. package/dist/node.d.ts +3 -3
  46. package/dist/node.js +36 -45
  47. package/dist/path.js +1 -4
  48. package/dist/reporters.d.ts +1 -1
  49. package/dist/reporters.js +4 -4
  50. package/dist/runners.js +231 -267
  51. package/dist/snapshot.js +2 -2
  52. package/dist/suite.js +2 -2
  53. package/dist/worker.js +98 -114
  54. package/dist/workers/forks.js +22 -22
  55. package/dist/workers/runVmTests.js +61 -66
  56. package/dist/workers/threads.js +13 -13
  57. package/dist/workers/vmForks.js +24 -24
  58. package/dist/workers/vmThreads.js +15 -15
  59. package/dist/workers.js +10 -10
  60. package/package.json +11 -11
  61. package/dist/chunks/base.DV59CbtV.js +0 -45
  62. package/dist/chunks/benchmark.DL72EVN-.js +0 -40
  63. package/dist/chunks/cac.BjmXy7OV.js +0 -1664
  64. package/dist/chunks/console.CN7AiMGV.js +0 -179
  65. package/dist/chunks/constants.DTYd6dNH.js +0 -46
  66. package/dist/chunks/coverage.A3sS5-Wm.js +0 -40
  67. package/dist/chunks/creator.BsBnpTzI.js +0 -670
  68. package/dist/chunks/date.W2xKR2qe.js +0 -53
  69. package/dist/chunks/defaults.C2Ndd9wx.js +0 -119
  70. package/dist/chunks/execute.eDH0aFFd.js +0 -839
  71. package/dist/chunks/git.B5SDxu-n.js +0 -69
  72. package/dist/chunks/index.DOyx6FYJ.js +0 -2551
  73. package/dist/chunks/index.K90BXFOx.js +0 -658
  74. package/dist/chunks/index.uXkkC4xl.js +0 -111
  75. package/dist/chunks/inspector.DKLceBVD.js +0 -54
  76. package/dist/chunks/node.AKq966Jp.js +0 -15
  77. package/dist/chunks/rpc.TVf73xOu.js +0 -102
  78. package/dist/chunks/run-once.2ogXb3JV.js +0 -28
  79. package/dist/chunks/runBaseTests.BVrL_ow3.js +0 -142
  80. package/dist/chunks/setup-common.CPvtqi8q.js +0 -96
  81. package/dist/chunks/utils.C8RiOc4B.js +0 -77
  82. package/dist/chunks/utils.Cn0zI1t3.js +0 -68
  83. package/dist/chunks/utils.bLM2atbD.js +0 -198
  84. package/dist/chunks/vite.d.Fvq-NZoa.d.ts +0 -11
  85. package/dist/chunks/vm.jEFQDlX_.js +0 -852
package/dist/runners.js CHANGED
@@ -1,292 +1,256 @@
1
1
  import { updateTask } from '@vitest/runner';
2
2
  import { createDefer, getSafeTimers } from '@vitest/utils';
3
- import { a as getBenchOptions, g as getBenchFn } from './chunks/benchmark.DL72EVN-.js';
4
- import { g as getWorkerState } from './chunks/utils.C8RiOc4B.js';
3
+ import { a as getBenchOptions, g as getBenchFn } from './chunks/benchmark.BKUatJGy.js';
4
+ import { g as getWorkerState } from './chunks/utils.CtocqOoE.js';
5
5
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
6
6
  import { getTests, getNames, getTestName } from '@vitest/runner/utils';
7
- import { g as getSnapshotClient, i as inject, c as createExpect, v as vi } from './chunks/vi.nSCvwQ7l.js';
8
- import { r as rpc } from './chunks/rpc.TVf73xOu.js';
7
+ import { g as getSnapshotClient, i as inject, c as createExpect, v as vi } from './chunks/vi.B-PuvDzu.js';
8
+ import { r as rpc } from './chunks/rpc.DGgL5dw7.js';
9
9
  import 'chai';
10
10
  import './chunks/_commonjsHelpers.BFTU3MAI.js';
11
11
  import '@vitest/snapshot';
12
12
  import '@vitest/utils/error';
13
13
  import '@vitest/spy';
14
14
  import '@vitest/utils/source-map';
15
- import './chunks/date.W2xKR2qe.js';
15
+ import './chunks/date.CDOsz-HY.js';
16
16
  import './chunks/index.68735LiX.js';
17
17
 
18
18
  function createBenchmarkResult(name) {
19
- return {
20
- name,
21
- rank: 0,
22
- rme: 0,
23
- samples: []
24
- };
19
+ return {
20
+ name,
21
+ rank: 0,
22
+ rme: 0,
23
+ samples: []
24
+ };
25
25
  }
26
- const benchmarkTasks = /* @__PURE__ */ new WeakMap();
26
+ const benchmarkTasks = new WeakMap();
27
27
  async function runBenchmarkSuite(suite, runner) {
28
- const { Task, Bench } = await runner.importTinybench();
29
- const start = performance.now();
30
- const benchmarkGroup = [];
31
- const benchmarkSuiteGroup = [];
32
- for (const task of suite.tasks) {
33
- if (task.mode !== "run" && task.mode !== "queued") {
34
- continue;
35
- }
36
- if (task.meta?.benchmark) {
37
- benchmarkGroup.push(task);
38
- } else if (task.type === "suite") {
39
- benchmarkSuiteGroup.push(task);
40
- }
41
- }
42
- for (const subSuite of benchmarkSuiteGroup) {
43
- await runBenchmarkSuite(subSuite, runner);
44
- }
45
- if (benchmarkGroup.length) {
46
- const defer = createDefer();
47
- suite.result = {
48
- state: "run",
49
- startTime: start,
50
- benchmark: createBenchmarkResult(suite.name)
51
- };
52
- updateTask$1("suite-prepare", suite);
53
- const addBenchTaskListener = (task, benchmark) => {
54
- task.addEventListener(
55
- "complete",
56
- (e) => {
57
- const task2 = e.task;
58
- const taskRes = task2.result;
59
- const result = benchmark.result.benchmark;
60
- benchmark.result.state = "pass";
61
- Object.assign(result, taskRes);
62
- const samples = result.samples;
63
- result.sampleCount = samples.length;
64
- result.median = samples.length % 2 ? samples[Math.floor(samples.length / 2)] : (samples[samples.length / 2] + samples[samples.length / 2 - 1]) / 2;
65
- if (!runner.config.benchmark?.includeSamples) {
66
- result.samples.length = 0;
67
- }
68
- updateTask$1("test-finished", benchmark);
69
- },
70
- {
71
- once: true
72
- }
73
- );
74
- task.addEventListener(
75
- "error",
76
- (e) => {
77
- const task2 = e.task;
78
- defer.reject(benchmark ? task2.result.error : e);
79
- },
80
- {
81
- once: true
82
- }
83
- );
84
- };
85
- benchmarkGroup.forEach((benchmark) => {
86
- const options = getBenchOptions(benchmark);
87
- const benchmarkInstance = new Bench(options);
88
- const benchmarkFn = getBenchFn(benchmark);
89
- benchmark.result = {
90
- state: "run",
91
- startTime: start,
92
- benchmark: createBenchmarkResult(benchmark.name)
93
- };
94
- const task = new Task(benchmarkInstance, benchmark.name, benchmarkFn);
95
- benchmarkTasks.set(benchmark, task);
96
- addBenchTaskListener(task, benchmark);
97
- });
98
- const { setTimeout } = getSafeTimers();
99
- const tasks = [];
100
- for (const benchmark of benchmarkGroup) {
101
- const task = benchmarkTasks.get(benchmark);
102
- updateTask$1("test-prepare", benchmark);
103
- await task.warmup();
104
- tasks.push([
105
- await new Promise(
106
- (resolve) => setTimeout(async () => {
107
- resolve(await task.run());
108
- })
109
- ),
110
- benchmark
111
- ]);
112
- }
113
- suite.result.duration = performance.now() - start;
114
- suite.result.state = "pass";
115
- updateTask$1("suite-finished", suite);
116
- defer.resolve(null);
117
- await defer;
118
- }
119
- function updateTask$1(event, task) {
120
- updateTask(event, task, runner);
121
- }
28
+ const { Task, Bench } = await runner.importTinybench();
29
+ const start = performance.now();
30
+ const benchmarkGroup = [];
31
+ const benchmarkSuiteGroup = [];
32
+ for (const task of suite.tasks) {
33
+ if (task.mode !== "run" && task.mode !== "queued") {
34
+ continue;
35
+ }
36
+ if (task.meta?.benchmark) {
37
+ benchmarkGroup.push(task);
38
+ } else if (task.type === "suite") {
39
+ benchmarkSuiteGroup.push(task);
40
+ }
41
+ }
42
+ for (const subSuite of benchmarkSuiteGroup) {
43
+ await runBenchmarkSuite(subSuite, runner);
44
+ }
45
+ if (benchmarkGroup.length) {
46
+ const defer = createDefer();
47
+ suite.result = {
48
+ state: "run",
49
+ startTime: start,
50
+ benchmark: createBenchmarkResult(suite.name)
51
+ };
52
+ updateTask$1("suite-prepare", suite);
53
+ const addBenchTaskListener = (task, benchmark) => {
54
+ task.addEventListener("complete", (e) => {
55
+ const task = e.task;
56
+ const taskRes = task.result;
57
+ const result = benchmark.result.benchmark;
58
+ benchmark.result.state = "pass";
59
+ Object.assign(result, taskRes);
60
+ const samples = result.samples;
61
+ result.sampleCount = samples.length;
62
+ result.median = samples.length % 2 ? samples[Math.floor(samples.length / 2)] : (samples[samples.length / 2] + samples[samples.length / 2 - 1]) / 2;
63
+ if (!runner.config.benchmark?.includeSamples) {
64
+ result.samples.length = 0;
65
+ }
66
+ updateTask$1("test-finished", benchmark);
67
+ }, { once: true });
68
+ task.addEventListener("error", (e) => {
69
+ const task = e.task;
70
+ defer.reject(benchmark ? task.result.error : e);
71
+ }, { once: true });
72
+ };
73
+ benchmarkGroup.forEach((benchmark) => {
74
+ const options = getBenchOptions(benchmark);
75
+ const benchmarkInstance = new Bench(options);
76
+ const benchmarkFn = getBenchFn(benchmark);
77
+ benchmark.result = {
78
+ state: "run",
79
+ startTime: start,
80
+ benchmark: createBenchmarkResult(benchmark.name)
81
+ };
82
+ const task = new Task(benchmarkInstance, benchmark.name, benchmarkFn);
83
+ benchmarkTasks.set(benchmark, task);
84
+ addBenchTaskListener(task, benchmark);
85
+ });
86
+ const { setTimeout } = getSafeTimers();
87
+ const tasks = [];
88
+ for (const benchmark of benchmarkGroup) {
89
+ const task = benchmarkTasks.get(benchmark);
90
+ updateTask$1("test-prepare", benchmark);
91
+ await task.warmup();
92
+ tasks.push([await new Promise((resolve) => setTimeout(async () => {
93
+ resolve(await task.run());
94
+ })), benchmark]);
95
+ }
96
+ suite.result.duration = performance.now() - start;
97
+ suite.result.state = "pass";
98
+ updateTask$1("suite-finished", suite);
99
+ defer.resolve(null);
100
+ await defer;
101
+ }
102
+ function updateTask$1(event, task) {
103
+ updateTask(event, task, runner);
104
+ }
122
105
  }
123
106
  class NodeBenchmarkRunner {
124
- constructor(config) {
125
- this.config = config;
126
- }
127
- __vitest_executor;
128
- async importTinybench() {
129
- return await import('tinybench');
130
- }
131
- importFile(filepath, source) {
132
- if (source === "setup") {
133
- getWorkerState().moduleCache.delete(filepath);
134
- }
135
- return this.__vitest_executor.executeId(filepath);
136
- }
137
- async runSuite(suite) {
138
- await runBenchmarkSuite(suite, this);
139
- }
140
- async runTask() {
141
- throw new Error("`test()` and `it()` is only available in test mode.");
142
- }
107
+ __vitest_executor;
108
+ constructor(config) {
109
+ this.config = config;
110
+ }
111
+ async importTinybench() {
112
+ return await import('tinybench');
113
+ }
114
+ importFile(filepath, source) {
115
+ if (source === "setup") {
116
+ getWorkerState().moduleCache.delete(filepath);
117
+ }
118
+ return this.__vitest_executor.executeId(filepath);
119
+ }
120
+ async runSuite(suite) {
121
+ await runBenchmarkSuite(suite, this);
122
+ }
123
+ async runTask() {
124
+ throw new Error("`test()` and `it()` is only available in test mode.");
125
+ }
143
126
  }
144
127
 
145
128
  class VitestTestRunner {
146
- constructor(config) {
147
- this.config = config;
148
- }
149
- snapshotClient = getSnapshotClient();
150
- workerState = getWorkerState();
151
- __vitest_executor;
152
- cancelRun = false;
153
- assertionsErrors = /* @__PURE__ */ new WeakMap();
154
- pool = this.workerState.ctx.pool;
155
- importFile(filepath, source) {
156
- if (source === "setup") {
157
- this.workerState.moduleCache.delete(filepath);
158
- }
159
- return this.__vitest_executor.executeId(filepath);
160
- }
161
- onCollectStart(file) {
162
- this.workerState.current = file;
163
- }
164
- onAfterRunFiles() {
165
- this.snapshotClient.clear();
166
- this.workerState.current = void 0;
167
- }
168
- async onAfterRunSuite(suite) {
169
- if (this.config.logHeapUsage && typeof process !== "undefined") {
170
- suite.result.heap = process.memoryUsage().heapUsed;
171
- }
172
- if (suite.mode !== "skip" && "filepath" in suite) {
173
- for (const test of getTests(suite)) {
174
- if (test.mode === "skip") {
175
- const name = getNames(test).slice(1).join(" > ");
176
- this.snapshotClient.skipTest(suite.file.filepath, name);
177
- }
178
- }
179
- const result = await this.snapshotClient.finish(suite.file.filepath);
180
- await rpc().snapshotSaved(result);
181
- }
182
- this.workerState.current = suite.suite || suite.file;
183
- }
184
- onAfterRunTask(test) {
185
- if (this.config.logHeapUsage && typeof process !== "undefined") {
186
- test.result.heap = process.memoryUsage().heapUsed;
187
- }
188
- this.workerState.current = test.suite || test.file;
189
- }
190
- onCancel(_reason) {
191
- this.cancelRun = true;
192
- }
193
- injectValue(key) {
194
- return inject(key);
195
- }
196
- async onBeforeRunTask(test) {
197
- if (this.cancelRun) {
198
- test.mode = "skip";
199
- }
200
- if (test.mode !== "run" && test.mode !== "queued") {
201
- return;
202
- }
203
- clearModuleMocks(this.config);
204
- this.workerState.current = test;
205
- }
206
- async onBeforeRunSuite(suite) {
207
- if (this.cancelRun) {
208
- suite.mode = "skip";
209
- }
210
- if (suite.mode !== "skip" && "filepath" in suite) {
211
- await this.snapshotClient.setup(
212
- suite.file.filepath,
213
- this.workerState.config.snapshotOptions
214
- );
215
- }
216
- this.workerState.current = suite;
217
- }
218
- onBeforeTryTask(test) {
219
- this.snapshotClient.clearTest(test.file.filepath, test.id);
220
- setState(
221
- {
222
- assertionCalls: 0,
223
- isExpectingAssertions: false,
224
- isExpectingAssertionsError: null,
225
- expectedAssertionsNumber: null,
226
- expectedAssertionsNumberErrorGen: null,
227
- currentTestName: getTestName(test),
228
- snapshotState: this.snapshotClient.getSnapshotState(test.file.filepath)
229
- },
230
- globalThis[GLOBAL_EXPECT]
231
- );
232
- }
233
- onAfterTryTask(test) {
234
- const {
235
- assertionCalls,
236
- expectedAssertionsNumber,
237
- expectedAssertionsNumberErrorGen,
238
- isExpectingAssertions,
239
- isExpectingAssertionsError
240
- } = "context" in test && test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
241
- if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber) {
242
- throw expectedAssertionsNumberErrorGen();
243
- }
244
- if (isExpectingAssertions === true && assertionCalls === 0) {
245
- throw isExpectingAssertionsError;
246
- }
247
- if (this.config.expect.requireAssertions && assertionCalls === 0) {
248
- throw this.assertionsErrors.get(test);
249
- }
250
- }
251
- extendTaskContext(context) {
252
- if (this.config.expect.requireAssertions) {
253
- this.assertionsErrors.set(
254
- context.task,
255
- new Error("expected any number of assertion, but got none")
256
- );
257
- }
258
- let _expect;
259
- Object.defineProperty(context, "expect", {
260
- get() {
261
- if (!_expect) {
262
- _expect = createExpect(context.task);
263
- }
264
- return _expect;
265
- }
266
- });
267
- Object.defineProperty(context, "_local", {
268
- get() {
269
- return _expect != null;
270
- }
271
- });
272
- return context;
273
- }
129
+ snapshotClient = getSnapshotClient();
130
+ workerState = getWorkerState();
131
+ __vitest_executor;
132
+ cancelRun = false;
133
+ assertionsErrors = new WeakMap();
134
+ pool = this.workerState.ctx.pool;
135
+ constructor(config) {
136
+ this.config = config;
137
+ }
138
+ importFile(filepath, source) {
139
+ if (source === "setup") {
140
+ this.workerState.moduleCache.delete(filepath);
141
+ }
142
+ return this.__vitest_executor.executeId(filepath);
143
+ }
144
+ onCollectStart(file) {
145
+ this.workerState.current = file;
146
+ }
147
+ onAfterRunFiles() {
148
+ this.snapshotClient.clear();
149
+ this.workerState.current = undefined;
150
+ }
151
+ async onAfterRunSuite(suite) {
152
+ if (this.config.logHeapUsage && typeof process !== "undefined") {
153
+ suite.result.heap = process.memoryUsage().heapUsed;
154
+ }
155
+ if (suite.mode !== "skip" && "filepath" in suite) {
156
+ for (const test of getTests(suite)) {
157
+ if (test.mode === "skip") {
158
+ const name = getNames(test).slice(1).join(" > ");
159
+ this.snapshotClient.skipTest(suite.file.filepath, name);
160
+ }
161
+ }
162
+ const result = await this.snapshotClient.finish(suite.file.filepath);
163
+ await rpc().snapshotSaved(result);
164
+ }
165
+ this.workerState.current = suite.suite || suite.file;
166
+ }
167
+ onAfterRunTask(test) {
168
+ if (this.config.logHeapUsage && typeof process !== "undefined") {
169
+ test.result.heap = process.memoryUsage().heapUsed;
170
+ }
171
+ this.workerState.current = test.suite || test.file;
172
+ }
173
+ onCancel(_reason) {
174
+ this.cancelRun = true;
175
+ }
176
+ injectValue(key) {
177
+ return inject(key);
178
+ }
179
+ async onBeforeRunTask(test) {
180
+ if (this.cancelRun) {
181
+ test.mode = "skip";
182
+ }
183
+ if (test.mode !== "run" && test.mode !== "queued") {
184
+ return;
185
+ }
186
+ clearModuleMocks(this.config);
187
+ this.workerState.current = test;
188
+ }
189
+ async onBeforeRunSuite(suite) {
190
+ if (this.cancelRun) {
191
+ suite.mode = "skip";
192
+ }
193
+ if (suite.mode !== "skip" && "filepath" in suite) {
194
+ await this.snapshotClient.setup(suite.file.filepath, this.workerState.config.snapshotOptions);
195
+ }
196
+ this.workerState.current = suite;
197
+ }
198
+ onBeforeTryTask(test) {
199
+ this.snapshotClient.clearTest(test.file.filepath, test.id);
200
+ setState({
201
+ assertionCalls: 0,
202
+ isExpectingAssertions: false,
203
+ isExpectingAssertionsError: null,
204
+ expectedAssertionsNumber: null,
205
+ expectedAssertionsNumberErrorGen: null,
206
+ currentTestName: getTestName(test),
207
+ snapshotState: this.snapshotClient.getSnapshotState(test.file.filepath)
208
+ }, globalThis[GLOBAL_EXPECT]);
209
+ }
210
+ onAfterTryTask(test) {
211
+ const { assertionCalls, expectedAssertionsNumber, expectedAssertionsNumberErrorGen, isExpectingAssertions, isExpectingAssertionsError } = "context" in test && test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
212
+ if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber) {
213
+ throw expectedAssertionsNumberErrorGen();
214
+ }
215
+ if (isExpectingAssertions === true && assertionCalls === 0) {
216
+ throw isExpectingAssertionsError;
217
+ }
218
+ if (this.config.expect.requireAssertions && assertionCalls === 0) {
219
+ throw this.assertionsErrors.get(test);
220
+ }
221
+ }
222
+ extendTaskContext(context) {
223
+ if (this.config.expect.requireAssertions) {
224
+ this.assertionsErrors.set(context.task, new Error("expected any number of assertion, but got none"));
225
+ }
226
+ let _expect;
227
+ Object.defineProperty(context, "expect", { get() {
228
+ if (!_expect) {
229
+ _expect = createExpect(context.task);
230
+ }
231
+ return _expect;
232
+ } });
233
+ Object.defineProperty(context, "_local", { get() {
234
+ return _expect != null;
235
+ } });
236
+ return context;
237
+ }
274
238
  }
275
239
  function clearModuleMocks(config) {
276
- const { clearMocks, mockReset, restoreMocks, unstubEnvs, unstubGlobals } = config;
277
- if (restoreMocks) {
278
- vi.restoreAllMocks();
279
- } else if (mockReset) {
280
- vi.resetAllMocks();
281
- } else if (clearMocks) {
282
- vi.clearAllMocks();
283
- }
284
- if (unstubEnvs) {
285
- vi.unstubAllEnvs();
286
- }
287
- if (unstubGlobals) {
288
- vi.unstubAllGlobals();
289
- }
240
+ const { clearMocks, mockReset, restoreMocks, unstubEnvs, unstubGlobals } = config;
241
+ if (restoreMocks) {
242
+ vi.restoreAllMocks();
243
+ } else if (mockReset) {
244
+ vi.resetAllMocks();
245
+ } else if (clearMocks) {
246
+ vi.clearAllMocks();
247
+ }
248
+ if (unstubEnvs) {
249
+ vi.unstubAllEnvs();
250
+ }
251
+ if (unstubGlobals) {
252
+ vi.unstubAllGlobals();
253
+ }
290
254
  }
291
255
 
292
256
  export { NodeBenchmarkRunner, VitestTestRunner };
package/dist/snapshot.js CHANGED
@@ -1,4 +1,4 @@
1
- export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.AKq966Jp.js';
1
+ export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.IqGoMrm4.js';
2
2
  import '@vitest/snapshot/environment';
3
- import './chunks/utils.C8RiOc4B.js';
3
+ import './chunks/utils.CtocqOoE.js';
4
4
  import '@vitest/utils';
package/dist/suite.js CHANGED
@@ -1,5 +1,5 @@
1
- export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.DL72EVN-.js';
1
+ export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.BKUatJGy.js';
2
2
  export { createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
3
3
  export { createChainable } from '@vitest/runner/utils';
4
4
  import '@vitest/utils';
5
- import './chunks/utils.C8RiOc4B.js';
5
+ import './chunks/utils.CtocqOoE.js';