vitest 2.0.0-beta.1 → 2.0.0-beta.11
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/LICENSE.md +1 -1
- package/dist/browser.d.ts +22 -2
- package/dist/browser.js +5 -3
- package/dist/chunks/{integrations-globals.B5Jl0grA.js → integrations-globals.CC2ed6Py.js} +9 -9
- package/dist/chunks/{node-git.CCI8evVZ.js → node-git.ZtkbKc8u.js} +14 -15
- package/dist/chunks/{runtime-console.CUES-L8X.js → runtime-console.Ckl0vEQr.js} +76 -31
- package/dist/chunks/{runtime-runBaseTests._dXkRAZc.js → runtime-runBaseTests.BXW_BJeO.js} +40 -32
- package/dist/cli.js +3 -3
- package/dist/config.cjs +43 -20
- package/dist/config.d.ts +2 -2
- package/dist/config.js +43 -21
- package/dist/coverage.d.ts +4 -4
- package/dist/coverage.js +125 -37
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +2 -2
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +20 -30
- package/dist/index.js +9 -9
- package/dist/node.d.ts +22 -9
- package/dist/node.js +25 -15
- package/dist/path.js +4 -1
- package/dist/{reporters-MGvT5U9f.d.ts → reporters-fiIq_dT9.d.ts} +310 -148
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +8 -8
- package/dist/runners.d.ts +4 -2
- package/dist/runners.js +103 -57
- package/dist/{suite-8WAe-urM.d.ts → suite-D4aoU9rI.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +2 -2
- package/dist/utils.d.ts +1 -5
- package/dist/utils.js +1 -6
- package/dist/vendor/{base.VFkIJ66g.js → base.C2DbLEfT.js} +4 -3
- package/dist/vendor/{base._gnK9Slw.js → base.CTYV4Gnz.js} +24 -17
- package/dist/vendor/{benchmark.BNLebNi5.js → benchmark.CMp8QfyL.js} +13 -14
- package/dist/vendor/{cac.DzKZaJu2.js → cac.BcJW7n2j.js} +127 -51
- package/dist/vendor/{cli-api.DTeni0Qq.js → cli-api.C8t8m4__.js} +2771 -1711
- package/dist/vendor/{constants.5SOfHUj0.js → constants.BWsVtsAj.js} +6 -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/{execute.CLLNVNnK.js → execute.T3gg2ZK6.js} +177 -63
- package/dist/vendor/{index.BfoZyXD1.js → index.-dbR4KUi.js} +17 -9
- package/dist/vendor/{index.CRxYS9H3.js → index.BC5zhX9y.js} +1201 -491
- package/dist/vendor/{index.DP-km6lF.js → index.BMmMjLIQ.js} +64 -51
- package/dist/vendor/{index._7XLd8Kd.js → index.C9Thslzw.js} +2 -1
- package/dist/vendor/{index.CmILuxzC.js → index.CQJ2m700.js} +3 -3
- package/dist/vendor/{index.DeR1hhfY.js → index.D4nqnQWz.js} +71 -74
- 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.XeoZAW8t.js → setup-common.uqZOEWuR.js} +30 -15
- package/dist/vendor/spy.Cf_4R5Oe.js +22 -0
- package/dist/vendor/{tasks.WC7M-K-v.js → tasks.DhVtQBtW.js} +3 -1
- package/dist/vendor/{utils.D5gGkwyH.js → utils.DSO2UK15.js} +41 -26
- package/dist/vendor/{utils.CUjzkRH7.js → utils.DkxLWvS1.js} +12 -5
- package/dist/vendor/{vi.ClD3hi7L.js → vi.BPjl8cAZ.js} +350 -166
- package/dist/vendor/{vm.Bi3bljci.js → vm.CycSoHnJ.js} +151 -86
- package/dist/worker.js +31 -15
- package/dist/workers/forks.js +4 -4
- package/dist/workers/runVmTests.js +14 -13
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +6 -6
- package/dist/workers/vmThreads.js +6 -6
- package/dist/workers.d.ts +2 -2
- package/dist/workers.js +9 -9
- package/package.json +22 -22
- package/suppress-warnings.cjs +2 -4
package/dist/reporters.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { b6 as BaseReporter, aZ as BasicReporter, be as BenchmarkBuiltinReporters, bd as BenchmarkReportsMap, b9 as BuiltinReporterOptions, b8 as BuiltinReporters, aY as DefaultReporter, a_ as DotReporter, b5 as GithubActionsReporter, b4 as HangingProcessReporter, b2 as JUnitReporter, ba as JsonAssertionResult, a$ as JsonReporter, bb as JsonTestResult, bc as JsonTestResults, j as Reporter, b7 as ReportersMap, b3 as TapFlatReporter, b1 as TapReporter, b0 as VerboseReporter } from './reporters-fiIq_dT9.js';
|
|
2
2
|
import 'vite';
|
|
3
3
|
import '@vitest/runner';
|
|
4
4
|
import 'vite-node';
|
package/dist/reporters.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export {
|
|
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.BC5zhX9y.js';
|
|
2
2
|
import 'node:fs';
|
|
3
3
|
import 'picocolors';
|
|
4
4
|
import 'pathe';
|
|
5
|
-
import './vendor/tasks.
|
|
5
|
+
import './vendor/tasks.DhVtQBtW.js';
|
|
6
6
|
import '@vitest/runner/utils';
|
|
7
7
|
import '@vitest/utils';
|
|
8
8
|
import './vendor/env.bmJgw1qP.js';
|
|
9
9
|
import 'std-env';
|
|
10
|
-
import './vendor/utils.
|
|
11
|
-
import './vendor/base.
|
|
10
|
+
import './vendor/utils.DSO2UK15.js';
|
|
11
|
+
import './vendor/base.CTYV4Gnz.js';
|
|
12
12
|
import 'node:perf_hooks';
|
|
13
|
-
import '
|
|
13
|
+
import '@vitest/utils/source-map';
|
|
14
|
+
import './vendor/index.C9Thslzw.js';
|
|
14
15
|
import './vendor/global.7bFbnyXl.js';
|
|
15
|
-
import './chunks/runtime-console.
|
|
16
|
+
import './chunks/runtime-console.Ckl0vEQr.js';
|
|
16
17
|
import 'node:stream';
|
|
17
18
|
import 'node:console';
|
|
18
19
|
import 'node:path';
|
|
19
|
-
import './vendor/date.
|
|
20
|
-
import '@vitest/utils/source-map';
|
|
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 { VitestRunner, VitestRunnerImportSource, Suite, Task, CancelReason, Test, Custom, TaskContext, ExtendedContext } from '@vitest/runner';
|
|
2
|
-
import { R as ResolvedConfig } from './reporters-
|
|
1
|
+
import { VitestRunner, VitestRunnerImportSource, File, Suite, Task, CancelReason, Test, Custom, TaskContext, ExtendedContext } from '@vitest/runner';
|
|
2
|
+
import { R as ResolvedConfig } from './reporters-fiIq_dT9.js';
|
|
3
3
|
import * as tinybench from 'tinybench';
|
|
4
4
|
import 'vite';
|
|
5
5
|
import 'vite-node';
|
|
@@ -21,8 +21,10 @@ declare class VitestTestRunner implements VitestRunner {
|
|
|
21
21
|
private workerState;
|
|
22
22
|
private __vitest_executor;
|
|
23
23
|
private cancelRun;
|
|
24
|
+
private assertionsErrors;
|
|
24
25
|
constructor(config: ResolvedConfig);
|
|
25
26
|
importFile(filepath: string, source: VitestRunnerImportSource): unknown;
|
|
27
|
+
onCollectStart(file: File): void;
|
|
26
28
|
onBeforeRunFiles(): void;
|
|
27
29
|
onAfterRunFiles(): void;
|
|
28
30
|
onAfterRunSuite(suite: Suite): Promise<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.
|
|
2
|
+
import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.BPjl8cAZ.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
7
|
import './vendor/env.bmJgw1qP.js';
|
|
8
|
-
import { r as rpc } from './vendor/rpc.
|
|
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.CMp8QfyL.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.C9Thslzw.js';
|
|
23
23
|
|
|
24
24
|
class VitestTestRunner {
|
|
25
25
|
constructor(config) {
|
|
@@ -29,11 +29,16 @@ class VitestTestRunner {
|
|
|
29
29
|
workerState = getWorkerState();
|
|
30
30
|
__vitest_executor;
|
|
31
31
|
cancelRun = false;
|
|
32
|
+
assertionsErrors = /* @__PURE__ */ new WeakMap();
|
|
32
33
|
importFile(filepath, source) {
|
|
33
|
-
if (source === "setup")
|
|
34
|
+
if (source === "setup") {
|
|
34
35
|
this.workerState.moduleCache.delete(filepath);
|
|
36
|
+
}
|
|
35
37
|
return this.__vitest_executor.executeId(filepath);
|
|
36
38
|
}
|
|
39
|
+
onCollectStart(file) {
|
|
40
|
+
this.workerState.current = file;
|
|
41
|
+
}
|
|
37
42
|
onBeforeRunFiles() {
|
|
38
43
|
this.snapshotClient.clear();
|
|
39
44
|
}
|
|
@@ -41,8 +46,9 @@ class VitestTestRunner {
|
|
|
41
46
|
this.workerState.current = void 0;
|
|
42
47
|
}
|
|
43
48
|
async onAfterRunSuite(suite) {
|
|
44
|
-
if (this.config.logHeapUsage && typeof process !== "undefined")
|
|
49
|
+
if (this.config.logHeapUsage && typeof process !== "undefined") {
|
|
45
50
|
suite.result.heap = process.memoryUsage().heapUsed;
|
|
51
|
+
}
|
|
46
52
|
if (suite.mode !== "skip" && "filepath" in suite) {
|
|
47
53
|
for (const test of getTests(suite)) {
|
|
48
54
|
if (test.mode === "skip") {
|
|
@@ -51,47 +57,59 @@ class VitestTestRunner {
|
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
const result = await this.snapshotClient.finishCurrentRun();
|
|
54
|
-
if (result)
|
|
60
|
+
if (result) {
|
|
55
61
|
await rpc().snapshotSaved(result);
|
|
62
|
+
}
|
|
56
63
|
}
|
|
57
64
|
this.workerState.current = suite.suite || suite.file;
|
|
58
65
|
}
|
|
59
66
|
onAfterRunTask(test) {
|
|
60
67
|
this.snapshotClient.clearTest();
|
|
61
|
-
if (this.config.logHeapUsage && typeof process !== "undefined")
|
|
68
|
+
if (this.config.logHeapUsage && typeof process !== "undefined") {
|
|
62
69
|
test.result.heap = process.memoryUsage().heapUsed;
|
|
70
|
+
}
|
|
63
71
|
this.workerState.current = test.suite || test.file;
|
|
64
72
|
}
|
|
65
73
|
onCancel(_reason) {
|
|
66
74
|
this.cancelRun = true;
|
|
67
75
|
}
|
|
68
76
|
async onBeforeRunTask(test) {
|
|
69
|
-
if (this.cancelRun)
|
|
77
|
+
if (this.cancelRun) {
|
|
70
78
|
test.mode = "skip";
|
|
71
|
-
|
|
79
|
+
}
|
|
80
|
+
if (test.mode !== "run") {
|
|
72
81
|
return;
|
|
82
|
+
}
|
|
73
83
|
clearModuleMocks(this.config);
|
|
74
84
|
this.workerState.current = test;
|
|
75
85
|
}
|
|
76
86
|
async onBeforeRunSuite(suite) {
|
|
77
|
-
if (this.cancelRun)
|
|
87
|
+
if (this.cancelRun) {
|
|
78
88
|
suite.mode = "skip";
|
|
89
|
+
}
|
|
79
90
|
if (suite.mode !== "skip" && "filepath" in suite) {
|
|
80
|
-
await this.snapshotClient.startCurrentRun(
|
|
91
|
+
await this.snapshotClient.startCurrentRun(
|
|
92
|
+
suite.filepath,
|
|
93
|
+
"__default_name_",
|
|
94
|
+
this.workerState.config.snapshotOptions
|
|
95
|
+
);
|
|
81
96
|
}
|
|
82
97
|
this.workerState.current = suite;
|
|
83
98
|
}
|
|
84
99
|
onBeforeTryTask(test) {
|
|
85
|
-
setState(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
+
);
|
|
95
113
|
}
|
|
96
114
|
onAfterTryTask(test) {
|
|
97
115
|
const {
|
|
@@ -100,19 +118,30 @@ class VitestTestRunner {
|
|
|
100
118
|
expectedAssertionsNumberErrorGen,
|
|
101
119
|
isExpectingAssertions,
|
|
102
120
|
isExpectingAssertionsError
|
|
103
|
-
// @ts-expect-error _local is untyped
|
|
104
121
|
} = "context" in test && test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
|
|
105
|
-
if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber)
|
|
122
|
+
if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber) {
|
|
106
123
|
throw expectedAssertionsNumberErrorGen();
|
|
107
|
-
|
|
124
|
+
}
|
|
125
|
+
if (isExpectingAssertions === true && assertionCalls === 0) {
|
|
108
126
|
throw isExpectingAssertionsError;
|
|
127
|
+
}
|
|
128
|
+
if (this.config.expect.requireAssertions && assertionCalls === 0) {
|
|
129
|
+
throw this.assertionsErrors.get(test);
|
|
130
|
+
}
|
|
109
131
|
}
|
|
110
132
|
extendTaskContext(context) {
|
|
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
|
+
}
|
|
111
139
|
let _expect;
|
|
112
140
|
Object.defineProperty(context, "expect", {
|
|
113
141
|
get() {
|
|
114
|
-
if (!_expect)
|
|
142
|
+
if (!_expect) {
|
|
115
143
|
_expect = createExpect(context.task);
|
|
144
|
+
}
|
|
116
145
|
return _expect;
|
|
117
146
|
}
|
|
118
147
|
});
|
|
@@ -126,16 +155,19 @@ class VitestTestRunner {
|
|
|
126
155
|
}
|
|
127
156
|
function clearModuleMocks(config) {
|
|
128
157
|
const { clearMocks, mockReset, restoreMocks, unstubEnvs, unstubGlobals } = config;
|
|
129
|
-
if (restoreMocks)
|
|
158
|
+
if (restoreMocks) {
|
|
130
159
|
vi.restoreAllMocks();
|
|
131
|
-
else if (mockReset)
|
|
160
|
+
} else if (mockReset) {
|
|
132
161
|
vi.resetAllMocks();
|
|
133
|
-
else if (clearMocks)
|
|
162
|
+
} else if (clearMocks) {
|
|
134
163
|
vi.clearAllMocks();
|
|
135
|
-
|
|
164
|
+
}
|
|
165
|
+
if (unstubEnvs) {
|
|
136
166
|
vi.unstubAllEnvs();
|
|
137
|
-
|
|
167
|
+
}
|
|
168
|
+
if (unstubGlobals) {
|
|
138
169
|
vi.unstubAllGlobals();
|
|
170
|
+
}
|
|
139
171
|
}
|
|
140
172
|
|
|
141
173
|
function createBenchmarkResult(name) {
|
|
@@ -154,15 +186,18 @@ async function runBenchmarkSuite(suite, runner) {
|
|
|
154
186
|
const benchmarkGroup = [];
|
|
155
187
|
const benchmarkSuiteGroup = [];
|
|
156
188
|
for (const task of suite.tasks) {
|
|
157
|
-
if (task.mode !== "run")
|
|
189
|
+
if (task.mode !== "run") {
|
|
158
190
|
continue;
|
|
159
|
-
|
|
191
|
+
}
|
|
192
|
+
if ((_a = task.meta) == null ? void 0 : _a.benchmark) {
|
|
160
193
|
benchmarkGroup.push(task);
|
|
161
|
-
else if (task.type === "suite")
|
|
194
|
+
} else if (task.type === "suite") {
|
|
162
195
|
benchmarkSuiteGroup.push(task);
|
|
196
|
+
}
|
|
163
197
|
}
|
|
164
|
-
for (const subSuite of benchmarkSuiteGroup)
|
|
198
|
+
for (const subSuite of benchmarkSuiteGroup) {
|
|
165
199
|
await runBenchmarkSuite(subSuite, runner);
|
|
200
|
+
}
|
|
166
201
|
if (benchmarkGroup.length) {
|
|
167
202
|
const defer = createDefer();
|
|
168
203
|
suite.result = {
|
|
@@ -172,21 +207,29 @@ async function runBenchmarkSuite(suite, runner) {
|
|
|
172
207
|
};
|
|
173
208
|
updateTask$1(suite);
|
|
174
209
|
const addBenchTaskListener = (task, benchmark) => {
|
|
175
|
-
task.addEventListener(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
+
);
|
|
190
233
|
};
|
|
191
234
|
benchmarkGroup.forEach((benchmark) => {
|
|
192
235
|
const options = getBenchOptions(benchmark);
|
|
@@ -208,9 +251,11 @@ async function runBenchmarkSuite(suite, runner) {
|
|
|
208
251
|
const task = benchmarkTasks.get(benchmark);
|
|
209
252
|
await task.warmup();
|
|
210
253
|
tasks.push([
|
|
211
|
-
await new Promise(
|
|
212
|
-
resolve(
|
|
213
|
-
|
|
254
|
+
await new Promise(
|
|
255
|
+
(resolve) => setTimeout(async () => {
|
|
256
|
+
resolve(await task.run());
|
|
257
|
+
})
|
|
258
|
+
),
|
|
214
259
|
benchmark
|
|
215
260
|
]);
|
|
216
261
|
}
|
|
@@ -241,8 +286,9 @@ class NodeBenchmarkRunner {
|
|
|
241
286
|
return await import('tinybench');
|
|
242
287
|
}
|
|
243
288
|
importFile(filepath, source) {
|
|
244
|
-
if (source === "setup")
|
|
289
|
+
if (source === "setup") {
|
|
245
290
|
getWorkerState().moduleCache.delete(filepath);
|
|
291
|
+
}
|
|
246
292
|
return this.__vitest_executor.executeId(filepath);
|
|
247
293
|
}
|
|
248
294
|
async runSuite(suite) {
|
|
@@ -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-fiIq_dT9.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-D4aoU9rI.js';
|
|
4
|
+
import './reporters-fiIq_dT9.js';
|
|
5
5
|
import 'vite';
|
|
6
6
|
import 'vite-node';
|
|
7
7
|
import '@vitest/snapshot';
|
package/dist/suite.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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.CMp8QfyL.js';
|
|
4
4
|
import '@vitest/utils';
|
|
5
|
-
import './vendor/index.
|
|
5
|
+
import './vendor/index.C9Thslzw.js';
|
|
6
6
|
import 'pathe';
|
|
7
7
|
import './vendor/global.7bFbnyXl.js';
|
|
8
8
|
import './vendor/env.bmJgw1qP.js';
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
|
@@ -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.BXW_BJeO.js')
|
|
29
30
|
]);
|
|
30
31
|
await run(
|
|
31
32
|
ctx.files,
|
|
@@ -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,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.C9Thslzw.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"],
|