vitest 4.0.0-beta.8 → 4.0.0-beta.9
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 +5 -5
- package/dist/browser.js +4 -4
- package/dist/chunks/{runBaseTests.D6sfuWBM.js → base.CA5N8Af0.js} +55 -26
- package/dist/chunks/{benchmark.UW6Ezvxy.js → benchmark.CJUa-Hsa.js} +1 -1
- package/dist/chunks/{browser.d.DOMmqJQx.d.ts → browser.d.DtfyY9yS.d.ts} +1 -1
- package/dist/chunks/{cac.By1HvRIk.js → cac.Dt7e1TIu.js} +6 -24
- package/dist/chunks/{cli-api.C-JHgQgp.js → cli-api.eAzsLIxz.js} +41 -32
- package/dist/chunks/{config.d._GBBbReY.d.ts → config.d.DacWrqWe.d.ts} +1 -0
- package/dist/chunks/{console.B0quX7yH.js → console.7h5kHUIf.js} +1 -1
- package/dist/chunks/{coverage.DarITf6U.js → coverage.CDRAMTt7.js} +19 -50
- package/dist/chunks/{globals.lgsmH00r.js → globals.CJrTTbxC.js} +5 -6
- package/dist/chunks/{index.AzwzFtyi.js → index.BIP7prJq.js} +1 -1
- package/dist/chunks/{index.BuwjkI-q.js → index.BjKEiSn0.js} +1 -1
- package/dist/chunks/{index.AR8aAkCC.js → index.C832ioot.js} +5 -6
- package/dist/chunks/{moduleRunner.d.CX4DuqOx.d.ts → moduleRunner.d.DxTLreRD.d.ts} +4 -1
- package/dist/chunks/{node.BOqcT2jW.js → node.CyipiPvJ.js} +1 -1
- package/dist/chunks/{plugin.d.CHe6slQs.d.ts → plugin.d.CIk0YiKb.d.ts} +1 -1
- package/dist/chunks/{reporters.d.37tJQ2uV.d.ts → reporters.d.DmP-iHLr.d.ts} +9 -16
- package/dist/chunks/{index.CsFXYRkW.js → resolveSnapshotEnvironment.Bvv2zr69.js} +16 -21
- package/dist/chunks/{rpc.RpPylpp0.js → rpc.BKr6mtxz.js} +1 -1
- package/dist/chunks/{setup-common.hLGRxhC8.js → setup-common.B7I37Tji.js} +4 -4
- package/dist/chunks/{startModuleRunner.C8TW8zTN.js → startModuleRunner.BDRvKSdz.js} +7 -2
- package/dist/chunks/test.BAlBebnP.js +214 -0
- package/dist/chunks/{typechecker.DSo_maXz.js → typechecker.DB-fIMaH.js} +44 -1
- package/dist/chunks/{utils.C7__0Iv5.js → utils.D2R2NiOH.js} +1 -10
- package/dist/chunks/{vi.BfdOiD4j.js → vi.BB37KeLx.js} +16 -16
- package/dist/chunks/{vm.BHBje7cC.js → vm.CjLTDaST.js} +12 -7
- package/dist/chunks/{worker.d.DYlqbejz.d.ts → worker.d.B2r4Ln6p.d.ts} +1 -1
- package/dist/chunks/{worker.d.BKu8cnnX.d.ts → worker.d.DJ6qxO2w.d.ts} +1 -1
- package/dist/cli.js +3 -3
- package/dist/config.d.ts +7 -7
- package/dist/coverage.d.ts +5 -5
- package/dist/coverage.js +2 -2
- package/dist/index.d.ts +11 -12
- package/dist/index.js +5 -8
- package/dist/module-evaluator.d.ts +4 -3
- package/dist/module-evaluator.js +3 -3
- package/dist/module-runner.js +2 -2
- package/dist/node.d.ts +9 -10
- package/dist/node.js +8 -8
- package/dist/reporters.d.ts +5 -5
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +11 -215
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +2 -3
- package/dist/workers/forks.js +27 -4
- package/dist/workers/runVmTests.js +18 -19
- package/dist/workers/threads.js +27 -4
- package/dist/workers/vmForks.js +4 -4
- package/dist/workers/vmThreads.js +4 -4
- package/dist/workers.d.ts +3 -3
- package/dist/workers.js +26 -8
- package/package.json +10 -13
- package/dist/chunks/base.BXI97p6t.js +0 -39
package/dist/runners.js
CHANGED
|
@@ -1,221 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import 'chai';
|
|
1
|
+
export { N as NodeBenchmarkRunner, V as VitestTestRunner } from './chunks/test.BAlBebnP.js';
|
|
2
|
+
import '@vitest/runner';
|
|
3
|
+
import '@vitest/utils';
|
|
4
|
+
import './chunks/benchmark.CJUa-Hsa.js';
|
|
5
|
+
import '@vitest/runner/utils';
|
|
6
|
+
import './chunks/utils.D2R2NiOH.js';
|
|
7
|
+
import '@vitest/expect';
|
|
8
|
+
import '@vitest/utils/error';
|
|
9
|
+
import 'pathe';
|
|
10
|
+
import './chunks/vi.BB37KeLx.js';
|
|
12
11
|
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
13
12
|
import '@vitest/snapshot';
|
|
14
13
|
import '@vitest/spy';
|
|
15
14
|
import '@vitest/utils/source-map';
|
|
16
15
|
import './chunks/date.-jtEtIeV.js';
|
|
16
|
+
import './chunks/rpc.BKr6mtxz.js';
|
|
17
17
|
import './chunks/index.Bgo3tNWt.js';
|
|
18
|
-
|
|
19
|
-
function createBenchmarkResult(name) {
|
|
20
|
-
return {
|
|
21
|
-
name,
|
|
22
|
-
rank: 0,
|
|
23
|
-
rme: 0,
|
|
24
|
-
samples: []
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
const benchmarkTasks = /* @__PURE__ */ new WeakMap();
|
|
28
|
-
async function runBenchmarkSuite(suite, runner) {
|
|
29
|
-
const { Task, Bench } = await runner.importTinybench(), start = performance.now(), benchmarkGroup = [], benchmarkSuiteGroup = [];
|
|
30
|
-
for (const task of suite.tasks) {
|
|
31
|
-
if (task.mode !== "run" && task.mode !== "queued") continue;
|
|
32
|
-
if (task.meta?.benchmark) benchmarkGroup.push(task);
|
|
33
|
-
else if (task.type === "suite") benchmarkSuiteGroup.push(task);
|
|
34
|
-
}
|
|
35
|
-
// run sub suites sequentially
|
|
36
|
-
for (const subSuite of benchmarkSuiteGroup) await runBenchmarkSuite(subSuite, runner);
|
|
37
|
-
if (benchmarkGroup.length) {
|
|
38
|
-
const defer = createDefer();
|
|
39
|
-
suite.result = {
|
|
40
|
-
state: "run",
|
|
41
|
-
startTime: start,
|
|
42
|
-
benchmark: createBenchmarkResult(suite.name)
|
|
43
|
-
}, updateTask$1("suite-prepare", suite);
|
|
44
|
-
const addBenchTaskListener = (task, benchmark) => {
|
|
45
|
-
task.addEventListener("complete", (e) => {
|
|
46
|
-
const task = e.task, taskRes = task.result, result = benchmark.result.benchmark;
|
|
47
|
-
benchmark.result.state = "pass", Object.assign(result, taskRes);
|
|
48
|
-
// compute extra stats and free raw samples as early as possible
|
|
49
|
-
const samples = result.samples;
|
|
50
|
-
if (result.sampleCount = samples.length, result.median = samples.length % 2 ? samples[Math.floor(samples.length / 2)] : (samples[samples.length / 2] + samples[samples.length / 2 - 1]) / 2, !runner.config.benchmark?.includeSamples) result.samples.length = 0;
|
|
51
|
-
updateTask$1("test-finished", benchmark);
|
|
52
|
-
}, { once: true }), task.addEventListener("error", (e) => {
|
|
53
|
-
const task = e.task;
|
|
54
|
-
defer.reject(benchmark ? task.result.error : e);
|
|
55
|
-
}, { once: true });
|
|
56
|
-
};
|
|
57
|
-
benchmarkGroup.forEach((benchmark) => {
|
|
58
|
-
const options = getBenchOptions(benchmark), benchmarkInstance = new Bench(options), benchmarkFn = getBenchFn(benchmark);
|
|
59
|
-
benchmark.result = {
|
|
60
|
-
state: "run",
|
|
61
|
-
startTime: start,
|
|
62
|
-
benchmark: createBenchmarkResult(benchmark.name)
|
|
63
|
-
};
|
|
64
|
-
const task = new Task(benchmarkInstance, benchmark.name, benchmarkFn);
|
|
65
|
-
benchmarkTasks.set(benchmark, task), addBenchTaskListener(task, benchmark);
|
|
66
|
-
});
|
|
67
|
-
const { setTimeout } = getSafeTimers(), tasks = [];
|
|
68
|
-
for (const benchmark of benchmarkGroup) {
|
|
69
|
-
const task = benchmarkTasks.get(benchmark);
|
|
70
|
-
updateTask$1("test-prepare", benchmark), await task.warmup(), tasks.push([await new Promise((resolve) => setTimeout(async () => {
|
|
71
|
-
resolve(await task.run());
|
|
72
|
-
})), benchmark]);
|
|
73
|
-
}
|
|
74
|
-
suite.result.duration = performance.now() - start, suite.result.state = "pass", updateTask$1("suite-finished", suite), defer.resolve(null), await defer;
|
|
75
|
-
}
|
|
76
|
-
function updateTask$1(event, task) {
|
|
77
|
-
updateTask(event, task, runner);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
class NodeBenchmarkRunner {
|
|
81
|
-
moduleRunner;
|
|
82
|
-
constructor(config) {
|
|
83
|
-
this.config = config;
|
|
84
|
-
}
|
|
85
|
-
async importTinybench() {
|
|
86
|
-
return await import('tinybench');
|
|
87
|
-
}
|
|
88
|
-
importFile(filepath, source) {
|
|
89
|
-
if (source === "setup") {
|
|
90
|
-
const moduleNode = getWorkerState().evaluatedModules.getModuleById(filepath);
|
|
91
|
-
if (moduleNode) getWorkerState().evaluatedModules.invalidateModule(moduleNode);
|
|
92
|
-
}
|
|
93
|
-
return this.moduleRunner.import(filepath);
|
|
94
|
-
}
|
|
95
|
-
async runSuite(suite) {
|
|
96
|
-
await runBenchmarkSuite(suite, this);
|
|
97
|
-
}
|
|
98
|
-
async runTask() {
|
|
99
|
-
throw new Error("`test()` and `it()` is only available in test mode.");
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// import type { VitestExecutor } from '../execute'
|
|
104
|
-
// worker context is shared between all tests
|
|
105
|
-
const workerContext = Object.create(null);
|
|
106
|
-
class VitestTestRunner {
|
|
107
|
-
snapshotClient = getSnapshotClient();
|
|
108
|
-
workerState = getWorkerState();
|
|
109
|
-
moduleRunner;
|
|
110
|
-
cancelRun = false;
|
|
111
|
-
assertionsErrors = /* @__PURE__ */ new WeakMap();
|
|
112
|
-
pool = this.workerState.ctx.pool;
|
|
113
|
-
constructor(config) {
|
|
114
|
-
this.config = config;
|
|
115
|
-
}
|
|
116
|
-
importFile(filepath, source) {
|
|
117
|
-
if (source === "setup") {
|
|
118
|
-
const moduleNode = this.workerState.evaluatedModules.getModuleById(filepath);
|
|
119
|
-
if (moduleNode) this.workerState.evaluatedModules.invalidateModule(moduleNode);
|
|
120
|
-
}
|
|
121
|
-
return this.moduleRunner.import(filepath);
|
|
122
|
-
}
|
|
123
|
-
onCollectStart(file) {
|
|
124
|
-
this.workerState.current = file;
|
|
125
|
-
}
|
|
126
|
-
onCleanupWorkerContext(listener) {
|
|
127
|
-
this.workerState.onCleanup(listener);
|
|
128
|
-
}
|
|
129
|
-
onAfterRunFiles() {
|
|
130
|
-
this.snapshotClient.clear(), this.workerState.current = void 0;
|
|
131
|
-
}
|
|
132
|
-
getWorkerContext() {
|
|
133
|
-
return workerContext;
|
|
134
|
-
}
|
|
135
|
-
async onAfterRunSuite(suite) {
|
|
136
|
-
if (this.config.logHeapUsage && typeof process !== "undefined") suite.result.heap = process.memoryUsage().heapUsed;
|
|
137
|
-
if (suite.mode !== "skip" && "filepath" in suite) {
|
|
138
|
-
// mark snapshots in skipped tests as not obsolete
|
|
139
|
-
for (const test of getTests(suite)) if (test.mode === "skip") {
|
|
140
|
-
const name = getNames(test).slice(1).join(" > ");
|
|
141
|
-
this.snapshotClient.skipTest(suite.file.filepath, name);
|
|
142
|
-
}
|
|
143
|
-
const result = await this.snapshotClient.finish(suite.file.filepath);
|
|
144
|
-
if (this.workerState.config.snapshotOptions.updateSnapshot === "none" && result.unchecked) {
|
|
145
|
-
let message = `Obsolete snapshots found when no snapshot update is expected.\n`;
|
|
146
|
-
for (const key of result.uncheckedKeys) message += `· ${key}\n`;
|
|
147
|
-
suite.result.errors ??= [], suite.result.errors.push(processError(new Error(message))), suite.result.state = "fail";
|
|
148
|
-
}
|
|
149
|
-
await rpc().snapshotSaved(result);
|
|
150
|
-
}
|
|
151
|
-
this.workerState.current = suite.suite || suite.file;
|
|
152
|
-
}
|
|
153
|
-
onAfterRunTask(test) {
|
|
154
|
-
if (this.config.logHeapUsage && typeof process !== "undefined") test.result.heap = process.memoryUsage().heapUsed;
|
|
155
|
-
this.workerState.current = test.suite || test.file;
|
|
156
|
-
}
|
|
157
|
-
cancel(_reason) {
|
|
158
|
-
this.cancelRun = true;
|
|
159
|
-
}
|
|
160
|
-
injectValue(key) {
|
|
161
|
-
// inject has a very limiting type controlled by ProvidedContext
|
|
162
|
-
// some tests override it which causes the build to fail
|
|
163
|
-
return inject(key);
|
|
164
|
-
}
|
|
165
|
-
async onBeforeRunTask(test) {
|
|
166
|
-
if (this.cancelRun) test.mode = "skip";
|
|
167
|
-
test.mode !== "run" && test.mode !== "queued" || (this.workerState.current = test);
|
|
168
|
-
}
|
|
169
|
-
async onBeforeRunSuite(suite) {
|
|
170
|
-
if (this.cancelRun) suite.mode = "skip";
|
|
171
|
-
// initialize snapshot state before running file suite
|
|
172
|
-
if (suite.mode !== "skip" && "filepath" in suite) await this.snapshotClient.setup(suite.file.filepath, this.workerState.config.snapshotOptions);
|
|
173
|
-
this.workerState.current = suite;
|
|
174
|
-
}
|
|
175
|
-
onBeforeTryTask(test) {
|
|
176
|
-
clearModuleMocks(this.config), this.snapshotClient.clearTest(test.file.filepath, test.id), setState({
|
|
177
|
-
assertionCalls: 0,
|
|
178
|
-
isExpectingAssertions: false,
|
|
179
|
-
isExpectingAssertionsError: null,
|
|
180
|
-
expectedAssertionsNumber: null,
|
|
181
|
-
expectedAssertionsNumberErrorGen: null,
|
|
182
|
-
currentTestName: getTestName(test),
|
|
183
|
-
snapshotState: this.snapshotClient.getSnapshotState(test.file.filepath)
|
|
184
|
-
}, globalThis[GLOBAL_EXPECT]);
|
|
185
|
-
}
|
|
186
|
-
onAfterTryTask(test) {
|
|
187
|
-
const { assertionCalls, expectedAssertionsNumber, expectedAssertionsNumberErrorGen, isExpectingAssertions, isExpectingAssertionsError } = test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
|
|
188
|
-
if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber) throw expectedAssertionsNumberErrorGen();
|
|
189
|
-
if (isExpectingAssertions === true && assertionCalls === 0) throw isExpectingAssertionsError;
|
|
190
|
-
if (this.config.expect.requireAssertions && assertionCalls === 0) throw this.assertionsErrors.get(test);
|
|
191
|
-
}
|
|
192
|
-
extendTaskContext(context) {
|
|
193
|
-
// create error during the test initialization so we have a nice stack trace
|
|
194
|
-
if (this.config.expect.requireAssertions) this.assertionsErrors.set(context.task, /* @__PURE__ */ new Error("expected any number of assertion, but got none"));
|
|
195
|
-
let _expect;
|
|
196
|
-
return Object.defineProperty(context, "expect", { get() {
|
|
197
|
-
if (!_expect) _expect = createExpect(context.task);
|
|
198
|
-
return _expect;
|
|
199
|
-
} }), Object.defineProperty(context, "_local", { get() {
|
|
200
|
-
return _expect != null;
|
|
201
|
-
} }), context;
|
|
202
|
-
}
|
|
203
|
-
getImportDurations() {
|
|
204
|
-
const entries = [...this.workerState.moduleExecutionInfo?.entries() ?? []];
|
|
205
|
-
return Object.fromEntries(entries.map(([filepath, { duration, selfTime }]) => [normalize(filepath), {
|
|
206
|
-
selfTime,
|
|
207
|
-
totalTime: duration
|
|
208
|
-
}]));
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
function clearModuleMocks(config) {
|
|
212
|
-
const { clearMocks, mockReset, restoreMocks, unstubEnvs, unstubGlobals } = config;
|
|
213
|
-
// since each function calls another, we can just call one
|
|
214
|
-
if (restoreMocks) vi.restoreAllMocks();
|
|
215
|
-
else if (mockReset) vi.resetAllMocks();
|
|
216
|
-
else if (clearMocks) vi.clearAllMocks();
|
|
217
|
-
if (unstubEnvs) vi.unstubAllEnvs();
|
|
218
|
-
if (unstubGlobals) vi.unstubAllGlobals();
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export { NodeBenchmarkRunner, VitestTestRunner };
|
package/dist/snapshot.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.
|
|
1
|
+
export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.CyipiPvJ.js';
|
|
2
2
|
import '@vitest/snapshot/environment';
|
|
3
|
-
import './chunks/utils.
|
|
3
|
+
import './chunks/utils.D2R2NiOH.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.
|
|
1
|
+
export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.CJUa-Hsa.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.
|
|
5
|
+
import './chunks/utils.D2R2NiOH.js';
|
package/dist/worker.js
CHANGED
|
@@ -8,8 +8,8 @@ import { resolve } from 'pathe';
|
|
|
8
8
|
import { V as VitestTransport } from './chunks/moduleTransport.I-bgQy0S.js';
|
|
9
9
|
import { e as environments } from './chunks/index.DfviD7lX.js';
|
|
10
10
|
import { s as setupInspect } from './chunks/inspector.CvQD-Nie.js';
|
|
11
|
-
import { c as createRuntimeRpc, a as rpcDone } from './chunks/rpc.
|
|
12
|
-
import { i as isChildProcess
|
|
11
|
+
import { c as createRuntimeRpc, a as rpcDone } from './chunks/rpc.BKr6mtxz.js';
|
|
12
|
+
import { i as isChildProcess } from './chunks/utils.D2R2NiOH.js';
|
|
13
13
|
import { d as disposeInternalListeners } from './chunks/utils.C2YI6McM.js';
|
|
14
14
|
import 'node:console';
|
|
15
15
|
import '@vitest/utils';
|
|
@@ -77,7 +77,6 @@ async function cleanup() {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
if (isChildProcess()) {
|
|
80
|
-
setProcessTitle(`vitest ${workerId}`);
|
|
81
80
|
const isProfiling = process.execArgv.some((execArg) => execArg.startsWith("--prof") || execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir"));
|
|
82
81
|
if (isProfiling)
|
|
83
82
|
// Work-around for nodejs/node#55094
|
package/dist/workers/forks.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import v8 from 'node:v8';
|
|
2
|
-
import { r as runBaseTests } from '../chunks/base.
|
|
2
|
+
import { r as runBaseTests } from '../chunks/base.CA5N8Af0.js';
|
|
3
3
|
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.C2YI6McM.js';
|
|
4
|
+
import 'node:vm';
|
|
5
|
+
import '@vitest/spy';
|
|
4
6
|
import 'vite/module-runner';
|
|
5
|
-
import '../chunks/startModuleRunner.
|
|
7
|
+
import '../chunks/startModuleRunner.BDRvKSdz.js';
|
|
6
8
|
import 'node:fs';
|
|
7
9
|
import 'node:module';
|
|
8
10
|
import '@vitest/utils';
|
|
@@ -12,10 +14,31 @@ import '../path.js';
|
|
|
12
14
|
import 'node:path';
|
|
13
15
|
import '@vitest/utils/error';
|
|
14
16
|
import '../module-evaluator.js';
|
|
15
|
-
import 'node:vm';
|
|
16
17
|
import '@vitest/mocker';
|
|
17
18
|
import '../chunks/moduleTransport.I-bgQy0S.js';
|
|
18
|
-
import '
|
|
19
|
+
import 'node:perf_hooks';
|
|
20
|
+
import '@vitest/runner';
|
|
21
|
+
import '../chunks/resolveSnapshotEnvironment.Bvv2zr69.js';
|
|
22
|
+
import '@vitest/expect';
|
|
23
|
+
import '../chunks/setup-common.B7I37Tji.js';
|
|
24
|
+
import '../chunks/coverage.D_JHT54q.js';
|
|
25
|
+
import '@vitest/snapshot';
|
|
26
|
+
import '../chunks/utils.D2R2NiOH.js';
|
|
27
|
+
import '../chunks/rpc.BKr6mtxz.js';
|
|
28
|
+
import '../chunks/index.Bgo3tNWt.js';
|
|
29
|
+
import '../chunks/test.BAlBebnP.js';
|
|
30
|
+
import '../chunks/benchmark.CJUa-Hsa.js';
|
|
31
|
+
import '@vitest/runner/utils';
|
|
32
|
+
import '../chunks/vi.BB37KeLx.js';
|
|
33
|
+
import '../chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
34
|
+
import '@vitest/utils/source-map';
|
|
35
|
+
import '../chunks/date.-jtEtIeV.js';
|
|
36
|
+
import '../chunks/inspector.CvQD-Nie.js';
|
|
37
|
+
import 'node:timers';
|
|
38
|
+
import 'node:timers/promises';
|
|
39
|
+
import 'node:util';
|
|
40
|
+
import '../chunks/index.C832ioot.js';
|
|
41
|
+
import 'expect-type';
|
|
19
42
|
|
|
20
43
|
class ForksBaseWorker {
|
|
21
44
|
getRpcOptions() {
|
|
@@ -5,39 +5,38 @@ import timersPromises from 'node:timers/promises';
|
|
|
5
5
|
import util from 'node:util';
|
|
6
6
|
import { startTests, collectTests } from '@vitest/runner';
|
|
7
7
|
import { KNOWN_ASSET_TYPES } from '@vitest/utils';
|
|
8
|
-
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/
|
|
9
|
-
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.
|
|
10
|
-
import {
|
|
8
|
+
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/resolveSnapshotEnvironment.Bvv2zr69.js';
|
|
9
|
+
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.B7I37Tji.js';
|
|
10
|
+
import { i as index } from '../chunks/index.C832ioot.js';
|
|
11
11
|
import { c as closeInspector } from '../chunks/inspector.CvQD-Nie.js';
|
|
12
|
-
import { g as getWorkerState } from '../chunks/utils.
|
|
13
|
-
import '
|
|
14
|
-
import '
|
|
15
|
-
import '../
|
|
16
|
-
import 'node:url';
|
|
17
|
-
import '../chunks/rpc.RpPylpp0.js';
|
|
12
|
+
import { g as getWorkerState } from '../chunks/utils.D2R2NiOH.js';
|
|
13
|
+
import { g as globalExpect } from '../chunks/vi.BB37KeLx.js';
|
|
14
|
+
import '@vitest/expect';
|
|
15
|
+
import '../chunks/rpc.BKr6mtxz.js';
|
|
18
16
|
import '../chunks/index.Bgo3tNWt.js';
|
|
17
|
+
import '../chunks/test.BAlBebnP.js';
|
|
18
|
+
import '../chunks/benchmark.CJUa-Hsa.js';
|
|
19
|
+
import '@vitest/runner/utils';
|
|
20
|
+
import '@vitest/utils/error';
|
|
21
|
+
import 'pathe';
|
|
19
22
|
import '../chunks/coverage.D_JHT54q.js';
|
|
20
23
|
import '@vitest/snapshot';
|
|
21
|
-
import '
|
|
22
|
-
import '
|
|
23
|
-
import '
|
|
24
|
+
import 'expect-type';
|
|
25
|
+
import 'vite/module-runner';
|
|
26
|
+
import 'node:url';
|
|
24
27
|
import '../chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
25
|
-
import '@vitest/utils/error';
|
|
26
28
|
import '@vitest/spy';
|
|
27
29
|
import '@vitest/utils/source-map';
|
|
28
30
|
import '../chunks/date.-jtEtIeV.js';
|
|
29
|
-
import '../chunks/benchmark.UW6Ezvxy.js';
|
|
30
|
-
import 'expect-type';
|
|
31
|
-
import 'vite/module-runner';
|
|
32
31
|
|
|
33
32
|
async function run(method, files, config, moduleRunner) {
|
|
34
33
|
const workerState = getWorkerState();
|
|
35
34
|
await setupCommonEnv(config), Object.defineProperty(globalThis, "__vitest_index__", {
|
|
36
|
-
value:
|
|
35
|
+
value: index,
|
|
37
36
|
enumerable: false
|
|
38
37
|
});
|
|
39
38
|
const viteEnvironment = workerState.environment.viteEnvironment || workerState.environment.name;
|
|
40
|
-
if (viteEnvironment === "client") {
|
|
39
|
+
if (globalExpect.setState({ environment: workerState.environment.name }), viteEnvironment === "client") {
|
|
41
40
|
const _require = createRequire(import.meta.url);
|
|
42
41
|
_require.extensions[".css"] = resolveCss, _require.extensions[".scss"] = resolveCss, _require.extensions[".sass"] = resolveCss, _require.extensions[".less"] = resolveCss, KNOWN_ASSET_TYPES.forEach((type) => {
|
|
43
42
|
_require.extensions[`.${type}`] = resolveAsset;
|
|
@@ -52,7 +51,7 @@ async function run(method, files, config, moduleRunner) {
|
|
|
52
51
|
config.snapshotOptions.snapshotEnvironment = snapshotEnvironment, runner.getWorkerContext = void 0, workerState.onCancel.then((reason) => {
|
|
53
52
|
closeInspector(config), runner.cancel?.(reason);
|
|
54
53
|
}), workerState.durations.prepare = performance.now() - workerState.durations.prepare;
|
|
55
|
-
const { vi } =
|
|
54
|
+
const { vi } = index;
|
|
56
55
|
for (const file of files) {
|
|
57
56
|
if (workerState.filepath = file.filepath, method === "run") await startTests([file], runner);
|
|
58
57
|
else await collectTests([file], runner);
|
package/dist/workers/threads.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { r as runBaseTests } from '../chunks/base.
|
|
1
|
+
import { r as runBaseTests } from '../chunks/base.CA5N8Af0.js';
|
|
2
2
|
import { a as createThreadsRpcOptions } from '../chunks/utils.C2YI6McM.js';
|
|
3
|
+
import 'node:vm';
|
|
4
|
+
import '@vitest/spy';
|
|
3
5
|
import 'vite/module-runner';
|
|
4
|
-
import '../chunks/startModuleRunner.
|
|
6
|
+
import '../chunks/startModuleRunner.BDRvKSdz.js';
|
|
5
7
|
import 'node:fs';
|
|
6
8
|
import 'node:module';
|
|
7
9
|
import '@vitest/utils';
|
|
@@ -11,10 +13,31 @@ import '../path.js';
|
|
|
11
13
|
import 'node:path';
|
|
12
14
|
import '@vitest/utils/error';
|
|
13
15
|
import '../module-evaluator.js';
|
|
14
|
-
import 'node:vm';
|
|
15
16
|
import '@vitest/mocker';
|
|
16
17
|
import '../chunks/moduleTransport.I-bgQy0S.js';
|
|
17
|
-
import '
|
|
18
|
+
import 'node:perf_hooks';
|
|
19
|
+
import '@vitest/runner';
|
|
20
|
+
import '../chunks/resolveSnapshotEnvironment.Bvv2zr69.js';
|
|
21
|
+
import '@vitest/expect';
|
|
22
|
+
import '../chunks/setup-common.B7I37Tji.js';
|
|
23
|
+
import '../chunks/coverage.D_JHT54q.js';
|
|
24
|
+
import '@vitest/snapshot';
|
|
25
|
+
import '../chunks/utils.D2R2NiOH.js';
|
|
26
|
+
import '../chunks/rpc.BKr6mtxz.js';
|
|
27
|
+
import '../chunks/index.Bgo3tNWt.js';
|
|
28
|
+
import '../chunks/test.BAlBebnP.js';
|
|
29
|
+
import '../chunks/benchmark.CJUa-Hsa.js';
|
|
30
|
+
import '@vitest/runner/utils';
|
|
31
|
+
import '../chunks/vi.BB37KeLx.js';
|
|
32
|
+
import '../chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
33
|
+
import '@vitest/utils/source-map';
|
|
34
|
+
import '../chunks/date.-jtEtIeV.js';
|
|
35
|
+
import '../chunks/inspector.CvQD-Nie.js';
|
|
36
|
+
import 'node:timers';
|
|
37
|
+
import 'node:timers/promises';
|
|
38
|
+
import 'node:util';
|
|
39
|
+
import '../chunks/index.C832ioot.js';
|
|
40
|
+
import 'expect-type';
|
|
18
41
|
|
|
19
42
|
class ThreadsBaseWorker {
|
|
20
43
|
getRpcOptions(ctx) {
|
package/dist/workers/vmForks.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import v8 from 'node:v8';
|
|
2
2
|
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.C2YI6McM.js';
|
|
3
|
-
import { r as runVmTests } from '../chunks/vm.
|
|
3
|
+
import { r as runVmTests } from '../chunks/vm.CjLTDaST.js';
|
|
4
4
|
import '@vitest/utils';
|
|
5
5
|
import 'node:url';
|
|
6
6
|
import 'node:vm';
|
|
7
7
|
import 'pathe';
|
|
8
8
|
import '../path.js';
|
|
9
9
|
import 'node:path';
|
|
10
|
-
import '../chunks/console.
|
|
10
|
+
import '../chunks/console.7h5kHUIf.js';
|
|
11
11
|
import 'node:console';
|
|
12
12
|
import 'node:stream';
|
|
13
13
|
import 'tinyrainbow';
|
|
14
14
|
import '../chunks/date.-jtEtIeV.js';
|
|
15
|
-
import '../chunks/utils.
|
|
15
|
+
import '../chunks/utils.D2R2NiOH.js';
|
|
16
16
|
import 'node:fs';
|
|
17
17
|
import 'node:module';
|
|
18
18
|
import '../chunks/resolver.Bx6lE0iq.js';
|
|
19
19
|
import '../module-evaluator.js';
|
|
20
20
|
import 'vite/module-runner';
|
|
21
|
-
import '../chunks/startModuleRunner.
|
|
21
|
+
import '../chunks/startModuleRunner.BDRvKSdz.js';
|
|
22
22
|
import '@vitest/utils/error';
|
|
23
23
|
import '@vitest/mocker';
|
|
24
24
|
import '../chunks/moduleTransport.I-bgQy0S.js';
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { a as createThreadsRpcOptions } from '../chunks/utils.C2YI6McM.js';
|
|
2
|
-
import { r as runVmTests } from '../chunks/vm.
|
|
2
|
+
import { r as runVmTests } from '../chunks/vm.CjLTDaST.js';
|
|
3
3
|
import '@vitest/utils';
|
|
4
4
|
import 'node:url';
|
|
5
5
|
import 'node:vm';
|
|
6
6
|
import 'pathe';
|
|
7
7
|
import '../path.js';
|
|
8
8
|
import 'node:path';
|
|
9
|
-
import '../chunks/console.
|
|
9
|
+
import '../chunks/console.7h5kHUIf.js';
|
|
10
10
|
import 'node:console';
|
|
11
11
|
import 'node:stream';
|
|
12
12
|
import 'tinyrainbow';
|
|
13
13
|
import '../chunks/date.-jtEtIeV.js';
|
|
14
|
-
import '../chunks/utils.
|
|
14
|
+
import '../chunks/utils.D2R2NiOH.js';
|
|
15
15
|
import 'node:fs';
|
|
16
16
|
import 'node:module';
|
|
17
17
|
import '../chunks/resolver.Bx6lE0iq.js';
|
|
18
18
|
import '../module-evaluator.js';
|
|
19
19
|
import 'vite/module-runner';
|
|
20
|
-
import '../chunks/startModuleRunner.
|
|
20
|
+
import '../chunks/startModuleRunner.BDRvKSdz.js';
|
|
21
21
|
import '@vitest/utils/error';
|
|
22
22
|
import '@vitest/mocker';
|
|
23
23
|
import '../chunks/moduleTransport.I-bgQy0S.js';
|
package/dist/workers.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { W as WorkerGlobalState, C as ContextRPC, B as BirpcOptions, R as RuntimeRPC } from './chunks/worker.d.
|
|
1
|
+
import { W as WorkerGlobalState, C as ContextRPC, B as BirpcOptions, R as RuntimeRPC } from './chunks/worker.d.B2r4Ln6p.js';
|
|
2
2
|
import { Awaitable } from '@vitest/utils';
|
|
3
3
|
import * as v8 from 'v8';
|
|
4
|
-
import { a as SerializedConfig } from './chunks/config.d.
|
|
5
|
-
import { W as WorkerContext } from './chunks/worker.d.
|
|
4
|
+
import { a as SerializedConfig } from './chunks/config.d.DacWrqWe.js';
|
|
5
|
+
import { W as WorkerContext } from './chunks/worker.d.DJ6qxO2w.js';
|
|
6
6
|
import '@vitest/runner';
|
|
7
7
|
import 'vite/module-runner';
|
|
8
8
|
import './chunks/environment.d.2fYMoz3o.js';
|
package/dist/workers.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { p as provideWorkerState } from './chunks/utils.
|
|
1
|
+
export { p as provideWorkerState } from './chunks/utils.D2R2NiOH.js';
|
|
2
2
|
export { collect as collectVitestWorkerTests, run as runVitestWorker } from './worker.js';
|
|
3
|
-
export { r as runBaseTests } from './chunks/base.
|
|
3
|
+
export { r as runBaseTests } from './chunks/base.CA5N8Af0.js';
|
|
4
4
|
export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './chunks/utils.C2YI6McM.js';
|
|
5
|
-
export { r as runVmTests } from './chunks/vm.
|
|
5
|
+
export { r as runVmTests } from './chunks/vm.CjLTDaST.js';
|
|
6
6
|
import '@vitest/utils';
|
|
7
7
|
import 'node:url';
|
|
8
8
|
import '@vitest/utils/source-map';
|
|
@@ -15,17 +15,35 @@ import './chunks/moduleTransport.I-bgQy0S.js';
|
|
|
15
15
|
import './chunks/index.DfviD7lX.js';
|
|
16
16
|
import 'node:console';
|
|
17
17
|
import './chunks/inspector.CvQD-Nie.js';
|
|
18
|
-
import './chunks/rpc.
|
|
18
|
+
import './chunks/rpc.BKr6mtxz.js';
|
|
19
19
|
import './chunks/index.Bgo3tNWt.js';
|
|
20
|
-
import '
|
|
20
|
+
import 'node:vm';
|
|
21
|
+
import '@vitest/spy';
|
|
22
|
+
import './chunks/startModuleRunner.BDRvKSdz.js';
|
|
21
23
|
import './path.js';
|
|
22
24
|
import 'node:path';
|
|
23
25
|
import '@vitest/utils/error';
|
|
24
26
|
import './module-evaluator.js';
|
|
25
|
-
import 'node:vm';
|
|
26
27
|
import '@vitest/mocker';
|
|
27
|
-
import '
|
|
28
|
+
import 'node:perf_hooks';
|
|
29
|
+
import '@vitest/runner';
|
|
30
|
+
import './chunks/resolveSnapshotEnvironment.Bvv2zr69.js';
|
|
31
|
+
import '@vitest/expect';
|
|
32
|
+
import './chunks/setup-common.B7I37Tji.js';
|
|
33
|
+
import './chunks/coverage.D_JHT54q.js';
|
|
34
|
+
import '@vitest/snapshot';
|
|
35
|
+
import './chunks/test.BAlBebnP.js';
|
|
36
|
+
import './chunks/benchmark.CJUa-Hsa.js';
|
|
37
|
+
import '@vitest/runner/utils';
|
|
38
|
+
import './chunks/vi.BB37KeLx.js';
|
|
39
|
+
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
40
|
+
import './chunks/date.-jtEtIeV.js';
|
|
41
|
+
import 'node:timers';
|
|
42
|
+
import 'node:timers/promises';
|
|
43
|
+
import 'node:util';
|
|
44
|
+
import './chunks/index.C832ioot.js';
|
|
45
|
+
import 'expect-type';
|
|
46
|
+
import './chunks/console.7h5kHUIf.js';
|
|
28
47
|
import 'node:stream';
|
|
29
48
|
import 'tinyrainbow';
|
|
30
|
-
import './chunks/date.-jtEtIeV.js';
|
|
31
49
|
import './chunks/resolver.Bx6lE0iq.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.9",
|
|
5
5
|
"description": "Next generation testing framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -125,8 +125,8 @@
|
|
|
125
125
|
"@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
|
|
126
126
|
"happy-dom": "*",
|
|
127
127
|
"jsdom": "*",
|
|
128
|
-
"@vitest/browser": "4.0.0-beta.
|
|
129
|
-
"@vitest/ui": "4.0.0-beta.
|
|
128
|
+
"@vitest/browser": "4.0.0-beta.9",
|
|
129
|
+
"@vitest/ui": "4.0.0-beta.9"
|
|
130
130
|
},
|
|
131
131
|
"peerDependenciesMeta": {
|
|
132
132
|
"@edge-runtime/vm": {
|
|
@@ -152,8 +152,6 @@
|
|
|
152
152
|
}
|
|
153
153
|
},
|
|
154
154
|
"dependencies": {
|
|
155
|
-
"@types/chai": "^5.2.2",
|
|
156
|
-
"chai": "^5.2.1",
|
|
157
155
|
"debug": "^4.4.1",
|
|
158
156
|
"es-module-lexer": "^1.7.0",
|
|
159
157
|
"expect-type": "^1.2.2",
|
|
@@ -168,13 +166,13 @@
|
|
|
168
166
|
"tinyrainbow": "^2.0.0",
|
|
169
167
|
"vite": "^6.0.0 || ^7.0.0-0",
|
|
170
168
|
"why-is-node-running": "^2.3.0",
|
|
171
|
-
"@vitest/
|
|
172
|
-
"@vitest/
|
|
173
|
-
"@vitest/
|
|
174
|
-
"@vitest/
|
|
175
|
-
"@vitest/
|
|
176
|
-
"@vitest/
|
|
177
|
-
"@vitest/
|
|
169
|
+
"@vitest/pretty-format": "^4.0.0-beta.9",
|
|
170
|
+
"@vitest/runner": "4.0.0-beta.9",
|
|
171
|
+
"@vitest/snapshot": "4.0.0-beta.9",
|
|
172
|
+
"@vitest/utils": "4.0.0-beta.9",
|
|
173
|
+
"@vitest/mocker": "4.0.0-beta.9",
|
|
174
|
+
"@vitest/spy": "4.0.0-beta.9",
|
|
175
|
+
"@vitest/expect": "4.0.0-beta.9"
|
|
178
176
|
},
|
|
179
177
|
"devDependencies": {
|
|
180
178
|
"@antfu/install-pkg": "^1.1.0",
|
|
@@ -199,7 +197,6 @@
|
|
|
199
197
|
"jsdom": "^26.1.0",
|
|
200
198
|
"local-pkg": "^1.1.1",
|
|
201
199
|
"mime": "^4.0.7",
|
|
202
|
-
"pretty-format": "^29.7.0",
|
|
203
200
|
"prompts": "^2.4.2",
|
|
204
201
|
"strip-literal": "^3.0.0",
|
|
205
202
|
"ws": "^8.18.3"
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { EvaluatedModules } from 'vite/module-runner';
|
|
2
|
-
import { s as startVitestModuleRunner } from './startModuleRunner.C8TW8zTN.js';
|
|
3
|
-
import { p as provideWorkerState } from './utils.C7__0Iv5.js';
|
|
4
|
-
|
|
5
|
-
let _moduleRunner;
|
|
6
|
-
const evaluatedModules = new EvaluatedModules(), moduleExecutionInfo = /* @__PURE__ */ new Map();
|
|
7
|
-
async function startModuleRunner(options) {
|
|
8
|
-
return _moduleRunner || (_moduleRunner = await startVitestModuleRunner(options), _moduleRunner);
|
|
9
|
-
}
|
|
10
|
-
async function runBaseTests(method, state) {
|
|
11
|
-
const { ctx } = state;
|
|
12
|
-
if (state.evaluatedModules = evaluatedModules, state.moduleExecutionInfo = moduleExecutionInfo, provideWorkerState(globalThis, state), ctx.invalidates) ctx.invalidates.forEach((filepath) => {
|
|
13
|
-
const modules = state.evaluatedModules.fileToModulesMap.get(filepath) || [];
|
|
14
|
-
modules.forEach((module) => {
|
|
15
|
-
state.evaluatedModules.invalidateModule(module);
|
|
16
|
-
});
|
|
17
|
-
// evaluatedModules.delete(fsPath)
|
|
18
|
-
// evaluatedModules.delete(`mock:${fsPath}`)
|
|
19
|
-
});
|
|
20
|
-
ctx.files.forEach((i) => {
|
|
21
|
-
const filepath = typeof i === "string" ? i : i.filepath, modules = state.evaluatedModules.fileToModulesMap.get(filepath) || [];
|
|
22
|
-
modules.forEach((module) => {
|
|
23
|
-
state.evaluatedModules.invalidateModule(module);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
const [executor, { run }] = await Promise.all([startModuleRunner({
|
|
27
|
-
state,
|
|
28
|
-
evaluatedModules: state.evaluatedModules
|
|
29
|
-
}), import('./runBaseTests.D6sfuWBM.js')]), fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
|
|
30
|
-
filepath: f,
|
|
31
|
-
testLocations: void 0
|
|
32
|
-
} : f);
|
|
33
|
-
await run(method, fileSpecs, ctx.config, {
|
|
34
|
-
environment: state.environment,
|
|
35
|
-
options: ctx.environment.options
|
|
36
|
-
}, executor);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { runBaseTests as r };
|