vitest 2.0.0-beta.10 → 2.0.0-beta.12
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.
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +3 -3
- package/dist/chunks/browser-creator.Bw94IHrL.js +673 -0
- package/dist/chunks/{environments-node.39w4gmlF.js → environments-node.XE5FbRPQ.js} +1 -1
- package/dist/chunks/{integrations-globals.C6Ah-pUW.js → integrations-globals.DSNOaUHv.js} +10 -10
- package/dist/chunks/{node-git.CCI8evVZ.js → node-git.ZtkbKc8u.js} +14 -15
- package/dist/chunks/{runtime-console.DiVMr5d4.js → runtime-console.O41g23Zj.js} +26 -11
- package/dist/chunks/{runtime-runBaseTests.Cukyr5-I.js → runtime-runBaseTests.BDt9gQFB.js} +41 -33
- package/dist/cli.js +3 -3
- package/dist/config.cjs +45 -21
- package/dist/config.d.ts +1 -1
- package/dist/config.js +45 -22
- package/dist/coverage.d.ts +5 -4
- package/dist/coverage.js +100 -37
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +37 -11
- package/dist/index.js +10 -10
- package/dist/node.d.ts +20 -7
- package/dist/node.js +29 -20
- package/dist/path.js +4 -1
- package/dist/{reporters-CYVC6LOl.d.ts → reporters-Cd1vkLMZ.d.ts} +134 -182
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +8 -8
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +99 -61
- package/dist/snapshot.js +2 -2
- package/dist/{suite-Dpu9EC_k.d.ts → suite-BS2CV79a.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +3 -3
- package/dist/utils.d.ts +1 -5
- package/dist/utils.js +1 -6
- package/dist/vendor/{base._gnK9Slw.js → base.CTYV4Gnz.js} +24 -17
- package/dist/vendor/{base.Dln9yllP.js → base.Cy97mmVC.js} +4 -3
- package/dist/vendor/{benchmark.BNLebNi5.js → benchmark.B6pblCp2.js} +13 -14
- package/dist/vendor/{cac.CtYFkoSJ.js → cac.DRNUX42m.js} +82 -38
- package/dist/vendor/{cli-api.CUtJc4r3.js → cli-api.Bu-PSdzx.js} +5908 -13271
- package/dist/vendor/{constants.TCjCaw2D.js → constants.BWsVtsAj.js} +5 -22
- package/dist/vendor/{coverage.ChSqD-qS.js → coverage.BhYSDdTT.js} +27 -11
- package/dist/vendor/{date.BKM1wewY.js → date.W2xKR2qe.js} +5 -3
- package/dist/vendor/env.2ltrQNq0.js +8 -0
- package/dist/vendor/{execute.BHj6OMh4.js → execute.T3gg2ZK6.js} +174 -60
- package/dist/vendor/{index.B5SKBLvV.js → index.B7pSlOSa.js} +18 -10
- package/dist/vendor/{index._7XLd8Kd.js → index.BJmtb_7W.js} +3 -2
- package/dist/vendor/{index.CThipSqB.js → index.BMmMjLIQ.js} +2540 -2540
- package/dist/vendor/{index.kpsSqFiz.js → index.D4nqnQWz.js} +69 -73
- package/dist/vendor/index.D6GZqexG.js +6575 -0
- package/dist/vendor/{index.D3hs2WiI.js → index.Hqvcg1pf.js} +3 -3
- package/dist/vendor/{index.BOMEjpjj.js → index.ZtQtNPP2.js} +962 -471
- package/dist/vendor/{rpc.DRDE9Pu1.js → rpc.BGx7q_k2.js} +30 -19
- package/dist/vendor/{run-once.DLomgGUH.js → run-once.Db8Hgq9X.js} +2 -1
- package/dist/vendor/{setup-common.DAu7t7mY.js → setup-common.CWnv_2-5.js} +30 -15
- package/dist/vendor/{tasks.WC7M-K-v.js → tasks.DhVtQBtW.js} +3 -1
- package/dist/vendor/{utils.YuQ3LT2a.js → utils.DSO2UK15.js} +40 -25
- package/dist/vendor/{utils.CUjzkRH7.js → utils.DkxLWvS1.js} +12 -5
- package/dist/vendor/{vi.hATFzZbX.js → vi.DXACdGTu.js} +267 -138
- package/dist/vendor/{vm.Ow-X2mkS.js → vm.D9wVR14y.js} +152 -87
- package/dist/worker.js +31 -15
- package/dist/workers/forks.js +4 -4
- package/dist/workers/runVmTests.js +15 -14
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +7 -7
- package/dist/workers/vmThreads.js +7 -7
- package/dist/workers.d.ts +2 -2
- package/dist/workers.js +10 -10
- package/package.json +11 -11
- package/suppress-warnings.cjs +1 -4
- package/dist/vendor/env.bmJgw1qP.js +0 -7
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.
|
|
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.
|
|
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.
|
|
8
|
-
import { r as rpc } from './vendor/rpc.
|
|
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.
|
|
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.
|
|
18
|
-
import './vendor/date.
|
|
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.
|
|
22
|
+
import './vendor/index.BJmtb_7W.js';
|
|
23
23
|
|
|
24
24
|
class VitestTestRunner {
|
|
25
25
|
constructor(config) {
|
|
@@ -31,8 +31,9 @@ class VitestTestRunner {
|
|
|
31
31
|
cancelRun = false;
|
|
32
32
|
assertionsErrors = /* @__PURE__ */ new WeakMap();
|
|
33
33
|
importFile(filepath, source) {
|
|
34
|
-
if (source === "setup")
|
|
34
|
+
if (source === "setup") {
|
|
35
35
|
this.workerState.moduleCache.delete(filepath);
|
|
36
|
+
}
|
|
36
37
|
return this.__vitest_executor.executeId(filepath);
|
|
37
38
|
}
|
|
38
39
|
onCollectStart(file) {
|
|
@@ -45,8 +46,9 @@ class VitestTestRunner {
|
|
|
45
46
|
this.workerState.current = void 0;
|
|
46
47
|
}
|
|
47
48
|
async onAfterRunSuite(suite) {
|
|
48
|
-
if (this.config.logHeapUsage && typeof process !== "undefined")
|
|
49
|
+
if (this.config.logHeapUsage && typeof process !== "undefined") {
|
|
49
50
|
suite.result.heap = process.memoryUsage().heapUsed;
|
|
51
|
+
}
|
|
50
52
|
if (suite.mode !== "skip" && "filepath" in suite) {
|
|
51
53
|
for (const test of getTests(suite)) {
|
|
52
54
|
if (test.mode === "skip") {
|
|
@@ -55,47 +57,59 @@ class VitestTestRunner {
|
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
const result = await this.snapshotClient.finishCurrentRun();
|
|
58
|
-
if (result)
|
|
60
|
+
if (result) {
|
|
59
61
|
await rpc().snapshotSaved(result);
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
64
|
this.workerState.current = suite.suite || suite.file;
|
|
62
65
|
}
|
|
63
66
|
onAfterRunTask(test) {
|
|
64
67
|
this.snapshotClient.clearTest();
|
|
65
|
-
if (this.config.logHeapUsage && typeof process !== "undefined")
|
|
68
|
+
if (this.config.logHeapUsage && typeof process !== "undefined") {
|
|
66
69
|
test.result.heap = process.memoryUsage().heapUsed;
|
|
70
|
+
}
|
|
67
71
|
this.workerState.current = test.suite || test.file;
|
|
68
72
|
}
|
|
69
73
|
onCancel(_reason) {
|
|
70
74
|
this.cancelRun = true;
|
|
71
75
|
}
|
|
72
76
|
async onBeforeRunTask(test) {
|
|
73
|
-
if (this.cancelRun)
|
|
77
|
+
if (this.cancelRun) {
|
|
74
78
|
test.mode = "skip";
|
|
75
|
-
|
|
79
|
+
}
|
|
80
|
+
if (test.mode !== "run") {
|
|
76
81
|
return;
|
|
82
|
+
}
|
|
77
83
|
clearModuleMocks(this.config);
|
|
78
84
|
this.workerState.current = test;
|
|
79
85
|
}
|
|
80
86
|
async onBeforeRunSuite(suite) {
|
|
81
|
-
if (this.cancelRun)
|
|
87
|
+
if (this.cancelRun) {
|
|
82
88
|
suite.mode = "skip";
|
|
89
|
+
}
|
|
83
90
|
if (suite.mode !== "skip" && "filepath" in suite) {
|
|
84
|
-
await this.snapshotClient.startCurrentRun(
|
|
91
|
+
await this.snapshotClient.startCurrentRun(
|
|
92
|
+
suite.filepath,
|
|
93
|
+
"__default_name_",
|
|
94
|
+
this.workerState.config.snapshotOptions
|
|
95
|
+
);
|
|
85
96
|
}
|
|
86
97
|
this.workerState.current = suite;
|
|
87
98
|
}
|
|
88
99
|
onBeforeTryTask(test) {
|
|
89
|
-
setState(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
setState(
|
|
101
|
+
{
|
|
102
|
+
assertionCalls: 0,
|
|
103
|
+
isExpectingAssertions: false,
|
|
104
|
+
isExpectingAssertionsError: null,
|
|
105
|
+
expectedAssertionsNumber: null,
|
|
106
|
+
expectedAssertionsNumberErrorGen: null,
|
|
107
|
+
testPath: test.file.filepath,
|
|
108
|
+
currentTestName: getTestName(test),
|
|
109
|
+
snapshotState: this.snapshotClient.snapshotState
|
|
110
|
+
},
|
|
111
|
+
globalThis[GLOBAL_EXPECT]
|
|
112
|
+
);
|
|
99
113
|
}
|
|
100
114
|
onAfterTryTask(test) {
|
|
101
115
|
const {
|
|
@@ -104,23 +118,30 @@ class VitestTestRunner {
|
|
|
104
118
|
expectedAssertionsNumberErrorGen,
|
|
105
119
|
isExpectingAssertions,
|
|
106
120
|
isExpectingAssertionsError
|
|
107
|
-
// @ts-expect-error _local is untyped
|
|
108
121
|
} = "context" in test && test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
|
|
109
|
-
if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber)
|
|
122
|
+
if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber) {
|
|
110
123
|
throw expectedAssertionsNumberErrorGen();
|
|
111
|
-
|
|
124
|
+
}
|
|
125
|
+
if (isExpectingAssertions === true && assertionCalls === 0) {
|
|
112
126
|
throw isExpectingAssertionsError;
|
|
113
|
-
|
|
127
|
+
}
|
|
128
|
+
if (this.config.expect.requireAssertions && assertionCalls === 0) {
|
|
114
129
|
throw this.assertionsErrors.get(test);
|
|
130
|
+
}
|
|
115
131
|
}
|
|
116
132
|
extendTaskContext(context) {
|
|
117
|
-
if (this.config.expect.requireAssertions)
|
|
118
|
-
this.assertionsErrors.set(
|
|
133
|
+
if (this.config.expect.requireAssertions) {
|
|
134
|
+
this.assertionsErrors.set(
|
|
135
|
+
context.task,
|
|
136
|
+
new Error("expected any number of assertion, but got none")
|
|
137
|
+
);
|
|
138
|
+
}
|
|
119
139
|
let _expect;
|
|
120
140
|
Object.defineProperty(context, "expect", {
|
|
121
141
|
get() {
|
|
122
|
-
if (!_expect)
|
|
142
|
+
if (!_expect) {
|
|
123
143
|
_expect = createExpect(context.task);
|
|
144
|
+
}
|
|
124
145
|
return _expect;
|
|
125
146
|
}
|
|
126
147
|
});
|
|
@@ -134,16 +155,19 @@ class VitestTestRunner {
|
|
|
134
155
|
}
|
|
135
156
|
function clearModuleMocks(config) {
|
|
136
157
|
const { clearMocks, mockReset, restoreMocks, unstubEnvs, unstubGlobals } = config;
|
|
137
|
-
if (restoreMocks)
|
|
158
|
+
if (restoreMocks) {
|
|
138
159
|
vi.restoreAllMocks();
|
|
139
|
-
else if (mockReset)
|
|
160
|
+
} else if (mockReset) {
|
|
140
161
|
vi.resetAllMocks();
|
|
141
|
-
else if (clearMocks)
|
|
162
|
+
} else if (clearMocks) {
|
|
142
163
|
vi.clearAllMocks();
|
|
143
|
-
|
|
164
|
+
}
|
|
165
|
+
if (unstubEnvs) {
|
|
144
166
|
vi.unstubAllEnvs();
|
|
145
|
-
|
|
167
|
+
}
|
|
168
|
+
if (unstubGlobals) {
|
|
146
169
|
vi.unstubAllGlobals();
|
|
170
|
+
}
|
|
147
171
|
}
|
|
148
172
|
|
|
149
173
|
function createBenchmarkResult(name) {
|
|
@@ -162,15 +186,18 @@ async function runBenchmarkSuite(suite, runner) {
|
|
|
162
186
|
const benchmarkGroup = [];
|
|
163
187
|
const benchmarkSuiteGroup = [];
|
|
164
188
|
for (const task of suite.tasks) {
|
|
165
|
-
if (task.mode !== "run")
|
|
189
|
+
if (task.mode !== "run") {
|
|
166
190
|
continue;
|
|
167
|
-
|
|
191
|
+
}
|
|
192
|
+
if ((_a = task.meta) == null ? void 0 : _a.benchmark) {
|
|
168
193
|
benchmarkGroup.push(task);
|
|
169
|
-
else if (task.type === "suite")
|
|
194
|
+
} else if (task.type === "suite") {
|
|
170
195
|
benchmarkSuiteGroup.push(task);
|
|
196
|
+
}
|
|
171
197
|
}
|
|
172
|
-
for (const subSuite of benchmarkSuiteGroup)
|
|
198
|
+
for (const subSuite of benchmarkSuiteGroup) {
|
|
173
199
|
await runBenchmarkSuite(subSuite, runner);
|
|
200
|
+
}
|
|
174
201
|
if (benchmarkGroup.length) {
|
|
175
202
|
const defer = createDefer();
|
|
176
203
|
suite.result = {
|
|
@@ -180,21 +207,29 @@ async function runBenchmarkSuite(suite, runner) {
|
|
|
180
207
|
};
|
|
181
208
|
updateTask$1(suite);
|
|
182
209
|
const addBenchTaskListener = (task, benchmark) => {
|
|
183
|
-
task.addEventListener(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
210
|
+
task.addEventListener(
|
|
211
|
+
"complete",
|
|
212
|
+
(e) => {
|
|
213
|
+
const task2 = e.task;
|
|
214
|
+
const taskRes = task2.result;
|
|
215
|
+
const result = benchmark.result.benchmark;
|
|
216
|
+
Object.assign(result, taskRes);
|
|
217
|
+
updateTask$1(benchmark);
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
once: true
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
task.addEventListener(
|
|
224
|
+
"error",
|
|
225
|
+
(e) => {
|
|
226
|
+
const task2 = e.task;
|
|
227
|
+
defer.reject(benchmark ? task2.result.error : e);
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
once: true
|
|
231
|
+
}
|
|
232
|
+
);
|
|
198
233
|
};
|
|
199
234
|
benchmarkGroup.forEach((benchmark) => {
|
|
200
235
|
const options = getBenchOptions(benchmark);
|
|
@@ -216,9 +251,11 @@ async function runBenchmarkSuite(suite, runner) {
|
|
|
216
251
|
const task = benchmarkTasks.get(benchmark);
|
|
217
252
|
await task.warmup();
|
|
218
253
|
tasks.push([
|
|
219
|
-
await new Promise(
|
|
220
|
-
resolve(
|
|
221
|
-
|
|
254
|
+
await new Promise(
|
|
255
|
+
(resolve) => setTimeout(async () => {
|
|
256
|
+
resolve(await task.run());
|
|
257
|
+
})
|
|
258
|
+
),
|
|
222
259
|
benchmark
|
|
223
260
|
]);
|
|
224
261
|
}
|
|
@@ -249,8 +286,9 @@ class NodeBenchmarkRunner {
|
|
|
249
286
|
return await import('tinybench');
|
|
250
287
|
}
|
|
251
288
|
importFile(filepath, source) {
|
|
252
|
-
if (source === "setup")
|
|
289
|
+
if (source === "setup") {
|
|
253
290
|
getWorkerState().moduleCache.delete(filepath);
|
|
291
|
+
}
|
|
254
292
|
return this.__vitest_executor.executeId(filepath);
|
|
255
293
|
}
|
|
256
294
|
async runSuite(suite) {
|
package/dist/snapshot.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/environments-node.
|
|
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.
|
|
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 {
|
|
3
|
+
import { ah as BenchFunction, ai as BenchmarkAPI } from './reporters-Cd1vkLMZ.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-
|
|
4
|
-
import './reporters-
|
|
3
|
+
export { g as getBenchFn, a as getBenchOptions } from './suite-BS2CV79a.js';
|
|
4
|
+
import './reporters-Cd1vkLMZ.js';
|
|
5
5
|
import 'vite';
|
|
6
6
|
import 'vite-node';
|
|
7
7
|
import '@vitest/snapshot';
|
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.
|
|
3
|
+
export { g as getBenchFn, a as getBenchOptions } from './vendor/benchmark.B6pblCp2.js';
|
|
4
4
|
import '@vitest/utils';
|
|
5
|
-
import './vendor/index.
|
|
5
|
+
import './vendor/index.BJmtb_7W.js';
|
|
6
6
|
import 'pathe';
|
|
7
7
|
import './vendor/global.7bFbnyXl.js';
|
|
8
|
-
import './vendor/env.
|
|
8
|
+
import './vendor/env.2ltrQNq0.js';
|
|
9
9
|
import 'std-env';
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
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--)
|
|
119
|
+
while (i--) {
|
|
120
|
+
id += urlAlphabet[Math.random() * 64 | 0];
|
|
121
|
+
}
|
|
115
122
|
return id;
|
|
116
123
|
}
|
|
117
124
|
|
|
@@ -1,13 +1,14 @@
|
|
|
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.
|
|
3
|
+
import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.T3gg2ZK6.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
|
}
|
|
@@ -25,7 +26,7 @@ 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.
|
|
29
|
+
import('../chunks/runtime-runBaseTests.BDt9gQFB.js')
|
|
29
30
|
]);
|
|
30
31
|
await run(
|
|
31
32
|
ctx.files,
|
|
@@ -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.
|
|
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
|
-
|
|
16
|
-
|
|
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"],
|