vitest 4.0.0-beta.10 → 4.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 +81 -0
- package/dist/browser.d.ts +9 -5
- package/dist/browser.js +8 -5
- package/dist/chunks/{benchmark.CJUa-Hsa.js → benchmark.LXhJ0F0X.js} +2 -2
- package/dist/chunks/{browser.d.yFAklsD1.d.ts → browser.d.Dx7DO_Ce.d.ts} +1 -1
- package/dist/chunks/{cac.DCxo_nSu.js → cac.elvK37c9.js} +8 -8
- package/dist/chunks/{cli-api.BJJXh9BV.js → cli-api.C7plPyhs.js} +64 -34
- package/dist/chunks/{console.7h5kHUIf.js → console.CiTi59Jy.js} +2 -2
- package/dist/chunks/{coverage.BCU-r2QL.js → coverage.CG6Uhorw.js} +14 -18
- package/dist/chunks/{globals.DG-S3xFe.js → globals.BjvYA-AD.js} +7 -5
- package/dist/chunks/{index.CMfqw92x.js → index.AZOjjqWP.js} +2 -2
- package/dist/chunks/{index.BjKEiSn0.js → index.BhY64fF0.js} +3 -3
- package/dist/chunks/{index.BIP7prJq.js → index.BwBttQPf.js} +67 -71
- package/dist/chunks/{moduleRunner.d.D9nBoC4p.d.ts → moduleRunner.d.BNa-CL9e.d.ts} +1 -1
- package/dist/chunks/{node.CyipiPvJ.js → node.BsdMi6DV.js} +2 -2
- package/dist/chunks/{plugin.d.BMVSnsGV.d.ts → plugin.d.C5phQR6o.d.ts} +1 -1
- package/dist/chunks/{reporters.d.BUWjmRYq.d.ts → reporters.d.CVzhsTvK.d.ts} +16 -11
- package/dist/chunks/{resolveSnapshotEnvironment.Bkht6Yor.js → resolveSnapshotEnvironment.DQVamkje.js} +5 -5
- package/dist/chunks/{rpc.BKr6mtxz.js → rpc.jKGRSXIH.js} +2 -2
- package/dist/chunks/{setup-common.uiMcU3cv.js → setup-common.NAWRuMRP.js} +3 -3
- package/dist/chunks/{startModuleRunner.p67gbNo9.js → startModuleRunner.oAuCu1yL.js} +27 -10
- package/dist/chunks/{test.BiqSKISg.js → test.KC5tH8hC.js} +6 -6
- package/dist/chunks/{typechecker.DB-fIMaH.js → typechecker.gXq-5P3n.js} +640 -7
- package/dist/chunks/{utils.D2R2NiOH.js → utils.DGKhod2J.js} +1 -1
- package/dist/chunks/{vi.ZPgvtBao.js → vi.CiJ0Laa6.js} +4 -2
- package/dist/chunks/{worker.d.BDsXGkwh.d.ts → worker.d.B_Fd9M_w.d.ts} +1 -76
- package/dist/{worker.js → chunks/worker.rPGLlbkW.js} +65 -32
- package/dist/cli.js +7 -5
- package/dist/config.d.ts +5 -5
- package/dist/coverage.d.ts +3 -3
- package/dist/coverage.js +3 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -5
- package/dist/module-evaluator.d.ts +2 -2
- package/dist/module-evaluator.js +1 -1
- package/dist/module-runner.js +5 -5
- package/dist/node.d.ts +12 -9
- package/dist/node.js +16 -12
- package/dist/reporters.d.ts +3 -3
- package/dist/reporters.js +7 -5
- package/dist/runners.js +8 -6
- package/dist/snapshot.js +3 -3
- package/dist/suite.js +4 -3
- package/dist/{chunks/base.Cjha6usc.js → worker-base.js} +88 -14
- package/dist/{chunks/vm.Ca0Y0W5f.js → worker-vm.js} +69 -8
- package/dist/workers/runVmTests.js +12 -9
- package/package.json +20 -19
- package/browser.d.ts +0 -1
- package/dist/chunks/moduleTransport.I-bgQy0S.js +0 -19
- package/dist/chunks/resolver.Bx6lE0iq.js +0 -119
- package/dist/chunks/utils.C2YI6McM.js +0 -52
- package/dist/chunks/worker.d.BNcX_2mH.d.ts +0 -8
- package/dist/workers/forks.js +0 -67
- package/dist/workers/threads.js +0 -55
- package/dist/workers/vmForks.js +0 -48
- package/dist/workers/vmThreads.js +0 -38
- package/dist/workers.d.ts +0 -38
- package/dist/workers.js +0 -48
- package/execute.d.ts +0 -1
- package/utils.d.ts +0 -1
- package/workers.d.ts +0 -1
package/dist/runners.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
export { N as NodeBenchmarkRunner, V as VitestTestRunner } from './chunks/test.
|
|
1
|
+
export { N as NodeBenchmarkRunner, V as VitestTestRunner } from './chunks/test.KC5tH8hC.js';
|
|
2
2
|
import '@vitest/runner';
|
|
3
|
-
import '@vitest/utils';
|
|
4
|
-
import '
|
|
3
|
+
import '@vitest/utils/helpers';
|
|
4
|
+
import '@vitest/utils/timers';
|
|
5
|
+
import './chunks/benchmark.LXhJ0F0X.js';
|
|
5
6
|
import '@vitest/runner/utils';
|
|
6
|
-
import './chunks/utils.
|
|
7
|
+
import './chunks/utils.DGKhod2J.js';
|
|
7
8
|
import '@vitest/expect';
|
|
8
9
|
import '@vitest/utils/error';
|
|
9
10
|
import 'pathe';
|
|
10
|
-
import './chunks/vi.
|
|
11
|
+
import './chunks/vi.CiJ0Laa6.js';
|
|
11
12
|
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
12
13
|
import '@vitest/snapshot';
|
|
13
14
|
import '@vitest/spy';
|
|
15
|
+
import '@vitest/utils/offset';
|
|
14
16
|
import '@vitest/utils/source-map';
|
|
15
17
|
import './chunks/date.-jtEtIeV.js';
|
|
16
|
-
import './chunks/rpc.
|
|
18
|
+
import './chunks/rpc.jKGRSXIH.js';
|
|
17
19
|
import './chunks/index.Bgo3tNWt.js';
|
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.BsdMi6DV.js';
|
|
2
2
|
import '@vitest/snapshot/environment';
|
|
3
|
-
import './chunks/utils.
|
|
4
|
-
import '@vitest/utils';
|
|
3
|
+
import './chunks/utils.DGKhod2J.js';
|
|
4
|
+
import '@vitest/utils/timers';
|
package/dist/suite.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.
|
|
1
|
+
export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.LXhJ0F0X.js';
|
|
2
2
|
export { createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
|
|
3
3
|
export { createChainable } from '@vitest/runner/utils';
|
|
4
|
-
import '@vitest/utils';
|
|
5
|
-
import './chunks/utils.
|
|
4
|
+
import '@vitest/utils/helpers';
|
|
5
|
+
import './chunks/utils.DGKhod2J.js';
|
|
6
|
+
import '@vitest/utils/timers';
|
|
@@ -1,20 +1,48 @@
|
|
|
1
|
+
import { c as createForksRpcOptions, u as unwrapSerializableConfig, a as createThreadsRpcOptions, e as execute, t as teardown$1 } from './chunks/worker.rPGLlbkW.js';
|
|
2
|
+
import v8 from 'node:v8';
|
|
1
3
|
import { runInThisContext } from 'node:vm';
|
|
2
4
|
import * as spyModule from '@vitest/spy';
|
|
3
5
|
import { EvaluatedModules } from 'vite/module-runner';
|
|
4
|
-
import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startModuleRunner.
|
|
6
|
+
import { s as startVitestModuleRunner, c as createNodeImportMeta } from './chunks/startModuleRunner.oAuCu1yL.js';
|
|
5
7
|
import { performance } from 'node:perf_hooks';
|
|
6
8
|
import { startTests, collectTests } from '@vitest/runner';
|
|
7
|
-
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './resolveSnapshotEnvironment.
|
|
8
|
-
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './setup-common.
|
|
9
|
-
import { g as globalExpect, v as vi } from './vi.
|
|
10
|
-
import { c as closeInspector } from './inspector.CvQD-Nie.js';
|
|
9
|
+
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './chunks/resolveSnapshotEnvironment.DQVamkje.js';
|
|
10
|
+
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './chunks/setup-common.NAWRuMRP.js';
|
|
11
|
+
import { g as globalExpect, v as vi } from './chunks/vi.CiJ0Laa6.js';
|
|
12
|
+
import { c as closeInspector } from './chunks/inspector.CvQD-Nie.js';
|
|
11
13
|
import { createRequire } from 'node:module';
|
|
12
14
|
import timers from 'node:timers';
|
|
13
15
|
import timersPromises from 'node:timers/promises';
|
|
14
16
|
import util from 'node:util';
|
|
15
|
-
import { KNOWN_ASSET_TYPES
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
17
|
+
import { KNOWN_ASSET_TYPES } from '@vitest/utils/constants';
|
|
18
|
+
import { getSafeTimers } from '@vitest/utils/timers';
|
|
19
|
+
import { i as index } from './chunks/index.AZOjjqWP.js';
|
|
20
|
+
import { g as getWorkerState, r as resetModules, p as provideWorkerState } from './chunks/utils.DGKhod2J.js';
|
|
21
|
+
import '@vitest/utils/source-map';
|
|
22
|
+
import 'node:fs';
|
|
23
|
+
import 'node:url';
|
|
24
|
+
import 'pathe';
|
|
25
|
+
import './chunks/index.DIWhzsUh.js';
|
|
26
|
+
import 'node:console';
|
|
27
|
+
import './chunks/rpc.jKGRSXIH.js';
|
|
28
|
+
import './chunks/index.Bgo3tNWt.js';
|
|
29
|
+
import '@vitest/utils/helpers';
|
|
30
|
+
import './path.js';
|
|
31
|
+
import 'node:path';
|
|
32
|
+
import '@vitest/utils/serialize';
|
|
33
|
+
import './module-evaluator.js';
|
|
34
|
+
import '@vitest/mocker';
|
|
35
|
+
import '@vitest/expect';
|
|
36
|
+
import './chunks/test.KC5tH8hC.js';
|
|
37
|
+
import './chunks/benchmark.LXhJ0F0X.js';
|
|
38
|
+
import '@vitest/runner/utils';
|
|
39
|
+
import '@vitest/utils/error';
|
|
40
|
+
import './chunks/coverage.D_JHT54q.js';
|
|
41
|
+
import '@vitest/snapshot';
|
|
42
|
+
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
43
|
+
import '@vitest/utils/offset';
|
|
44
|
+
import './chunks/date.-jtEtIeV.js';
|
|
45
|
+
import 'expect-type';
|
|
18
46
|
|
|
19
47
|
// this should only be used in Node
|
|
20
48
|
let globalSetup = false;
|
|
@@ -47,7 +75,7 @@ function resolveAsset(mod, url) {
|
|
|
47
75
|
mod.exports = url;
|
|
48
76
|
}
|
|
49
77
|
async function setupConsoleLogSpy() {
|
|
50
|
-
const { createCustomConsole } = await import('./console.
|
|
78
|
+
const { createCustomConsole } = await import('./chunks/console.CiTi59Jy.js');
|
|
51
79
|
globalThis.console = createCustomConsole();
|
|
52
80
|
}
|
|
53
81
|
async function withEnv({ environment }, options, fn) {
|
|
@@ -63,7 +91,7 @@ async function withEnv({ environment }, options, fn) {
|
|
|
63
91
|
}
|
|
64
92
|
|
|
65
93
|
// browser shouldn't call this!
|
|
66
|
-
async function run(method, files, config, environment, moduleRunner) {
|
|
94
|
+
async function run$1(method, files, config, environment, moduleRunner) {
|
|
67
95
|
const workerState = getWorkerState(), isIsolatedThreads = config.pool === "threads" && (config.poolOptions?.threads?.isolate ?? true), isIsolatedForks = config.pool === "forks" && (config.poolOptions?.forks?.isolate ?? true), isolate = isIsolatedThreads || isIsolatedForks;
|
|
68
96
|
if (await setupGlobalEnv(config, environment, moduleRunner), await startCoverageInsideWorker(config.coverage, moduleRunner, { isolate }), config.chaiConfig) setupChaiConfig(config.chaiConfig);
|
|
69
97
|
const runner = await resolveTestRunner(config, moduleRunner);
|
|
@@ -94,8 +122,6 @@ async function runBaseTests(method, state) {
|
|
|
94
122
|
modules.forEach((module) => {
|
|
95
123
|
state.evaluatedModules.invalidateModule(module);
|
|
96
124
|
});
|
|
97
|
-
// evaluatedModules.delete(fsPath)
|
|
98
|
-
// evaluatedModules.delete(`mock:${fsPath}`)
|
|
99
125
|
});
|
|
100
126
|
ctx.files.forEach((i) => {
|
|
101
127
|
const filepath = typeof i === "string" ? i : i.filepath, modules = state.evaluatedModules.fileToModulesMap.get(filepath) || [];
|
|
@@ -112,6 +138,7 @@ async function runBaseTests(method, state) {
|
|
|
112
138
|
filepath: f,
|
|
113
139
|
testLocations: void 0
|
|
114
140
|
} : f);
|
|
141
|
+
// we could load @vite/env, but it would take ~8ms, while this takes ~0,02ms
|
|
115
142
|
if (ctx.config.serializedDefines) try {
|
|
116
143
|
runInThisContext(`(() =>{\n${ctx.config.serializedDefines}})()`, {
|
|
117
144
|
lineOffset: 1,
|
|
@@ -120,10 +147,57 @@ async function runBaseTests(method, state) {
|
|
|
120
147
|
} catch (error) {
|
|
121
148
|
throw new Error(`Failed to load custom "defines": ${error.message}`);
|
|
122
149
|
}
|
|
123
|
-
await run(method, fileSpecs, ctx.config, {
|
|
150
|
+
await run$1(method, fileSpecs, ctx.config, {
|
|
124
151
|
environment: state.environment,
|
|
125
152
|
options: ctx.environment.options
|
|
126
153
|
}, executor);
|
|
127
154
|
}
|
|
128
155
|
|
|
129
|
-
|
|
156
|
+
class ForksBaseWorker {
|
|
157
|
+
getRpcOptions() {
|
|
158
|
+
return createForksRpcOptions(v8);
|
|
159
|
+
}
|
|
160
|
+
async executeTests(method, state) {
|
|
161
|
+
// TODO: don't rely on reassigning process.exit
|
|
162
|
+
// https://github.com/vitest-dev/vitest/pull/4441#discussion_r1443771486
|
|
163
|
+
const exit = process.exit;
|
|
164
|
+
state.ctx.config = unwrapSerializableConfig(state.ctx.config);
|
|
165
|
+
try {
|
|
166
|
+
await runBaseTests(method, state);
|
|
167
|
+
} finally {
|
|
168
|
+
process.exit = exit;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
runTests(state) {
|
|
172
|
+
return this.executeTests("run", state);
|
|
173
|
+
}
|
|
174
|
+
collectTests(state) {
|
|
175
|
+
return this.executeTests("collect", state);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const worker$1 = new ForksBaseWorker();
|
|
179
|
+
|
|
180
|
+
class ThreadsBaseWorker {
|
|
181
|
+
getRpcOptions(ctx) {
|
|
182
|
+
return createThreadsRpcOptions(ctx);
|
|
183
|
+
}
|
|
184
|
+
runTests(state) {
|
|
185
|
+
return runBaseTests("run", state);
|
|
186
|
+
}
|
|
187
|
+
collectTests(state) {
|
|
188
|
+
return runBaseTests("collect", state);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const worker = new ThreadsBaseWorker();
|
|
192
|
+
|
|
193
|
+
async function run(ctx) {
|
|
194
|
+
await execute("run", ctx, ctx.pool === "forks" ? worker$1 : worker);
|
|
195
|
+
}
|
|
196
|
+
async function collect(ctx) {
|
|
197
|
+
await execute("collect", ctx, ctx.pool === "forks" ? worker$1 : worker);
|
|
198
|
+
}
|
|
199
|
+
async function teardown() {
|
|
200
|
+
await teardown$1();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export { collect, run, teardown };
|
|
@@ -1,16 +1,32 @@
|
|
|
1
|
+
import { c as createForksRpcOptions, u as unwrapSerializableConfig, a as createThreadsRpcOptions, e as execute, t as teardown$1 } from './chunks/worker.rPGLlbkW.js';
|
|
2
|
+
import v8 from 'node:v8';
|
|
1
3
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
2
4
|
import vm, { isContext, runInContext } from 'node:vm';
|
|
3
5
|
import { dirname, basename, extname, normalize, resolve } from 'pathe';
|
|
4
|
-
import { distDir } from '
|
|
5
|
-
import { createCustomConsole } from './console.
|
|
6
|
+
import { distDir } from './path.js';
|
|
7
|
+
import { createCustomConsole } from './chunks/console.CiTi59Jy.js';
|
|
6
8
|
import fs from 'node:fs';
|
|
7
9
|
import { createRequire, Module, isBuiltin } from 'node:module';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
+
import { toArray, isBareImport } from '@vitest/utils/helpers';
|
|
11
|
+
import { findNearestPackageData } from '@vitest/utils/resolver';
|
|
10
12
|
import { dirname as dirname$1 } from 'node:path';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
13
|
+
import { CSS_LANGS_RE, KNOWN_ASSET_RE } from '@vitest/utils/constants';
|
|
14
|
+
import { getDefaultRequestStubs } from './module-evaluator.js';
|
|
15
|
+
import { s as startVitestModuleRunner, c as createNodeImportMeta, a as VITEST_VM_CONTEXT_SYMBOL } from './chunks/startModuleRunner.oAuCu1yL.js';
|
|
16
|
+
import { p as provideWorkerState } from './chunks/utils.DGKhod2J.js';
|
|
17
|
+
import '@vitest/utils/source-map';
|
|
18
|
+
import 'vite/module-runner';
|
|
19
|
+
import './chunks/index.DIWhzsUh.js';
|
|
20
|
+
import 'node:console';
|
|
21
|
+
import './chunks/inspector.CvQD-Nie.js';
|
|
22
|
+
import './chunks/rpc.jKGRSXIH.js';
|
|
23
|
+
import '@vitest/utils/timers';
|
|
24
|
+
import './chunks/index.Bgo3tNWt.js';
|
|
25
|
+
import 'node:stream';
|
|
26
|
+
import 'tinyrainbow';
|
|
27
|
+
import './chunks/date.-jtEtIeV.js';
|
|
28
|
+
import '@vitest/utils/serialize';
|
|
29
|
+
import '@vitest/mocker';
|
|
14
30
|
|
|
15
31
|
function interopCommonJsModule(interopDefault, mod) {
|
|
16
32
|
if (isPrimitive(mod) || Array.isArray(mod) || mod instanceof Promise) return {
|
|
@@ -643,4 +659,49 @@ async function runVmTests(method, state) {
|
|
|
643
659
|
}
|
|
644
660
|
}
|
|
645
661
|
|
|
646
|
-
|
|
662
|
+
class ForksVmWorker {
|
|
663
|
+
getRpcOptions() {
|
|
664
|
+
return createForksRpcOptions(v8);
|
|
665
|
+
}
|
|
666
|
+
async executeTests(method, state) {
|
|
667
|
+
const exit = process.exit;
|
|
668
|
+
state.ctx.config = unwrapSerializableConfig(state.ctx.config);
|
|
669
|
+
try {
|
|
670
|
+
await runVmTests(method, state);
|
|
671
|
+
} finally {
|
|
672
|
+
process.exit = exit;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
runTests(state) {
|
|
676
|
+
return this.executeTests("run", state);
|
|
677
|
+
}
|
|
678
|
+
collectTests(state) {
|
|
679
|
+
return this.executeTests("collect", state);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
const worker$1 = new ForksVmWorker();
|
|
683
|
+
|
|
684
|
+
class ThreadsVmWorker {
|
|
685
|
+
getRpcOptions(ctx) {
|
|
686
|
+
return createThreadsRpcOptions(ctx);
|
|
687
|
+
}
|
|
688
|
+
runTests(state) {
|
|
689
|
+
return runVmTests("run", state);
|
|
690
|
+
}
|
|
691
|
+
collectTests(state) {
|
|
692
|
+
return runVmTests("collect", state);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
const worker = new ThreadsVmWorker();
|
|
696
|
+
|
|
697
|
+
async function run(ctx) {
|
|
698
|
+
await execute("run", ctx, ctx.pool === "vmForks" ? worker$1 : worker);
|
|
699
|
+
}
|
|
700
|
+
async function collect(ctx) {
|
|
701
|
+
await execute("collect", ctx, ctx.pool === "vmForks" ? worker$1 : worker);
|
|
702
|
+
}
|
|
703
|
+
async function teardown() {
|
|
704
|
+
await teardown$1();
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
export { collect, run, teardown };
|
|
@@ -4,18 +4,20 @@ import timers from 'node:timers';
|
|
|
4
4
|
import timersPromises from 'node:timers/promises';
|
|
5
5
|
import util from 'node:util';
|
|
6
6
|
import { startTests, collectTests } from '@vitest/runner';
|
|
7
|
-
import { KNOWN_ASSET_TYPES } from '@vitest/utils';
|
|
8
|
-
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/resolveSnapshotEnvironment.
|
|
9
|
-
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.
|
|
10
|
-
import { i as index } from '../chunks/index.
|
|
7
|
+
import { KNOWN_ASSET_TYPES } from '@vitest/utils/constants';
|
|
8
|
+
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/resolveSnapshotEnvironment.DQVamkje.js';
|
|
9
|
+
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.NAWRuMRP.js';
|
|
10
|
+
import { i as index } from '../chunks/index.AZOjjqWP.js';
|
|
11
11
|
import { c as closeInspector } from '../chunks/inspector.CvQD-Nie.js';
|
|
12
|
-
import { g as getWorkerState } from '../chunks/utils.
|
|
13
|
-
import { g as globalExpect } from '../chunks/vi.
|
|
12
|
+
import { g as getWorkerState } from '../chunks/utils.DGKhod2J.js';
|
|
13
|
+
import { g as globalExpect } from '../chunks/vi.CiJ0Laa6.js';
|
|
14
14
|
import '@vitest/expect';
|
|
15
|
-
import '../chunks/rpc.
|
|
15
|
+
import '../chunks/rpc.jKGRSXIH.js';
|
|
16
|
+
import '@vitest/utils/timers';
|
|
16
17
|
import '../chunks/index.Bgo3tNWt.js';
|
|
17
|
-
import '../chunks/test.
|
|
18
|
-
import '
|
|
18
|
+
import '../chunks/test.KC5tH8hC.js';
|
|
19
|
+
import '@vitest/utils/helpers';
|
|
20
|
+
import '../chunks/benchmark.LXhJ0F0X.js';
|
|
19
21
|
import '@vitest/runner/utils';
|
|
20
22
|
import '@vitest/utils/error';
|
|
21
23
|
import 'pathe';
|
|
@@ -26,6 +28,7 @@ import 'vite/module-runner';
|
|
|
26
28
|
import 'node:url';
|
|
27
29
|
import '../chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
28
30
|
import '@vitest/spy';
|
|
31
|
+
import '@vitest/utils/offset';
|
|
29
32
|
import '@vitest/utils/source-map';
|
|
30
33
|
import '../chunks/date.-jtEtIeV.js';
|
|
31
34
|
|
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.11",
|
|
5
5
|
"description": "Next generation testing framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -39,7 +39,11 @@
|
|
|
39
39
|
"default": "./index.cjs"
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
|
-
"
|
|
42
|
+
"./package.json": "./package.json",
|
|
43
|
+
"./optional-types.js": {
|
|
44
|
+
"types": "./optional-types.d.ts"
|
|
45
|
+
},
|
|
46
|
+
"./src/*": "./src/*",
|
|
43
47
|
"./globals": {
|
|
44
48
|
"types": "./globals.d.ts"
|
|
45
49
|
},
|
|
@@ -56,10 +60,6 @@
|
|
|
56
60
|
"types": "./dist/node.d.ts",
|
|
57
61
|
"default": "./dist/node.js"
|
|
58
62
|
},
|
|
59
|
-
"./workers": {
|
|
60
|
-
"types": "./dist/workers.d.ts",
|
|
61
|
-
"import": "./dist/workers.js"
|
|
62
|
-
},
|
|
63
63
|
"./internal/browser": {
|
|
64
64
|
"types": "./dist/browser.d.ts",
|
|
65
65
|
"default": "./dist/browser.js"
|
|
@@ -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.11",
|
|
129
|
+
"@vitest/ui": "4.0.0-beta.11"
|
|
130
130
|
},
|
|
131
131
|
"peerDependenciesMeta": {
|
|
132
132
|
"@edge-runtime/vm": {
|
|
@@ -155,35 +155,36 @@
|
|
|
155
155
|
"debug": "^4.4.1",
|
|
156
156
|
"es-module-lexer": "^1.7.0",
|
|
157
157
|
"expect-type": "^1.2.2",
|
|
158
|
-
"magic-string": "^0.30.
|
|
158
|
+
"magic-string": "^0.30.19",
|
|
159
159
|
"pathe": "^2.0.3",
|
|
160
160
|
"picomatch": "^4.0.3",
|
|
161
161
|
"std-env": "^3.9.0",
|
|
162
162
|
"tinybench": "^2.9.0",
|
|
163
163
|
"tinyexec": "^0.3.2",
|
|
164
|
-
"tinyglobby": "^0.2.
|
|
164
|
+
"tinyglobby": "^0.2.15",
|
|
165
165
|
"tinypool": "^2.0.0",
|
|
166
|
-
"tinyrainbow": "^
|
|
166
|
+
"tinyrainbow": "^3.0.3",
|
|
167
167
|
"vite": "^6.0.0 || ^7.0.0-0",
|
|
168
168
|
"why-is-node-running": "^2.3.0",
|
|
169
|
-
"@vitest/expect": "4.0.0-beta.
|
|
170
|
-
"@vitest/
|
|
171
|
-
"@vitest/
|
|
172
|
-
"@vitest/
|
|
173
|
-
"@vitest/
|
|
174
|
-
"@vitest/
|
|
175
|
-
"@vitest/
|
|
169
|
+
"@vitest/expect": "4.0.0-beta.11",
|
|
170
|
+
"@vitest/mocker": "4.0.0-beta.11",
|
|
171
|
+
"@vitest/pretty-format": "^4.0.0-beta.11",
|
|
172
|
+
"@vitest/snapshot": "4.0.0-beta.11",
|
|
173
|
+
"@vitest/spy": "4.0.0-beta.11",
|
|
174
|
+
"@vitest/utils": "4.0.0-beta.11",
|
|
175
|
+
"@vitest/runner": "4.0.0-beta.11"
|
|
176
176
|
},
|
|
177
177
|
"devDependencies": {
|
|
178
178
|
"@antfu/install-pkg": "^1.1.0",
|
|
179
179
|
"@edge-runtime/vm": "^5.0.0",
|
|
180
|
+
"@jridgewell/trace-mapping": "0.3.30",
|
|
180
181
|
"@sinonjs/fake-timers": "14.0.0",
|
|
181
182
|
"@types/debug": "^4.1.12",
|
|
182
183
|
"@types/estree": "^1.0.8",
|
|
183
184
|
"@types/istanbul-lib-coverage": "^2.0.6",
|
|
184
185
|
"@types/istanbul-reports": "^3.0.4",
|
|
185
186
|
"@types/jsdom": "^21.1.7",
|
|
186
|
-
"@types/node": "^22.18.
|
|
187
|
+
"@types/node": "^22.18.1",
|
|
187
188
|
"@types/picomatch": "^4.0.2",
|
|
188
189
|
"@types/prompts": "^2.4.9",
|
|
189
190
|
"@types/sinonjs__fake-timers": "^8.1.5",
|
package/browser.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/browser.js'
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
class VitestTransport {
|
|
2
|
-
constructor(options) {
|
|
3
|
-
this.options = options;
|
|
4
|
-
}
|
|
5
|
-
async invoke(event) {
|
|
6
|
-
if (event.type !== "custom") return { error: /* @__PURE__ */ new Error(`Vitest Module Runner doesn't support Vite HMR events.`) };
|
|
7
|
-
if (event.event !== "vite:invoke") return { error: /* @__PURE__ */ new Error(`Vitest Module Runner doesn't support ${event.event} event.`) };
|
|
8
|
-
const { name, data } = event.data;
|
|
9
|
-
if (name !== "fetchModule") return { error: /* @__PURE__ */ new Error(`Unknown method: ${name}. Expected "fetchModule".`) };
|
|
10
|
-
try {
|
|
11
|
-
const result = await this.options.fetchModule(...data);
|
|
12
|
-
return { result };
|
|
13
|
-
} catch (error) {
|
|
14
|
-
return { error };
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { VitestTransport as V };
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
|
|
3
|
-
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
4
|
-
function normalizeWindowsPath(input = "") {
|
|
5
|
-
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
6
|
-
}
|
|
7
|
-
const _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/, normalize = function(path) {
|
|
8
|
-
if (path.length === 0) return ".";
|
|
9
|
-
path = normalizeWindowsPath(path);
|
|
10
|
-
const isUNCPath = path.match(_UNC_REGEX), isPathAbsolute = isAbsolute(path), trailingSeparator = path[path.length - 1] === "/";
|
|
11
|
-
if (path = normalizeString(path, !isPathAbsolute), path.length === 0) return isPathAbsolute ? "/" : trailingSeparator ? "./" : ".";
|
|
12
|
-
if (trailingSeparator) path += "/";
|
|
13
|
-
if (_DRIVE_LETTER_RE.test(path)) path += "/";
|
|
14
|
-
return isUNCPath ? isPathAbsolute ? `//${path}` : `//./${path}` : isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
15
|
-
}, join = function(...segments) {
|
|
16
|
-
let path = "";
|
|
17
|
-
for (const seg of segments) {
|
|
18
|
-
if (!seg) continue;
|
|
19
|
-
if (path.length > 0) {
|
|
20
|
-
const pathTrailing = path[path.length - 1] === "/", segLeading = seg[0] === "/", both = pathTrailing && segLeading;
|
|
21
|
-
if (both) path += seg.slice(1);
|
|
22
|
-
else path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
23
|
-
} else path += seg;
|
|
24
|
-
}
|
|
25
|
-
return normalize(path);
|
|
26
|
-
};
|
|
27
|
-
function normalizeString(path, allowAboveRoot) {
|
|
28
|
-
let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
|
|
29
|
-
for (let index = 0; index <= path.length; ++index) {
|
|
30
|
-
if (index < path.length) char = path[index];
|
|
31
|
-
else if (char === "/") break;
|
|
32
|
-
else char = "/";
|
|
33
|
-
if (char === "/") {
|
|
34
|
-
if (lastSlash === index - 1 || dots === 1);
|
|
35
|
-
else if (dots === 2) {
|
|
36
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
37
|
-
if (res.length > 2) {
|
|
38
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
39
|
-
if (lastSlashIndex === -1) res = "", lastSegmentLength = 0;
|
|
40
|
-
else res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
41
|
-
lastSlash = index, dots = 0;
|
|
42
|
-
continue;
|
|
43
|
-
} else if (res.length > 0) {
|
|
44
|
-
res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (allowAboveRoot) res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2;
|
|
49
|
-
} else {
|
|
50
|
-
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
51
|
-
else res = path.slice(lastSlash + 1, index);
|
|
52
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
53
|
-
}
|
|
54
|
-
lastSlash = index, dots = 0;
|
|
55
|
-
} else if (char === "." && dots !== -1) ++dots;
|
|
56
|
-
else dots = -1;
|
|
57
|
-
}
|
|
58
|
-
return res;
|
|
59
|
-
}
|
|
60
|
-
const isAbsolute = function(p) {
|
|
61
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
62
|
-
}, dirname = function(p) {
|
|
63
|
-
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
64
|
-
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
65
|
-
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const packageCache = /* @__PURE__ */ new Map();
|
|
69
|
-
function findNearestPackageData(basedir) {
|
|
70
|
-
const originalBasedir = basedir;
|
|
71
|
-
while (basedir) {
|
|
72
|
-
var _tryStatSync;
|
|
73
|
-
const cached = getCachedData(packageCache, basedir, originalBasedir);
|
|
74
|
-
if (cached) return cached;
|
|
75
|
-
const pkgPath = join(basedir, "package.json");
|
|
76
|
-
if ((_tryStatSync = tryStatSync(pkgPath)) === null || _tryStatSync === void 0 ? void 0 : _tryStatSync.isFile()) {
|
|
77
|
-
const pkgData = JSON.parse(stripBomTag(fs.readFileSync(pkgPath, "utf8")));
|
|
78
|
-
if (packageCache) setCacheData(packageCache, pkgData, basedir, originalBasedir);
|
|
79
|
-
return pkgData;
|
|
80
|
-
}
|
|
81
|
-
const nextBasedir = dirname(basedir);
|
|
82
|
-
if (nextBasedir === basedir) break;
|
|
83
|
-
basedir = nextBasedir;
|
|
84
|
-
}
|
|
85
|
-
return {};
|
|
86
|
-
}
|
|
87
|
-
function stripBomTag(content) {
|
|
88
|
-
return content.charCodeAt(0) === 65279 ? content.slice(1) : content;
|
|
89
|
-
}
|
|
90
|
-
function tryStatSync(file) {
|
|
91
|
-
try {
|
|
92
|
-
// The "throwIfNoEntry" is a performance optimization for cases where the file does not exist
|
|
93
|
-
return fs.statSync(file, { throwIfNoEntry: false });
|
|
94
|
-
} catch {}
|
|
95
|
-
}
|
|
96
|
-
function getCachedData(cache, basedir, originalBasedir) {
|
|
97
|
-
const pkgData = cache.get(getFnpdCacheKey(basedir));
|
|
98
|
-
if (pkgData) return traverseBetweenDirs(originalBasedir, basedir, (dir) => {
|
|
99
|
-
cache.set(getFnpdCacheKey(dir), pkgData);
|
|
100
|
-
}), pkgData;
|
|
101
|
-
}
|
|
102
|
-
function setCacheData(cache, data, basedir, originalBasedir) {
|
|
103
|
-
cache.set(getFnpdCacheKey(basedir), data), traverseBetweenDirs(originalBasedir, basedir, (dir) => {
|
|
104
|
-
cache.set(getFnpdCacheKey(dir), data);
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
function getFnpdCacheKey(basedir) {
|
|
108
|
-
return `fnpd_${basedir}`;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Traverse between `longerDir` (inclusive) and `shorterDir` (exclusive) and call `cb` for each dir.
|
|
112
|
-
* @param longerDir Longer dir path, e.g. `/User/foo/bar/baz`
|
|
113
|
-
* @param shorterDir Shorter dir path, e.g. `/User/foo`
|
|
114
|
-
*/
|
|
115
|
-
function traverseBetweenDirs(longerDir, shorterDir, cb) {
|
|
116
|
-
while (longerDir !== shorterDir) cb(longerDir), longerDir = dirname(longerDir);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export { findNearestPackageData as f };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { parseRegexp } from '@vitest/utils';
|
|
2
|
-
|
|
3
|
-
const REGEXP_WRAP_PREFIX = "$$vitest:", processSend = process.send?.bind(process), processOn = process.on?.bind(process), processOff = process.off?.bind(process), dispose = [];
|
|
4
|
-
function createThreadsRpcOptions({ port }) {
|
|
5
|
-
return {
|
|
6
|
-
post: (v) => {
|
|
7
|
-
port.postMessage(v);
|
|
8
|
-
},
|
|
9
|
-
on: (fn) => {
|
|
10
|
-
port.addListener("message", fn);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function disposeInternalListeners() {
|
|
15
|
-
for (const fn of dispose) try {
|
|
16
|
-
fn();
|
|
17
|
-
} catch {}
|
|
18
|
-
dispose.length = 0;
|
|
19
|
-
}
|
|
20
|
-
function createForksRpcOptions(nodeV8) {
|
|
21
|
-
return {
|
|
22
|
-
serialize: nodeV8.serialize,
|
|
23
|
-
deserialize: (v) => nodeV8.deserialize(Buffer.from(v)),
|
|
24
|
-
post(v) {
|
|
25
|
-
processSend(v);
|
|
26
|
-
},
|
|
27
|
-
on(fn) {
|
|
28
|
-
const handler = (message, ...extras) => {
|
|
29
|
-
if (!message?.__tinypool_worker_message__) return fn(message, ...extras);
|
|
30
|
-
};
|
|
31
|
-
processOn("message", handler), dispose.push(() => processOff("message", handler));
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Reverts the wrapping done by `utils/config-helpers.ts`'s `wrapSerializableConfig`
|
|
37
|
-
*/
|
|
38
|
-
function unwrapSerializableConfig(config) {
|
|
39
|
-
if (config.testNamePattern && typeof config.testNamePattern === "string") {
|
|
40
|
-
const testNamePattern = config.testNamePattern;
|
|
41
|
-
if (testNamePattern.startsWith(REGEXP_WRAP_PREFIX)) config.testNamePattern = parseRegexp(testNamePattern.slice(9));
|
|
42
|
-
}
|
|
43
|
-
if (config.defines && Array.isArray(config.defines.keys) && config.defines.original) {
|
|
44
|
-
const { keys, original } = config.defines, defines = {};
|
|
45
|
-
// Apply all keys from the original. Entries which had undefined value are missing from original now
|
|
46
|
-
for (const key of keys) defines[key] = original[key];
|
|
47
|
-
config.defines = defines;
|
|
48
|
-
}
|
|
49
|
-
return config;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export { createThreadsRpcOptions as a, createForksRpcOptions as c, disposeInternalListeners as d, unwrapSerializableConfig as u };
|