vitest 4.1.0-beta.1 → 4.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +36 -0
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +2 -2
- package/dist/chunks/acorn.B2iPLyUM.js +5958 -0
- package/dist/chunks/{base.CBRNZa3k.js → base.DiopZV8F.js} +48 -14
- package/dist/chunks/{benchmark.B3N2zMcH.js → benchmark.BoqSLF53.js} +1 -1
- package/dist/chunks/{browser.d.8hOapKZr.d.ts → browser.d.BE4kbYok.d.ts} +2 -1
- package/dist/chunks/{cac.B1v3xxoC.js → cac.C4jjt2RX.js} +797 -13
- package/dist/chunks/{cli-api.B4CqEpI6.js → cli-api.ChbI1JU9.js} +322 -124
- package/dist/chunks/{config.d.idH22YSr.d.ts → config.d.Cr1Ep39N.d.ts} +6 -1
- package/dist/chunks/{console.uGgdMhyZ.js → console.CNlG1KsP.js} +2 -2
- package/dist/chunks/{constants.D_Q9UYh-.js → constants.B63TT-Bl.js} +1 -1
- package/dist/chunks/coverage.tyqbzn4W.js +1001 -0
- package/dist/chunks/{creator.C7WwjkuR.js → creator.yyCHuw5R.js} +1 -1
- package/dist/chunks/{global.d.B15mdLcR.d.ts → global.d.JeWMqlOm.d.ts} +1 -1
- package/dist/chunks/{globals.DjuGMoMc.js → globals.C6Ecf1TO.js} +6 -6
- package/dist/chunks/{index.Dm4xqZ0s.js → index.B-iBE_Gx.js} +20 -4
- package/dist/chunks/{coverage.BMlOMIWl.js → index.BCY_7LL2.js} +5 -969
- package/dist/chunks/{index.BiOAd_ki.js → index.CAN630q3.js} +7 -7
- package/dist/chunks/{index.DyBZXrH3.js → index.CFulQRmC.js} +1 -1
- package/dist/chunks/{index.BEFi2-_3.js → index.CouFDptX.js} +2 -2
- package/dist/chunks/{init-forks.CHeQ9Moq.js → init-forks.BnCXPazU.js} +1 -1
- package/dist/chunks/{init-threads.uZiNAuPk.js → init-threads.Cyh2PqXi.js} +1 -1
- package/dist/chunks/{init.DVtKdFty.js → init.B95Mm0Iz.js} +47 -9
- package/dist/chunks/native.mV0-490A.js +148 -0
- package/dist/chunks/nativeModuleMocker.D_q5sFv6.js +206 -0
- package/dist/chunks/nativeModuleRunner.BIakptoF.js +36 -0
- package/dist/chunks/{node.Ce0vMQM7.js → node.CrSEwhm4.js} +1 -1
- package/dist/chunks/{plugin.d.D8KU2PY_.d.ts → plugin.d.C9o5bttz.d.ts} +1 -1
- package/dist/chunks/{reporters.d.Db3MiIWX.d.ts → reporters.d.7faYdkxy.d.ts} +120 -51
- package/dist/chunks/{rpc.HLmECnw_.js → rpc.DcRWTy5G.js} +1 -1
- package/dist/chunks/{rpc.d.RH3apGEf.d.ts → rpc.d.CM7x9-sm.d.ts} +1 -0
- package/dist/chunks/{setup-common.BcqLPsn5.js → setup-common.cvFp-ao9.js} +2 -2
- package/dist/chunks/{startModuleRunner.C5CcWyXW.js → startVitestModuleRunner.BK-u7y4N.js} +163 -372
- package/dist/chunks/{test.prxIahgM.js → test.G82XYNFk.js} +9 -4
- package/dist/chunks/{utils.DvEY5TfP.js → utils.DT4VyRyl.js} +5 -1
- package/dist/chunks/{vm.CrifS09m.js → vm.BdLtzhnj.js} +13 -6
- package/dist/chunks/{worker.d.Bji1eq5g.d.ts → worker.d.CPzI2ZzJ.d.ts} +2 -2
- package/dist/cli.js +4 -3
- package/dist/config.d.ts +8 -8
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +7 -5
- package/dist/coverage.js +5 -4
- package/dist/index.d.ts +18 -23
- package/dist/index.js +5 -5
- package/dist/module-evaluator.d.ts +10 -1
- package/dist/node.d.ts +9 -9
- package/dist/node.js +18 -16
- package/dist/nodejs-worker-loader.js +41 -0
- package/dist/reporters.d.ts +5 -5
- package/dist/reporters.js +2 -2
- package/dist/runners.d.ts +2 -1
- package/dist/runners.js +4 -4
- package/dist/runtime.js +4 -5
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.d.ts +6 -6
- package/dist/worker.js +25 -18
- package/dist/workers/forks.js +21 -14
- package/dist/workers/runVmTests.js +7 -7
- package/dist/workers/threads.js +21 -14
- package/dist/workers/vmForks.js +14 -10
- package/dist/workers/vmThreads.js +14 -10
- package/package.json +17 -14
- package/suppress-warnings.cjs +1 -0
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { runInThisContext } from 'node:vm';
|
|
2
2
|
import * as spyModule from '@vitest/spy';
|
|
3
|
-
import { r as resolveTestRunner, a as resolveSnapshotEnvironment, s as setupChaiConfig } from './index.
|
|
4
|
-
import { l as loadEnvironment, e as emitModuleRunner } from './init.
|
|
3
|
+
import { r as resolveTestRunner, a as resolveSnapshotEnvironment, s as setupChaiConfig } from './index.CAN630q3.js';
|
|
4
|
+
import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.B95Mm0Iz.js';
|
|
5
|
+
import { N as NativeModuleRunner } from './nativeModuleRunner.BIakptoF.js';
|
|
6
|
+
import { T as Traces } from './traces.CCmnQaNT.js';
|
|
5
7
|
import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
|
|
6
|
-
import { s as startVitestModuleRunner, c as createNodeImportMeta } from './
|
|
8
|
+
import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startVitestModuleRunner.BK-u7y4N.js';
|
|
7
9
|
import { performance as performance$1 } from 'node:perf_hooks';
|
|
8
10
|
import { startTests, collectTests } from '@vitest/runner';
|
|
9
|
-
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './setup-common.
|
|
10
|
-
import { g as globalExpect, v as vi } from './test.
|
|
11
|
+
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './setup-common.cvFp-ao9.js';
|
|
12
|
+
import { g as globalExpect, v as vi } from './test.G82XYNFk.js';
|
|
11
13
|
import { c as closeInspector } from './inspector.CvyFGlXm.js';
|
|
12
14
|
import { createRequire } from 'node:module';
|
|
13
15
|
import timers from 'node:timers';
|
|
14
16
|
import timersPromises from 'node:timers/promises';
|
|
15
17
|
import util from 'node:util';
|
|
16
18
|
import { KNOWN_ASSET_TYPES } from '@vitest/utils/constants';
|
|
17
|
-
import { i as index } from './index.
|
|
18
|
-
import { g as getWorkerState, r as resetModules, p as provideWorkerState } from './utils.
|
|
19
|
+
import { i as index } from './index.CouFDptX.js';
|
|
20
|
+
import { g as getWorkerState, r as resetModules, p as provideWorkerState, a as getSafeWorkerState } from './utils.DT4VyRyl.js';
|
|
19
21
|
|
|
20
22
|
// this should only be used in Node
|
|
21
23
|
let globalSetup = false;
|
|
@@ -56,7 +58,7 @@ function resolveAsset(mod, url) {
|
|
|
56
58
|
mod.exports = url;
|
|
57
59
|
}
|
|
58
60
|
async function setupConsoleLogSpy() {
|
|
59
|
-
const { createCustomConsole } = await import('./console.
|
|
61
|
+
const { createCustomConsole } = await import('./console.CNlG1KsP.js');
|
|
60
62
|
globalThis.console = createCustomConsole();
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -79,7 +81,7 @@ async function run(method, files, config, moduleRunner, environment, traces) {
|
|
|
79
81
|
await traces.$(`vitest.test.runner.${method}`, async () => {
|
|
80
82
|
for (const file of files) {
|
|
81
83
|
if (config.isolate) {
|
|
82
|
-
moduleRunner.mocker
|
|
84
|
+
moduleRunner.mocker?.reset();
|
|
83
85
|
resetModules(workerState.evaluatedModules, true);
|
|
84
86
|
}
|
|
85
87
|
workerState.filepath = file.filepath;
|
|
@@ -97,15 +99,47 @@ async function run(method, files, config, moduleRunner, environment, traces) {
|
|
|
97
99
|
let _moduleRunner;
|
|
98
100
|
const evaluatedModules = new VitestEvaluatedModules();
|
|
99
101
|
const moduleExecutionInfo = /* @__PURE__ */ new Map();
|
|
100
|
-
function startModuleRunner(options) {
|
|
102
|
+
async function startModuleRunner(options) {
|
|
101
103
|
if (_moduleRunner) return _moduleRunner;
|
|
104
|
+
process.exit = (code = process.exitCode || 0) => {
|
|
105
|
+
throw new Error(`process.exit unexpectedly called with "${code}"`);
|
|
106
|
+
};
|
|
107
|
+
const state = () => getSafeWorkerState() || options.state;
|
|
108
|
+
listenForErrors(state);
|
|
109
|
+
if (options.state.config.experimental.viteModuleRunner === false) {
|
|
110
|
+
const root = options.state.config.root;
|
|
111
|
+
let mocker;
|
|
112
|
+
if (options.state.config.experimental.nodeLoader !== false) {
|
|
113
|
+
// this additionally imports acorn/magic-string
|
|
114
|
+
const { NativeModuleMocker } = await import('./nativeModuleMocker.D_q5sFv6.js');
|
|
115
|
+
mocker = new NativeModuleMocker({
|
|
116
|
+
async resolveId(id, importer) {
|
|
117
|
+
// TODO: use import.meta.resolve instead
|
|
118
|
+
return state().rpc.resolve(id, importer, "__vitest__");
|
|
119
|
+
},
|
|
120
|
+
root,
|
|
121
|
+
moduleDirectories: state().config.deps.moduleDirectories || ["/node_modules/"],
|
|
122
|
+
traces: options.traces || new Traces({ enabled: false }),
|
|
123
|
+
getCurrentTestFilepath() {
|
|
124
|
+
return state().filepath;
|
|
125
|
+
},
|
|
126
|
+
spyModule
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
_moduleRunner = new NativeModuleRunner(root, mocker);
|
|
130
|
+
return _moduleRunner;
|
|
131
|
+
}
|
|
102
132
|
_moduleRunner = startVitestModuleRunner(options);
|
|
103
133
|
return _moduleRunner;
|
|
104
134
|
}
|
|
105
135
|
let _currentEnvironment;
|
|
106
136
|
let _environmentTime;
|
|
107
137
|
/** @experimental */
|
|
108
|
-
async function
|
|
138
|
+
async function setupBaseEnvironment(context) {
|
|
139
|
+
if (context.config.experimental.viteModuleRunner === false) {
|
|
140
|
+
const { setupNodeLoaderHooks } = await import('./native.mV0-490A.js');
|
|
141
|
+
await setupNodeLoaderHooks(context);
|
|
142
|
+
}
|
|
109
143
|
const startTime = performance.now();
|
|
110
144
|
const { environment: { name: environmentName, options: environmentOptions }, rpc, config } = context;
|
|
111
145
|
// we could load @vite/env, but it would take ~8ms, while this takes ~0,02ms
|
|
@@ -118,7 +152,7 @@ async function setupEnvironment(context) {
|
|
|
118
152
|
throw new Error(`Failed to load custom "defines": ${error.message}`);
|
|
119
153
|
}
|
|
120
154
|
const otel = context.traces;
|
|
121
|
-
const { environment, loader } = await loadEnvironment(environmentName, config.root, rpc, otel);
|
|
155
|
+
const { environment, loader } = await loadEnvironment(environmentName, config.root, rpc, otel, context.config.experimental.viteModuleRunner);
|
|
122
156
|
_currentEnvironment = environment;
|
|
123
157
|
const env = await otel.$("vitest.runtime.environment.setup", { attributes: {
|
|
124
158
|
"vitest.environment": environment.name,
|
|
@@ -151,7 +185,7 @@ async function runBaseTests(method, state, traces) {
|
|
|
151
185
|
state.evaluatedModules.invalidateModule(module);
|
|
152
186
|
});
|
|
153
187
|
});
|
|
154
|
-
const moduleRunner = startModuleRunner({
|
|
188
|
+
const moduleRunner = await startModuleRunner({
|
|
155
189
|
state,
|
|
156
190
|
evaluatedModules: state.evaluatedModules,
|
|
157
191
|
spyModule,
|
|
@@ -162,4 +196,4 @@ async function runBaseTests(method, state, traces) {
|
|
|
162
196
|
await run(method, ctx.files, ctx.config, moduleRunner, _currentEnvironment, traces);
|
|
163
197
|
}
|
|
164
198
|
|
|
165
|
-
export { runBaseTests as r,
|
|
199
|
+
export { runBaseTests as r, setupBaseEnvironment as s };
|
|
@@ -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/helpers';
|
|
4
|
-
import { g as getWorkerState } from './utils.
|
|
4
|
+
import { g as getWorkerState } from './utils.DT4VyRyl.js';
|
|
5
5
|
|
|
6
6
|
const benchFns = /* @__PURE__ */ new WeakMap();
|
|
7
7
|
const benchOptsMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FileSpecification } from '@vitest/runner';
|
|
2
2
|
import { O as OTELCarrier } from './traces.d.402V_yFI.js';
|
|
3
|
-
import { T as TestExecutionMethod } from './worker.d.
|
|
3
|
+
import { T as TestExecutionMethod } from './worker.d.CPzI2ZzJ.js';
|
|
4
4
|
|
|
5
5
|
type SerializedTestSpecification = [project: {
|
|
6
6
|
name: string | undefined;
|
|
@@ -10,6 +10,7 @@ type SerializedTestSpecification = [project: {
|
|
|
10
10
|
testLines?: number[] | undefined;
|
|
11
11
|
testIds?: string[] | undefined;
|
|
12
12
|
testNamePattern?: RegExp | undefined;
|
|
13
|
+
testTagsFilter?: string[] | undefined;
|
|
13
14
|
}];
|
|
14
15
|
|
|
15
16
|
interface ModuleDefinitionLocation {
|