vitest 4.0.0-beta.4 → 4.0.0-beta.5
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 +8 -9
- package/dist/browser.js +3 -2
- package/dist/chunks/base.DMfOuRWD.js +48 -0
- package/dist/chunks/{benchmark.CYdenmiT.js → benchmark.CtuRzf-i.js} +4 -1
- package/dist/chunks/{browser.d.BRP8scJf.d.ts → browser.d.Cawq_X_N.d.ts} +1 -1
- package/dist/chunks/{cac.CY0IAxC4.js → cac.CKnbxhn2.js} +8 -9
- package/dist/chunks/{cli-api.B8xRY9Zt.js → cli-api.COn58yrl.js} +540 -342
- package/dist/chunks/{config.d.DZo8c7fw.d.ts → config.d.CKNVOKm0.d.ts} +3 -8
- package/dist/chunks/{console.DoJHFxmj.js → console.Duv2dVIC.js} +1 -1
- package/dist/chunks/{constants.CXzqaLmq.js → constants.D_Q9UYh-.js} +1 -6
- package/dist/chunks/{coverage.C84l9G-M.js → coverage.B6cReEn1.js} +232 -133
- package/dist/chunks/{coverage.DVF1vEu8.js → coverage.D_JHT54q.js} +2 -2
- package/dist/chunks/{coverage.d.CNYjU4GF.d.ts → coverage.d.BZtK59WP.d.ts} +7 -5
- package/dist/chunks/{creator.yfA2ExGt.js → creator.DUVZ6rfm.js} +1 -1
- package/dist/chunks/{environment.d.Bhm9oc0v.d.ts → environment.d.2fYMoz3o.d.ts} +26 -4
- package/dist/chunks/{global.d.DAhT2emn.d.ts → global.d.K6uBQHzY.d.ts} +1 -1
- package/dist/chunks/{globals.Dgo-vS5G.js → globals.CJQ63oO0.js} +6 -5
- package/dist/chunks/{index.CmSc2RE5.js → index.BRtIe7r8.js} +4 -4
- package/dist/chunks/{index.Bz6b0Ib7.js → index.DQhAfQQU.js} +12 -4
- package/dist/chunks/{index.D3SKT3tv.js → index.DgN0Zk9a.js} +1 -1
- package/dist/chunks/{index.D1_MsKEt.js → index.QZr3S3vQ.js} +4 -2
- package/dist/chunks/{index.CtUvr1c8.js → index.oWRWx-nj.js} +18 -18
- package/dist/chunks/moduleRunner.d.mmOmOGrW.d.ts +202 -0
- package/dist/chunks/moduleTransport.I-bgQy0S.js +19 -0
- package/dist/chunks/{node.fjCdwEIl.js → node.4JV5OXkt.js} +1 -1
- package/dist/chunks/{plugin.d.CLhMcYdD.d.ts → plugin.d.CvOlgjxK.d.ts} +1 -1
- package/dist/chunks/{reporters.d.DWg40D2B.d.ts → reporters.d.CYE9sT5z.d.ts} +37 -69
- package/dist/chunks/resolver.D5bG4zy5.js +162 -0
- package/dist/chunks/{rpc.jnQO9F8a.js → rpc.DGoW_Vl-.js} +1 -1
- package/dist/chunks/{runBaseTests.DBVVLMSb.js → runBaseTests.B3KcKqlF.js} +22 -23
- package/dist/chunks/{setup-common.Ebx5x0eP.js → setup-common.lgPs-bYv.js} +11 -10
- package/dist/chunks/{execute.Dt-pCVcL.js → startModuleRunner.C8FtT_BY.js} +381 -312
- package/dist/chunks/{typechecker.CMNPqJOo.js → typechecker.BgoW4nTA.js} +1 -1
- package/dist/chunks/{utils.XdZDrNZV.js → utils.B9FY3b73.js} +7 -8
- package/dist/chunks/{vi.CA0EPI9Y.js → vi.DGAfBY4R.js} +12 -8
- package/dist/chunks/{vm.BUnLJt_P.js → vm.BKfKvaKl.js} +36 -56
- package/dist/chunks/{worker.d.zjyR34Pb.d.ts → worker.d.D9QWnzAe.d.ts} +16 -13
- package/dist/chunks/{worker.d.C-1AbnVe.d.ts → worker.d.Db-UVmXc.d.ts} +1 -1
- package/dist/cli.js +4 -4
- package/dist/config.cjs +3 -9
- package/dist/config.d.ts +10 -12
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +10 -11
- package/dist/coverage.js +5 -6
- package/dist/environments.d.ts +2 -2
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.js +5 -4
- package/dist/module-evaluator.d.ts +12 -0
- package/dist/module-evaluator.js +327 -0
- package/dist/module-runner.js +15 -0
- package/dist/node.d.ts +12 -13
- package/dist/node.js +15 -14
- package/dist/reporters.d.ts +7 -8
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +3 -3
- package/dist/runners.js +16 -10
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +84 -31
- package/dist/workers/forks.js +10 -9
- package/dist/workers/runVmTests.js +16 -17
- package/dist/workers/threads.js +10 -9
- package/dist/workers/vmForks.js +9 -8
- package/dist/workers/vmThreads.js +9 -8
- package/dist/workers.d.ts +5 -4
- package/dist/workers.js +14 -13
- package/package.json +21 -16
- package/dist/chunks/base.BaCDDRPG.js +0 -38
- package/dist/execute.d.ts +0 -148
- package/dist/execute.js +0 -13
package/dist/worker.js
CHANGED
|
@@ -1,50 +1,77 @@
|
|
|
1
1
|
import { pathToFileURL } from 'node:url';
|
|
2
2
|
import { createStackString, parseStacktrace } from '@vitest/utils/source-map';
|
|
3
3
|
import { workerId } from 'tinypool';
|
|
4
|
-
import {
|
|
4
|
+
import { ModuleRunner, EvaluatedModules } from 'vite/module-runner';
|
|
5
5
|
import { readFileSync } from 'node:fs';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { isBuiltin } from 'node:module';
|
|
7
|
+
import { resolve } from 'pathe';
|
|
8
|
+
import { V as VitestTransport } from './chunks/moduleTransport.I-bgQy0S.js';
|
|
9
|
+
import { e as environments } from './chunks/index.BRtIe7r8.js';
|
|
8
10
|
import { s as setupInspect } from './chunks/inspector.C914Efll.js';
|
|
9
|
-
import { c as createRuntimeRpc, a as rpcDone } from './chunks/rpc.
|
|
10
|
-
import { i as isChildProcess, s as setProcessTitle } from './chunks/utils.
|
|
11
|
+
import { c as createRuntimeRpc, a as rpcDone } from './chunks/rpc.DGoW_Vl-.js';
|
|
12
|
+
import { i as isChildProcess, s as setProcessTitle } from './chunks/utils.B9FY3b73.js';
|
|
11
13
|
import { d as disposeInternalListeners } from './chunks/utils.CcGm2cd1.js';
|
|
12
14
|
import 'node:console';
|
|
13
|
-
import 'node:module';
|
|
14
15
|
import '@vitest/utils';
|
|
15
16
|
import './chunks/index.Bgo3tNWt.js';
|
|
16
17
|
|
|
17
18
|
function isBuiltinEnvironment(env) {
|
|
18
19
|
return env in environments;
|
|
19
20
|
}
|
|
21
|
+
const isWindows = process.platform === "win32";
|
|
20
22
|
const _loaders = /* @__PURE__ */ new Map();
|
|
21
|
-
async function createEnvironmentLoader(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
async function createEnvironmentLoader(root, rpc) {
|
|
24
|
+
const cachedLoader = _loaders.get(root);
|
|
25
|
+
if (!cachedLoader || cachedLoader.isClosed()) {
|
|
26
|
+
_loaders.delete(root);
|
|
27
|
+
const moduleRunner = new ModuleRunner({
|
|
28
|
+
hmr: false,
|
|
29
|
+
sourcemapInterceptor: "prepareStackTrace",
|
|
30
|
+
transport: new VitestTransport({
|
|
31
|
+
async fetchModule(id, importer, options) {
|
|
32
|
+
const result = await rpc.fetch(id, importer, "__vitest__", options);
|
|
33
|
+
if ("cached" in result) {
|
|
34
|
+
const code = readFileSync(result.tmp, "utf-8");
|
|
35
|
+
return {
|
|
36
|
+
code,
|
|
37
|
+
...result
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (isWindows && "externalize" in result)
|
|
41
|
+
// TODO: vitest returns paths for external modules, but Vite returns file://
|
|
42
|
+
// https://github.com/vitejs/vite/pull/20449
|
|
43
|
+
result.externalize = isBuiltin(id) || /^(?:node:|data:|http:|https:|file:)/.test(id) ? result.externalize : pathToFileURL(result.externalize).toString();
|
|
44
|
+
return result;
|
|
45
|
+
},
|
|
46
|
+
async resolveId(id, importer) {
|
|
47
|
+
return rpc.resolve(id, importer, "__vitest__");
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
_loaders.set(root, moduleRunner);
|
|
52
|
+
await moduleRunner.import("/@vite/env");
|
|
26
53
|
}
|
|
27
|
-
return _loaders.get(
|
|
54
|
+
return _loaders.get(root);
|
|
28
55
|
}
|
|
29
56
|
async function loadEnvironment(ctx, rpc) {
|
|
30
57
|
const name = ctx.environment.name;
|
|
31
|
-
if (isBuiltinEnvironment(name)) return environments[name];
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (result.id) return { code: readFileSync(result.id, "utf-8") };
|
|
37
|
-
return result;
|
|
38
|
-
},
|
|
39
|
-
resolveId: (id, importer) => rpc.resolveId(id, importer, "ssr")
|
|
40
|
-
});
|
|
41
|
-
const root = loader.root;
|
|
42
|
-
const packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : (await rpc.resolveId(`vitest-environment-${name}`, void 0, "ssr"))?.id ?? resolve(root, name);
|
|
43
|
-
const pkg = await loader.executeId(normalize(packageId));
|
|
58
|
+
if (isBuiltinEnvironment(name)) return { environment: environments[name] };
|
|
59
|
+
const root = ctx.config.root;
|
|
60
|
+
const loader = await createEnvironmentLoader(root, rpc);
|
|
61
|
+
const packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : (await rpc.resolve(`vitest-environment-${name}`, void 0, "__vitest__"))?.id ?? resolve(root, name);
|
|
62
|
+
const pkg = await loader.import(packageId);
|
|
44
63
|
if (!pkg || !pkg.default || typeof pkg.default !== "object") throw new TypeError(`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`);
|
|
45
64
|
const environment = pkg.default;
|
|
46
|
-
if (environment.transformMode !== "web" && environment.transformMode !== "ssr") throw new TypeError(`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "transformMode" method equal to "ssr" or "web".`);
|
|
47
|
-
|
|
65
|
+
if (environment.transformMode != null && environment.transformMode !== "web" && environment.transformMode !== "ssr") throw new TypeError(`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "transformMode" method equal to "ssr" or "web", received "${environment.transformMode}".`);
|
|
66
|
+
if (environment.transformMode) {
|
|
67
|
+
console.warn(`The Vitest environment ${environment.name} defines the "transformMode". This options was deprecated in Vitest 4 and will be removed in the next major version. Please, use "viteEnvironment" instead.`);
|
|
68
|
+
// keep for backwards compat
|
|
69
|
+
environment.viteEnvironment ??= environment.transformMode === "ssr" ? "ssr" : "client";
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
environment,
|
|
73
|
+
loader
|
|
74
|
+
};
|
|
48
75
|
}
|
|
49
76
|
|
|
50
77
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -65,6 +92,7 @@ if (isChildProcess()) {
|
|
|
65
92
|
process.exit();
|
|
66
93
|
});
|
|
67
94
|
}
|
|
95
|
+
const resolvingModules = /* @__PURE__ */ new Set();
|
|
68
96
|
// this is what every pool executes when running tests
|
|
69
97
|
async function execute(method, ctx) {
|
|
70
98
|
disposeInternalListeners();
|
|
@@ -72,6 +100,7 @@ async function execute(method, ctx) {
|
|
|
72
100
|
const cleanups = [setupInspect(ctx)];
|
|
73
101
|
process.env.VITEST_WORKER_ID = String(ctx.workerId);
|
|
74
102
|
process.env.VITEST_POOL_ID = String(workerId);
|
|
103
|
+
let environmentLoader;
|
|
75
104
|
try {
|
|
76
105
|
// worker is a filepath or URL to a file that exposes a default export with "getRpcOptions" and "runTests" methods
|
|
77
106
|
if (ctx.worker[0] === ".") throw new Error(`Path to the test runner cannot be relative, received "${ctx.worker}"`);
|
|
@@ -89,11 +118,12 @@ async function execute(method, ctx) {
|
|
|
89
118
|
}));
|
|
90
119
|
});
|
|
91
120
|
const beforeEnvironmentTime = performance.now();
|
|
92
|
-
const environment = await loadEnvironment(ctx, rpc);
|
|
93
|
-
|
|
121
|
+
const { environment, loader } = await loadEnvironment(ctx, rpc);
|
|
122
|
+
environmentLoader = loader;
|
|
94
123
|
const state = {
|
|
95
124
|
ctx,
|
|
96
|
-
|
|
125
|
+
evaluatedModules: new EvaluatedModules(),
|
|
126
|
+
resolvingModules,
|
|
97
127
|
moduleExecutionInfo: /* @__PURE__ */ new Map(),
|
|
98
128
|
config: ctx.config,
|
|
99
129
|
onCancel,
|
|
@@ -107,7 +137,8 @@ async function execute(method, ctx) {
|
|
|
107
137
|
providedContext: ctx.providedContext,
|
|
108
138
|
onFilterStackTrace(stack) {
|
|
109
139
|
return createStackString(parseStacktrace(stack));
|
|
110
|
-
}
|
|
140
|
+
},
|
|
141
|
+
metaEnv: createImportMetaEnvProxy()
|
|
111
142
|
};
|
|
112
143
|
const methodName = method === "collect" ? "collectTests" : "runTests";
|
|
113
144
|
if (!worker[methodName] || typeof worker[methodName] !== "function") throw new TypeError(`Test worker should expose "runTests" method. Received "${typeof worker.runTests}".`);
|
|
@@ -115,6 +146,7 @@ async function execute(method, ctx) {
|
|
|
115
146
|
} finally {
|
|
116
147
|
await Promise.all(cleanups.map((fn) => fn()));
|
|
117
148
|
await rpcDone().catch(() => {});
|
|
149
|
+
environmentLoader?.close();
|
|
118
150
|
}
|
|
119
151
|
}
|
|
120
152
|
function run(ctx) {
|
|
@@ -126,5 +158,26 @@ function collect(ctx) {
|
|
|
126
158
|
async function teardown() {
|
|
127
159
|
return cleanup();
|
|
128
160
|
}
|
|
161
|
+
function createImportMetaEnvProxy() {
|
|
162
|
+
// packages/vitest/src/node/plugins/index.ts:146
|
|
163
|
+
const booleanKeys = [
|
|
164
|
+
"DEV",
|
|
165
|
+
"PROD",
|
|
166
|
+
"SSR"
|
|
167
|
+
];
|
|
168
|
+
return new Proxy(process.env, {
|
|
169
|
+
get(_, key) {
|
|
170
|
+
if (typeof key !== "string") return void 0;
|
|
171
|
+
if (booleanKeys.includes(key)) return !!process.env[key];
|
|
172
|
+
return process.env[key];
|
|
173
|
+
},
|
|
174
|
+
set(_, key, value) {
|
|
175
|
+
if (typeof key !== "string") return true;
|
|
176
|
+
if (booleanKeys.includes(key)) process.env[key] = value ? "1" : "";
|
|
177
|
+
else process.env[key] = value;
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
129
182
|
|
|
130
183
|
export { collect, run, teardown };
|
package/dist/workers/forks.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import v8 from 'node:v8';
|
|
2
|
-
import { r as runBaseTests } from '../chunks/base.
|
|
2
|
+
import { r as runBaseTests } from '../chunks/base.DMfOuRWD.js';
|
|
3
3
|
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.CcGm2cd1.js';
|
|
4
|
-
import 'vite-
|
|
5
|
-
import '../chunks/
|
|
4
|
+
import 'vite/module-runner';
|
|
5
|
+
import '../chunks/startModuleRunner.C8FtT_BY.js';
|
|
6
6
|
import 'node:fs';
|
|
7
|
+
import 'node:module';
|
|
8
|
+
import '@vitest/utils';
|
|
7
9
|
import 'node:url';
|
|
8
|
-
import 'node:vm';
|
|
9
|
-
import '@vitest/utils/error';
|
|
10
10
|
import 'pathe';
|
|
11
|
-
import 'vite-node/utils';
|
|
12
11
|
import '../path.js';
|
|
13
12
|
import 'node:path';
|
|
13
|
+
import '@vitest/utils/error';
|
|
14
|
+
import '../module-evaluator.js';
|
|
15
|
+
import 'node:vm';
|
|
14
16
|
import '@vitest/mocker';
|
|
15
|
-
import '
|
|
16
|
-
import '
|
|
17
|
-
import '../chunks/utils.XdZDrNZV.js';
|
|
17
|
+
import '../chunks/moduleTransport.I-bgQy0S.js';
|
|
18
|
+
import '../chunks/utils.B9FY3b73.js';
|
|
18
19
|
|
|
19
20
|
class ForksBaseWorker {
|
|
20
21
|
getRpcOptions() {
|
|
@@ -4,23 +4,21 @@ 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 '
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { V as VitestIndex } from '../chunks/index.D1_MsKEt.js';
|
|
7
|
+
import { KNOWN_ASSET_TYPES } from '@vitest/utils';
|
|
8
|
+
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/index.oWRWx-nj.js';
|
|
9
|
+
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.lgPs-bYv.js';
|
|
10
|
+
import { V as VitestIndex } from '../chunks/index.QZr3S3vQ.js';
|
|
12
11
|
import { c as closeInspector } from '../chunks/inspector.C914Efll.js';
|
|
13
|
-
import { g as getWorkerState } from '../chunks/utils.
|
|
12
|
+
import { g as getWorkerState } from '../chunks/utils.B9FY3b73.js';
|
|
14
13
|
import 'chai';
|
|
15
14
|
import 'node:path';
|
|
16
15
|
import '../path.js';
|
|
17
16
|
import 'node:url';
|
|
18
|
-
import '../chunks/rpc.
|
|
19
|
-
import '@vitest/utils';
|
|
17
|
+
import '../chunks/rpc.DGoW_Vl-.js';
|
|
20
18
|
import '../chunks/index.Bgo3tNWt.js';
|
|
21
|
-
import '../chunks/coverage.
|
|
19
|
+
import '../chunks/coverage.D_JHT54q.js';
|
|
22
20
|
import '@vitest/snapshot';
|
|
23
|
-
import '../chunks/vi.
|
|
21
|
+
import '../chunks/vi.DGAfBY4R.js';
|
|
24
22
|
import '@vitest/expect';
|
|
25
23
|
import '@vitest/runner/utils';
|
|
26
24
|
import '../chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
@@ -28,17 +26,19 @@ import '@vitest/utils/error';
|
|
|
28
26
|
import '@vitest/spy';
|
|
29
27
|
import '@vitest/utils/source-map';
|
|
30
28
|
import '../chunks/date.Bq6ZW5rf.js';
|
|
31
|
-
import '../chunks/benchmark.
|
|
29
|
+
import '../chunks/benchmark.CtuRzf-i.js';
|
|
32
30
|
import 'expect-type';
|
|
31
|
+
import 'vite/module-runner';
|
|
33
32
|
|
|
34
|
-
async function run(method, files, config,
|
|
33
|
+
async function run(method, files, config, moduleRunner) {
|
|
35
34
|
const workerState = getWorkerState();
|
|
36
35
|
await setupCommonEnv(config);
|
|
37
36
|
Object.defineProperty(globalThis, "__vitest_index__", {
|
|
38
37
|
value: VitestIndex,
|
|
39
38
|
enumerable: false
|
|
40
39
|
});
|
|
41
|
-
|
|
40
|
+
const viteEnvironment = workerState.environment.viteEnvironment || workerState.environment.name;
|
|
41
|
+
if (viteEnvironment === "client") {
|
|
42
42
|
const _require = createRequire(import.meta.url);
|
|
43
43
|
// always mock "required" `css` files, because we cannot process them
|
|
44
44
|
_require.extensions[".css"] = resolveCss;
|
|
@@ -57,10 +57,9 @@ async function run(method, files, config, executor) {
|
|
|
57
57
|
timers,
|
|
58
58
|
timersPromises
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
await startCoverageInsideWorker(config.coverage, executor, { isolate: false });
|
|
60
|
+
await startCoverageInsideWorker(config.coverage, moduleRunner, { isolate: false });
|
|
62
61
|
if (config.chaiConfig) setupChaiConfig(config.chaiConfig);
|
|
63
|
-
const [runner, snapshotEnvironment] = await Promise.all([resolveTestRunner(config,
|
|
62
|
+
const [runner, snapshotEnvironment] = await Promise.all([resolveTestRunner(config, moduleRunner), resolveSnapshotEnvironment(config, moduleRunner)]);
|
|
64
63
|
config.snapshotOptions.snapshotEnvironment = snapshotEnvironment;
|
|
65
64
|
runner.getWorkerContext = void 0;
|
|
66
65
|
workerState.onCancel.then((reason) => {
|
|
@@ -78,7 +77,7 @@ async function run(method, files, config, executor) {
|
|
|
78
77
|
// mocks should not affect different files
|
|
79
78
|
vi.restoreAllMocks();
|
|
80
79
|
}
|
|
81
|
-
await stopCoverageInsideWorker(config.coverage,
|
|
80
|
+
await stopCoverageInsideWorker(config.coverage, moduleRunner, { isolate: false });
|
|
82
81
|
}
|
|
83
82
|
function resolveCss(mod) {
|
|
84
83
|
mod.exports = "";
|
package/dist/workers/threads.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { r as runBaseTests } from '../chunks/base.
|
|
1
|
+
import { r as runBaseTests } from '../chunks/base.DMfOuRWD.js';
|
|
2
2
|
import { a as createThreadsRpcOptions } from '../chunks/utils.CcGm2cd1.js';
|
|
3
|
-
import 'vite-
|
|
4
|
-
import '../chunks/
|
|
3
|
+
import 'vite/module-runner';
|
|
4
|
+
import '../chunks/startModuleRunner.C8FtT_BY.js';
|
|
5
5
|
import 'node:fs';
|
|
6
|
+
import 'node:module';
|
|
7
|
+
import '@vitest/utils';
|
|
6
8
|
import 'node:url';
|
|
7
|
-
import 'node:vm';
|
|
8
|
-
import '@vitest/utils/error';
|
|
9
9
|
import 'pathe';
|
|
10
|
-
import 'vite-node/utils';
|
|
11
10
|
import '../path.js';
|
|
12
11
|
import 'node:path';
|
|
12
|
+
import '@vitest/utils/error';
|
|
13
|
+
import '../module-evaluator.js';
|
|
14
|
+
import 'node:vm';
|
|
13
15
|
import '@vitest/mocker';
|
|
14
|
-
import '
|
|
15
|
-
import '
|
|
16
|
-
import '../chunks/utils.XdZDrNZV.js';
|
|
16
|
+
import '../chunks/moduleTransport.I-bgQy0S.js';
|
|
17
|
+
import '../chunks/utils.B9FY3b73.js';
|
|
17
18
|
|
|
18
19
|
class ThreadsBaseWorker {
|
|
19
20
|
getRpcOptions(ctx) {
|
package/dist/workers/vmForks.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import v8 from 'node:v8';
|
|
2
2
|
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.CcGm2cd1.js';
|
|
3
|
-
import { r as runVmTests } from '../chunks/vm.
|
|
3
|
+
import { r as runVmTests } from '../chunks/vm.BKfKvaKl.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.Duv2dVIC.js';
|
|
11
11
|
import 'node:console';
|
|
12
12
|
import 'node:stream';
|
|
13
13
|
import 'tinyrainbow';
|
|
14
14
|
import '../chunks/date.Bq6ZW5rf.js';
|
|
15
|
-
import '../chunks/utils.
|
|
16
|
-
import '../chunks/execute.Dt-pCVcL.js';
|
|
15
|
+
import '../chunks/utils.B9FY3b73.js';
|
|
17
16
|
import 'node:fs';
|
|
17
|
+
import 'node:module';
|
|
18
|
+
import '../chunks/resolver.D5bG4zy5.js';
|
|
19
|
+
import '../module-evaluator.js';
|
|
20
|
+
import 'vite/module-runner';
|
|
21
|
+
import '../chunks/startModuleRunner.C8FtT_BY.js';
|
|
18
22
|
import '@vitest/utils/error';
|
|
19
|
-
import 'vite-node/client';
|
|
20
|
-
import 'vite-node/utils';
|
|
21
23
|
import '@vitest/mocker';
|
|
22
|
-
import '
|
|
23
|
-
import 'vite-node/constants';
|
|
24
|
+
import '../chunks/moduleTransport.I-bgQy0S.js';
|
|
24
25
|
|
|
25
26
|
class ForksVmWorker {
|
|
26
27
|
getRpcOptions() {
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { a as createThreadsRpcOptions } from '../chunks/utils.CcGm2cd1.js';
|
|
2
|
-
import { r as runVmTests } from '../chunks/vm.
|
|
2
|
+
import { r as runVmTests } from '../chunks/vm.BKfKvaKl.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.Duv2dVIC.js';
|
|
10
10
|
import 'node:console';
|
|
11
11
|
import 'node:stream';
|
|
12
12
|
import 'tinyrainbow';
|
|
13
13
|
import '../chunks/date.Bq6ZW5rf.js';
|
|
14
|
-
import '../chunks/utils.
|
|
15
|
-
import '../chunks/execute.Dt-pCVcL.js';
|
|
14
|
+
import '../chunks/utils.B9FY3b73.js';
|
|
16
15
|
import 'node:fs';
|
|
16
|
+
import 'node:module';
|
|
17
|
+
import '../chunks/resolver.D5bG4zy5.js';
|
|
18
|
+
import '../module-evaluator.js';
|
|
19
|
+
import 'vite/module-runner';
|
|
20
|
+
import '../chunks/startModuleRunner.C8FtT_BY.js';
|
|
17
21
|
import '@vitest/utils/error';
|
|
18
|
-
import 'vite-node/client';
|
|
19
|
-
import 'vite-node/utils';
|
|
20
22
|
import '@vitest/mocker';
|
|
21
|
-
import '
|
|
22
|
-
import 'vite-node/constants';
|
|
23
|
+
import '../chunks/moduleTransport.I-bgQy0S.js';
|
|
23
24
|
|
|
24
25
|
class ThreadsVmWorker {
|
|
25
26
|
getRpcOptions(ctx) {
|
package/dist/workers.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
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.D9QWnzAe.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.CKNVOKm0.js';
|
|
5
|
+
import { W as WorkerContext } from './chunks/worker.d.Db-UVmXc.js';
|
|
6
6
|
import '@vitest/runner';
|
|
7
|
-
import '
|
|
7
|
+
import 'vite/module-runner';
|
|
8
|
+
import './chunks/environment.d.2fYMoz3o.js';
|
|
8
9
|
import '@vitest/snapshot';
|
|
9
10
|
import '@vitest/pretty-format';
|
|
10
11
|
import '@vitest/utils/diff';
|
package/dist/workers.js
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
export { p as provideWorkerState } from './chunks/utils.
|
|
1
|
+
export { p as provideWorkerState } from './chunks/utils.B9FY3b73.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.DMfOuRWD.js';
|
|
4
4
|
export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './chunks/utils.CcGm2cd1.js';
|
|
5
|
-
export { r as runVmTests } from './chunks/vm.
|
|
5
|
+
export { r as runVmTests } from './chunks/vm.BKfKvaKl.js';
|
|
6
6
|
import '@vitest/utils';
|
|
7
7
|
import 'node:url';
|
|
8
8
|
import '@vitest/utils/source-map';
|
|
9
9
|
import 'tinypool';
|
|
10
|
-
import 'vite-
|
|
10
|
+
import 'vite/module-runner';
|
|
11
11
|
import 'node:fs';
|
|
12
|
+
import 'node:module';
|
|
12
13
|
import 'pathe';
|
|
13
|
-
import './chunks/
|
|
14
|
+
import './chunks/moduleTransport.I-bgQy0S.js';
|
|
15
|
+
import './chunks/index.BRtIe7r8.js';
|
|
14
16
|
import 'node:console';
|
|
15
17
|
import './chunks/inspector.C914Efll.js';
|
|
16
|
-
import '
|
|
17
|
-
import './chunks/rpc.jnQO9F8a.js';
|
|
18
|
+
import './chunks/rpc.DGoW_Vl-.js';
|
|
18
19
|
import './chunks/index.Bgo3tNWt.js';
|
|
19
|
-
import './chunks/
|
|
20
|
-
import 'node:vm';
|
|
21
|
-
import '@vitest/utils/error';
|
|
22
|
-
import 'vite-node/utils';
|
|
20
|
+
import './chunks/startModuleRunner.C8FtT_BY.js';
|
|
23
21
|
import './path.js';
|
|
24
22
|
import 'node:path';
|
|
23
|
+
import '@vitest/utils/error';
|
|
24
|
+
import './module-evaluator.js';
|
|
25
|
+
import 'node:vm';
|
|
25
26
|
import '@vitest/mocker';
|
|
26
|
-
import './chunks/console.
|
|
27
|
+
import './chunks/console.Duv2dVIC.js';
|
|
27
28
|
import 'node:stream';
|
|
28
29
|
import 'tinyrainbow';
|
|
29
30
|
import './chunks/date.Bq6ZW5rf.js';
|
|
30
|
-
import '
|
|
31
|
+
import './chunks/resolver.D5bG4zy5.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.5",
|
|
5
5
|
"description": "Next generation testing framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,6 +22,12 @@
|
|
|
22
22
|
"jest"
|
|
23
23
|
],
|
|
24
24
|
"sideEffects": false,
|
|
25
|
+
"imports": {
|
|
26
|
+
"#module-evaluator": {
|
|
27
|
+
"types": "./dist/module-evaluator.d.ts",
|
|
28
|
+
"default": "./dist/module-evaluator.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
25
31
|
"exports": {
|
|
26
32
|
".": {
|
|
27
33
|
"import": {
|
|
@@ -50,10 +56,6 @@
|
|
|
50
56
|
"types": "./dist/node.d.ts",
|
|
51
57
|
"default": "./dist/node.js"
|
|
52
58
|
},
|
|
53
|
-
"./execute": {
|
|
54
|
-
"types": "./dist/execute.d.ts",
|
|
55
|
-
"default": "./dist/execute.js"
|
|
56
|
-
},
|
|
57
59
|
"./workers": {
|
|
58
60
|
"types": "./dist/workers.d.ts",
|
|
59
61
|
"import": "./dist/workers.js"
|
|
@@ -62,6 +64,10 @@
|
|
|
62
64
|
"types": "./dist/browser.d.ts",
|
|
63
65
|
"default": "./dist/browser.js"
|
|
64
66
|
},
|
|
67
|
+
"./internal/module-runner": {
|
|
68
|
+
"types": "./dist/module-runner.d.ts",
|
|
69
|
+
"default": "./dist/module-runner.js"
|
|
70
|
+
},
|
|
65
71
|
"./runners": {
|
|
66
72
|
"types": "./dist/runners.d.ts",
|
|
67
73
|
"default": "./dist/runners.js"
|
|
@@ -119,8 +125,8 @@
|
|
|
119
125
|
"@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
|
|
120
126
|
"happy-dom": "*",
|
|
121
127
|
"jsdom": "*",
|
|
122
|
-
"@vitest/browser": "4.0.0-beta.
|
|
123
|
-
"@vitest/ui": "4.0.0-beta.
|
|
128
|
+
"@vitest/browser": "4.0.0-beta.5",
|
|
129
|
+
"@vitest/ui": "4.0.0-beta.5"
|
|
124
130
|
},
|
|
125
131
|
"peerDependenciesMeta": {
|
|
126
132
|
"@edge-runtime/vm": {
|
|
@@ -149,6 +155,7 @@
|
|
|
149
155
|
"@types/chai": "^5.2.2",
|
|
150
156
|
"chai": "^5.2.1",
|
|
151
157
|
"debug": "^4.4.1",
|
|
158
|
+
"es-module-lexer": "^1.7.0",
|
|
152
159
|
"expect-type": "^1.2.2",
|
|
153
160
|
"magic-string": "^0.30.17",
|
|
154
161
|
"pathe": "^2.0.3",
|
|
@@ -161,14 +168,13 @@
|
|
|
161
168
|
"tinyrainbow": "^2.0.0",
|
|
162
169
|
"vite": "^6.0.0 || ^7.0.0-0",
|
|
163
170
|
"why-is-node-running": "^2.3.0",
|
|
164
|
-
"@vitest/expect": "4.0.0-beta.
|
|
165
|
-
"@vitest/
|
|
166
|
-
"@vitest/
|
|
167
|
-
"@vitest/
|
|
168
|
-
"@vitest/spy": "4.0.0-beta.
|
|
169
|
-
"@vitest/snapshot": "4.0.0-beta.
|
|
170
|
-
"
|
|
171
|
-
"@vitest/utils": "4.0.0-beta.4"
|
|
171
|
+
"@vitest/expect": "4.0.0-beta.5",
|
|
172
|
+
"@vitest/pretty-format": "^4.0.0-beta.5",
|
|
173
|
+
"@vitest/runner": "4.0.0-beta.5",
|
|
174
|
+
"@vitest/mocker": "4.0.0-beta.5",
|
|
175
|
+
"@vitest/spy": "4.0.0-beta.5",
|
|
176
|
+
"@vitest/snapshot": "4.0.0-beta.5",
|
|
177
|
+
"@vitest/utils": "4.0.0-beta.5"
|
|
172
178
|
},
|
|
173
179
|
"devDependencies": {
|
|
174
180
|
"@ampproject/remapping": "^2.3.0",
|
|
@@ -180,7 +186,6 @@
|
|
|
180
186
|
"@types/istanbul-lib-coverage": "^2.0.6",
|
|
181
187
|
"@types/istanbul-reports": "^3.0.4",
|
|
182
188
|
"@types/jsdom": "^21.1.7",
|
|
183
|
-
"@types/mime": "^4.0.0",
|
|
184
189
|
"@types/node": "^22.16.5",
|
|
185
190
|
"@types/picomatch": "^4.0.1",
|
|
186
191
|
"@types/prompts": "^2.4.9",
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ModuleCacheMap } from 'vite-node/client';
|
|
2
|
-
import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.Dt-pCVcL.js';
|
|
3
|
-
import { p as provideWorkerState } from './utils.XdZDrNZV.js';
|
|
4
|
-
|
|
5
|
-
let _viteNode;
|
|
6
|
-
const moduleCache = new ModuleCacheMap();
|
|
7
|
-
const moduleExecutionInfo = /* @__PURE__ */ new Map();
|
|
8
|
-
async function startViteNode(options) {
|
|
9
|
-
if (_viteNode) return _viteNode;
|
|
10
|
-
_viteNode = await startVitestExecutor(options);
|
|
11
|
-
return _viteNode;
|
|
12
|
-
}
|
|
13
|
-
async function runBaseTests(method, state) {
|
|
14
|
-
const { ctx } = state;
|
|
15
|
-
// state has new context, but we want to reuse existing ones
|
|
16
|
-
state.moduleCache = moduleCache;
|
|
17
|
-
state.moduleExecutionInfo = moduleExecutionInfo;
|
|
18
|
-
provideWorkerState(globalThis, state);
|
|
19
|
-
if (ctx.invalidates) ctx.invalidates.forEach((fsPath) => {
|
|
20
|
-
moduleCache.delete(fsPath);
|
|
21
|
-
moduleCache.delete(`mock:${fsPath}`);
|
|
22
|
-
});
|
|
23
|
-
ctx.files.forEach((i) => state.moduleCache.delete(typeof i === "string" ? i : i.filepath));
|
|
24
|
-
const [executor, { run }] = await Promise.all([startViteNode({
|
|
25
|
-
state,
|
|
26
|
-
requestStubs: getDefaultRequestStubs()
|
|
27
|
-
}), import('./runBaseTests.DBVVLMSb.js')]);
|
|
28
|
-
const fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
|
|
29
|
-
filepath: f,
|
|
30
|
-
testLocations: void 0
|
|
31
|
-
} : f);
|
|
32
|
-
await run(method, fileSpecs, ctx.config, {
|
|
33
|
-
environment: state.environment,
|
|
34
|
-
options: ctx.environment.options
|
|
35
|
-
}, executor);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { runBaseTests as r };
|