vitest 3.1.0-beta.1 → 3.1.0
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 +29 -0
- package/dist/browser.js +4 -4
- package/dist/chunks/base.bV8rwssx.js +41 -0
- package/dist/chunks/benchmark.BKUatJGy.js +39 -0
- package/dist/chunks/cac.1WcTh-zl.js +1529 -0
- package/dist/chunks/{cli-api.BwkkJsRe.js → cli-api.2yb7XCwB.js} +4640 -5072
- package/dist/chunks/console.D6t261w0.js +173 -0
- package/dist/chunks/constants.BZZyIeIE.js +43 -0
- package/dist/chunks/coverage.0iPg4Wrz.js +33 -0
- package/dist/chunks/{coverage.gV8doR2Y.js → coverage.SfnlalVs.js} +2424 -2482
- package/dist/chunks/creator.CuL7xDWI.js +705 -0
- package/dist/chunks/date.CDOsz-HY.js +53 -0
- package/dist/chunks/defaults.DmfNPoe5.js +114 -0
- package/dist/chunks/{env.D4Lgay0q.js → env.Dq0hM4Xv.js} +1 -1
- package/dist/chunks/execute.CwmnH2oH.js +791 -0
- package/dist/chunks/git.DXfdBEfR.js +74 -0
- package/dist/chunks/{globals.BEpDe-k3.js → globals.DCbUWjip.js} +10 -10
- package/dist/chunks/{index.D7Ny8f_s.js → index.BDobFbcz.js} +6 -7
- package/dist/chunks/index.CwHmn5H5.js +2422 -0
- package/dist/chunks/index.DFXFpH3w.js +607 -0
- package/dist/chunks/index.VfYQ6MXY.js +104 -0
- package/dist/chunks/inspector.DbDkSkFn.js +54 -0
- package/dist/chunks/node.IqGoMrm4.js +15 -0
- package/dist/chunks/{reporters.d.r7poTZjA.d.ts → reporters.d.CfRkRKN2.d.ts} +52 -20
- package/dist/chunks/rpc.DGgL5dw7.js +92 -0
- package/dist/chunks/run-once.I7PpBOk1.js +47 -0
- package/dist/chunks/runBaseTests.CqmKSG99.js +134 -0
- package/dist/chunks/setup-common.DEGDGBiA.js +88 -0
- package/dist/chunks/{typechecker.BlF3eHsb.js → typechecker.CG0zmr19.js} +620 -622
- package/dist/chunks/utils.BfxieIyZ.js +66 -0
- package/dist/chunks/utils.CtocqOoE.js +72 -0
- package/dist/chunks/utils.Lot3J_8U.js +194 -0
- package/dist/chunks/{vi.nSCvwQ7l.js → vi.B-PuvDzu.js} +878 -1019
- package/dist/chunks/vite.d.4pkSbgmp.d.ts +23 -0
- package/dist/chunks/vm.Lp7mPCVW.js +796 -0
- package/dist/cli.js +2 -2
- package/dist/config.cjs +97 -103
- package/dist/config.d.ts +6 -4
- package/dist/config.js +6 -6
- package/dist/coverage.d.ts +2 -1
- package/dist/coverage.js +7 -7
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +0 -2
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +6 -6
- package/dist/node.d.ts +17 -6
- package/dist/node.js +36 -45
- package/dist/path.js +1 -4
- package/dist/reporters.d.ts +2 -1
- package/dist/reporters.js +4 -4
- package/dist/runners.js +231 -267
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +98 -114
- package/dist/workers/forks.js +22 -22
- package/dist/workers/runVmTests.js +61 -66
- package/dist/workers/threads.js +13 -13
- package/dist/workers/vmForks.js +24 -24
- package/dist/workers/vmThreads.js +15 -15
- package/dist/workers.d.ts +2 -1
- package/dist/workers.js +10 -10
- package/package.json +17 -17
- package/dist/chunks/base.DV59CbtV.js +0 -45
- package/dist/chunks/benchmark.DL72EVN-.js +0 -40
- package/dist/chunks/cac.BjmXy7OV.js +0 -1664
- package/dist/chunks/console.CN7AiMGV.js +0 -179
- package/dist/chunks/constants.DTYd6dNH.js +0 -46
- package/dist/chunks/coverage.A3sS5-Wm.js +0 -40
- package/dist/chunks/creator.BsBnpTzI.js +0 -670
- package/dist/chunks/date.W2xKR2qe.js +0 -53
- package/dist/chunks/defaults.C2Ndd9wx.js +0 -119
- package/dist/chunks/execute.eDH0aFFd.js +0 -839
- package/dist/chunks/git.B5SDxu-n.js +0 -69
- package/dist/chunks/index.DOyx6FYJ.js +0 -2551
- package/dist/chunks/index.K90BXFOx.js +0 -658
- package/dist/chunks/index.uXkkC4xl.js +0 -111
- package/dist/chunks/inspector.DKLceBVD.js +0 -54
- package/dist/chunks/node.AKq966Jp.js +0 -15
- package/dist/chunks/rpc.TVf73xOu.js +0 -102
- package/dist/chunks/run-once.2ogXb3JV.js +0 -28
- package/dist/chunks/runBaseTests.BVrL_ow3.js +0 -142
- package/dist/chunks/setup-common.CPvtqi8q.js +0 -96
- package/dist/chunks/utils.C8RiOc4B.js +0 -77
- package/dist/chunks/utils.Cn0zI1t3.js +0 -68
- package/dist/chunks/utils.bLM2atbD.js +0 -198
- package/dist/chunks/vite.d.Fvq-NZoa.d.ts +0 -11
- package/dist/chunks/vm.jEFQDlX_.js +0 -852
package/dist/worker.js
CHANGED
|
@@ -4,139 +4,123 @@ import { workerId } from 'tinypool';
|
|
|
4
4
|
import { ViteNodeRunner, ModuleCacheMap } from 'vite-node/client';
|
|
5
5
|
import { readFileSync } from 'node:fs';
|
|
6
6
|
import { resolve, normalize } from 'pathe';
|
|
7
|
-
import { e as environments } from './chunks/index.
|
|
8
|
-
import { s as setupInspect } from './chunks/inspector.
|
|
9
|
-
import { c as createRuntimeRpc, a as rpcDone } from './chunks/rpc.
|
|
10
|
-
import { i as isChildProcess, s as setProcessTitle } from './chunks/utils.
|
|
11
|
-
import { d as disposeInternalListeners } from './chunks/utils.
|
|
7
|
+
import { e as environments } from './chunks/index.DFXFpH3w.js';
|
|
8
|
+
import { s as setupInspect } from './chunks/inspector.DbDkSkFn.js';
|
|
9
|
+
import { c as createRuntimeRpc, a as rpcDone } from './chunks/rpc.DGgL5dw7.js';
|
|
10
|
+
import { i as isChildProcess, s as setProcessTitle } from './chunks/utils.CtocqOoE.js';
|
|
11
|
+
import { d as disposeInternalListeners } from './chunks/utils.BfxieIyZ.js';
|
|
12
12
|
import 'node:console';
|
|
13
13
|
import 'node:module';
|
|
14
14
|
import '@vitest/utils';
|
|
15
15
|
import './chunks/index.68735LiX.js';
|
|
16
16
|
|
|
17
17
|
function isBuiltinEnvironment(env) {
|
|
18
|
-
|
|
18
|
+
return env in environments;
|
|
19
19
|
}
|
|
20
|
-
const _loaders =
|
|
20
|
+
const _loaders = new Map();
|
|
21
21
|
async function createEnvironmentLoader(options) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
if (!_loaders.has(options.root)) {
|
|
23
|
+
const loader = new ViteNodeRunner(options);
|
|
24
|
+
await loader.executeId("/@vite/env");
|
|
25
|
+
_loaders.set(options.root, loader);
|
|
26
|
+
}
|
|
27
|
+
return _loaders.get(options.root);
|
|
28
28
|
}
|
|
29
29
|
async function loadEnvironment(ctx, rpc) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "transformMode" method equal to "ssr" or "web".`
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
return environment;
|
|
30
|
+
const name = ctx.environment.name;
|
|
31
|
+
if (isBuiltinEnvironment(name)) {
|
|
32
|
+
return environments[name];
|
|
33
|
+
}
|
|
34
|
+
const loader = await createEnvironmentLoader({
|
|
35
|
+
root: ctx.config.root,
|
|
36
|
+
fetchModule: async (id) => {
|
|
37
|
+
const result = await rpc.fetch(id, "ssr");
|
|
38
|
+
if (result.id) {
|
|
39
|
+
return { code: readFileSync(result.id, "utf-8") };
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
},
|
|
43
|
+
resolveId: (id, importer) => rpc.resolveId(id, importer, "ssr")
|
|
44
|
+
});
|
|
45
|
+
const root = loader.root;
|
|
46
|
+
const packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : (await rpc.resolveId(`vitest-environment-${name}`, undefined, "ssr"))?.id ?? resolve(root, name);
|
|
47
|
+
const pkg = await loader.executeId(normalize(packageId));
|
|
48
|
+
if (!pkg || !pkg.default || typeof pkg.default !== "object") {
|
|
49
|
+
throw new TypeError(`Environment "${name}" is not a valid environment. ` + `Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`);
|
|
50
|
+
}
|
|
51
|
+
const environment = pkg.default;
|
|
52
|
+
if (environment.transformMode !== "web" && environment.transformMode !== "ssr") {
|
|
53
|
+
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".`);
|
|
54
|
+
}
|
|
55
|
+
return environment;
|
|
60
56
|
}
|
|
61
57
|
|
|
62
58
|
if (isChildProcess()) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
});
|
|
71
|
-
}
|
|
59
|
+
setProcessTitle(`vitest ${workerId}`);
|
|
60
|
+
const isProfiling = process.execArgv.some((execArg) => execArg.startsWith("--prof") || execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir"));
|
|
61
|
+
if (isProfiling) {
|
|
62
|
+
process.on("SIGTERM", () => {
|
|
63
|
+
process.exit();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
72
66
|
}
|
|
73
67
|
async function execute(method, ctx) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
throw new TypeError(
|
|
125
|
-
`Test worker should expose "runTests" method. Received "${typeof worker.runTests}".`
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
await worker[methodName](state);
|
|
129
|
-
} finally {
|
|
130
|
-
await rpcDone().catch(() => {
|
|
131
|
-
});
|
|
132
|
-
inspectorCleanup();
|
|
133
|
-
}
|
|
68
|
+
disposeInternalListeners();
|
|
69
|
+
const prepareStart = performance.now();
|
|
70
|
+
const inspectorCleanup = setupInspect(ctx);
|
|
71
|
+
process.env.VITEST_WORKER_ID = String(ctx.workerId);
|
|
72
|
+
process.env.VITEST_POOL_ID = String(workerId);
|
|
73
|
+
try {
|
|
74
|
+
if (ctx.worker[0] === ".") {
|
|
75
|
+
throw new Error(`Path to the test runner cannot be relative, received "${ctx.worker}"`);
|
|
76
|
+
}
|
|
77
|
+
const file = ctx.worker.startsWith("file:") ? ctx.worker : pathToFileURL(ctx.worker).toString();
|
|
78
|
+
const testRunnerModule = await import(file);
|
|
79
|
+
if (!testRunnerModule.default || typeof testRunnerModule.default !== "object") {
|
|
80
|
+
throw new TypeError(`Test worker object should be exposed as a default export. Received "${typeof testRunnerModule.default}"`);
|
|
81
|
+
}
|
|
82
|
+
const worker = testRunnerModule.default;
|
|
83
|
+
if (!worker.getRpcOptions || typeof worker.getRpcOptions !== "function") {
|
|
84
|
+
throw new TypeError(`Test worker should expose "getRpcOptions" method. Received "${typeof worker.getRpcOptions}".`);
|
|
85
|
+
}
|
|
86
|
+
const { rpc, onCancel } = createRuntimeRpc(worker.getRpcOptions(ctx));
|
|
87
|
+
const beforeEnvironmentTime = performance.now();
|
|
88
|
+
const environment = await loadEnvironment(ctx, rpc);
|
|
89
|
+
if (ctx.environment.transformMode) {
|
|
90
|
+
environment.transformMode = ctx.environment.transformMode;
|
|
91
|
+
}
|
|
92
|
+
const state = {
|
|
93
|
+
ctx,
|
|
94
|
+
moduleCache: new ModuleCacheMap(),
|
|
95
|
+
moduleExecutionInfo: new Map(),
|
|
96
|
+
config: ctx.config,
|
|
97
|
+
onCancel,
|
|
98
|
+
environment,
|
|
99
|
+
durations: {
|
|
100
|
+
environment: beforeEnvironmentTime,
|
|
101
|
+
prepare: prepareStart
|
|
102
|
+
},
|
|
103
|
+
rpc,
|
|
104
|
+
providedContext: ctx.providedContext,
|
|
105
|
+
onFilterStackTrace(stack) {
|
|
106
|
+
return createStackString(parseStacktrace(stack));
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const methodName = method === "collect" ? "collectTests" : "runTests";
|
|
110
|
+
if (!worker[methodName] || typeof worker[methodName] !== "function") {
|
|
111
|
+
throw new TypeError(`Test worker should expose "runTests" method. Received "${typeof worker.runTests}".`);
|
|
112
|
+
}
|
|
113
|
+
await worker[methodName](state);
|
|
114
|
+
} finally {
|
|
115
|
+
await rpcDone().catch(() => {});
|
|
116
|
+
inspectorCleanup();
|
|
117
|
+
}
|
|
134
118
|
}
|
|
135
119
|
function run(ctx) {
|
|
136
|
-
|
|
120
|
+
return execute("run", ctx);
|
|
137
121
|
}
|
|
138
122
|
function collect(ctx) {
|
|
139
|
-
|
|
123
|
+
return execute("collect", ctx);
|
|
140
124
|
}
|
|
141
125
|
|
|
142
126
|
export { collect, run };
|
package/dist/workers/forks.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import v8 from 'node:v8';
|
|
2
|
-
import { r as runBaseTests } from '../chunks/base.
|
|
3
|
-
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.
|
|
2
|
+
import { r as runBaseTests } from '../chunks/base.bV8rwssx.js';
|
|
3
|
+
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.BfxieIyZ.js';
|
|
4
4
|
import 'vite-node/client';
|
|
5
|
-
import '../chunks/execute.
|
|
5
|
+
import '../chunks/execute.CwmnH2oH.js';
|
|
6
6
|
import 'node:fs';
|
|
7
7
|
import 'node:url';
|
|
8
8
|
import 'node:vm';
|
|
@@ -14,27 +14,27 @@ import 'node:path';
|
|
|
14
14
|
import '@vitest/mocker';
|
|
15
15
|
import 'node:module';
|
|
16
16
|
import '@vitest/utils';
|
|
17
|
-
import '../chunks/utils.
|
|
17
|
+
import '../chunks/utils.CtocqOoE.js';
|
|
18
18
|
|
|
19
19
|
class ForksBaseWorker {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
20
|
+
getRpcOptions() {
|
|
21
|
+
return createForksRpcOptions(v8);
|
|
22
|
+
}
|
|
23
|
+
async executeTests(method, state) {
|
|
24
|
+
const exit = process.exit;
|
|
25
|
+
state.ctx.config = unwrapSerializableConfig(state.ctx.config);
|
|
26
|
+
try {
|
|
27
|
+
await runBaseTests(method, state);
|
|
28
|
+
} finally {
|
|
29
|
+
process.exit = exit;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
runTests(state) {
|
|
33
|
+
return this.executeTests("run", state);
|
|
34
|
+
}
|
|
35
|
+
collectTests(state) {
|
|
36
|
+
return this.executeTests("collect", state);
|
|
37
|
+
}
|
|
38
38
|
}
|
|
39
39
|
const worker = new ForksBaseWorker();
|
|
40
40
|
|
|
@@ -6,92 +6,87 @@ import util from 'node:util';
|
|
|
6
6
|
import { startTests, collectTests } from '@vitest/runner';
|
|
7
7
|
import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
|
|
8
8
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
9
|
-
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/index.
|
|
10
|
-
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.
|
|
11
|
-
import { V as VitestIndex } from '../chunks/index.
|
|
12
|
-
import { c as closeInspector } from '../chunks/inspector.
|
|
13
|
-
import { g as getWorkerState } from '../chunks/utils.
|
|
9
|
+
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/index.VfYQ6MXY.js';
|
|
10
|
+
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.DEGDGBiA.js';
|
|
11
|
+
import { V as VitestIndex } from '../chunks/index.BDobFbcz.js';
|
|
12
|
+
import { c as closeInspector } from '../chunks/inspector.DbDkSkFn.js';
|
|
13
|
+
import { g as getWorkerState } from '../chunks/utils.CtocqOoE.js';
|
|
14
14
|
import 'chai';
|
|
15
15
|
import 'node:path';
|
|
16
16
|
import '../path.js';
|
|
17
17
|
import 'node:url';
|
|
18
|
-
import '../chunks/rpc.
|
|
18
|
+
import '../chunks/rpc.DGgL5dw7.js';
|
|
19
19
|
import '@vitest/utils';
|
|
20
20
|
import '../chunks/index.68735LiX.js';
|
|
21
|
-
import '../chunks/coverage.
|
|
21
|
+
import '../chunks/coverage.0iPg4Wrz.js';
|
|
22
22
|
import '@vitest/snapshot';
|
|
23
|
-
import '../chunks/run-once.
|
|
24
|
-
import '../chunks/vi.
|
|
23
|
+
import '../chunks/run-once.I7PpBOk1.js';
|
|
24
|
+
import '../chunks/vi.B-PuvDzu.js';
|
|
25
25
|
import '@vitest/expect';
|
|
26
26
|
import '@vitest/runner/utils';
|
|
27
27
|
import '../chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
28
28
|
import '@vitest/utils/error';
|
|
29
29
|
import '@vitest/spy';
|
|
30
30
|
import '@vitest/utils/source-map';
|
|
31
|
-
import '../chunks/date.
|
|
32
|
-
import '../chunks/benchmark.
|
|
31
|
+
import '../chunks/date.CDOsz-HY.js';
|
|
32
|
+
import '../chunks/benchmark.BKUatJGy.js';
|
|
33
33
|
import 'expect-type';
|
|
34
34
|
|
|
35
35
|
async function run(method, files, config, executor) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
vi.resetConfig();
|
|
86
|
-
vi.restoreAllMocks();
|
|
87
|
-
}
|
|
88
|
-
await stopCoverageInsideWorker(config.coverage, executor, { isolate: false });
|
|
36
|
+
const workerState = getWorkerState();
|
|
37
|
+
await setupCommonEnv(config);
|
|
38
|
+
Object.defineProperty(globalThis, "__vitest_index__", {
|
|
39
|
+
value: VitestIndex,
|
|
40
|
+
enumerable: false
|
|
41
|
+
});
|
|
42
|
+
if (workerState.environment.transformMode === "web") {
|
|
43
|
+
const _require = createRequire(import.meta.url);
|
|
44
|
+
_require.extensions[".css"] = resolveCss;
|
|
45
|
+
_require.extensions[".scss"] = resolveCss;
|
|
46
|
+
_require.extensions[".sass"] = resolveCss;
|
|
47
|
+
_require.extensions[".less"] = resolveCss;
|
|
48
|
+
KNOWN_ASSET_TYPES.forEach((type) => {
|
|
49
|
+
_require.extensions[`.${type}`] = resolveAsset;
|
|
50
|
+
});
|
|
51
|
+
process.env.SSR = "";
|
|
52
|
+
} else {
|
|
53
|
+
process.env.SSR = "1";
|
|
54
|
+
}
|
|
55
|
+
globalThis.__vitest_required__ = {
|
|
56
|
+
util,
|
|
57
|
+
timers,
|
|
58
|
+
timersPromises
|
|
59
|
+
};
|
|
60
|
+
installSourcemapsSupport({ getSourceMap: (source) => workerState.moduleCache.getSourceMap(source) });
|
|
61
|
+
await startCoverageInsideWorker(config.coverage, executor, { isolate: false });
|
|
62
|
+
if (config.chaiConfig) {
|
|
63
|
+
setupChaiConfig(config.chaiConfig);
|
|
64
|
+
}
|
|
65
|
+
const [runner, snapshotEnvironment] = await Promise.all([resolveTestRunner(config, executor), resolveSnapshotEnvironment(config, executor)]);
|
|
66
|
+
config.snapshotOptions.snapshotEnvironment = snapshotEnvironment;
|
|
67
|
+
workerState.onCancel.then((reason) => {
|
|
68
|
+
closeInspector(config);
|
|
69
|
+
runner.onCancel?.(reason);
|
|
70
|
+
});
|
|
71
|
+
workerState.durations.prepare = performance.now() - workerState.durations.prepare;
|
|
72
|
+
const { vi } = VitestIndex;
|
|
73
|
+
for (const file of files) {
|
|
74
|
+
workerState.filepath = file.filepath;
|
|
75
|
+
if (method === "run") {
|
|
76
|
+
await startTests([file], runner);
|
|
77
|
+
} else {
|
|
78
|
+
await collectTests([file], runner);
|
|
79
|
+
}
|
|
80
|
+
vi.resetConfig();
|
|
81
|
+
vi.restoreAllMocks();
|
|
82
|
+
}
|
|
83
|
+
await stopCoverageInsideWorker(config.coverage, executor, { isolate: false });
|
|
89
84
|
}
|
|
90
85
|
function resolveCss(mod) {
|
|
91
|
-
|
|
86
|
+
mod.exports = "";
|
|
92
87
|
}
|
|
93
88
|
function resolveAsset(mod, url) {
|
|
94
|
-
|
|
89
|
+
mod.exports = url;
|
|
95
90
|
}
|
|
96
91
|
|
|
97
92
|
export { run };
|
package/dist/workers/threads.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as runBaseTests } from '../chunks/base.
|
|
2
|
-
import { a as createThreadsRpcOptions } from '../chunks/utils.
|
|
1
|
+
import { r as runBaseTests } from '../chunks/base.bV8rwssx.js';
|
|
2
|
+
import { a as createThreadsRpcOptions } from '../chunks/utils.BfxieIyZ.js';
|
|
3
3
|
import 'vite-node/client';
|
|
4
|
-
import '../chunks/execute.
|
|
4
|
+
import '../chunks/execute.CwmnH2oH.js';
|
|
5
5
|
import 'node:fs';
|
|
6
6
|
import 'node:url';
|
|
7
7
|
import 'node:vm';
|
|
@@ -13,18 +13,18 @@ import 'node:path';
|
|
|
13
13
|
import '@vitest/mocker';
|
|
14
14
|
import 'node:module';
|
|
15
15
|
import '@vitest/utils';
|
|
16
|
-
import '../chunks/utils.
|
|
16
|
+
import '../chunks/utils.CtocqOoE.js';
|
|
17
17
|
|
|
18
18
|
class ThreadsBaseWorker {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
getRpcOptions(ctx) {
|
|
20
|
+
return createThreadsRpcOptions(ctx);
|
|
21
|
+
}
|
|
22
|
+
runTests(state) {
|
|
23
|
+
return runBaseTests("run", state);
|
|
24
|
+
}
|
|
25
|
+
collectTests(state) {
|
|
26
|
+
return runBaseTests("collect", state);
|
|
27
|
+
}
|
|
28
28
|
}
|
|
29
29
|
const worker = new ThreadsBaseWorker();
|
|
30
30
|
|
package/dist/workers/vmForks.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import v8 from 'node:v8';
|
|
2
|
-
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.
|
|
3
|
-
import { r as runVmTests } from '../chunks/vm.
|
|
2
|
+
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.BfxieIyZ.js';
|
|
3
|
+
import { r as runVmTests } from '../chunks/vm.Lp7mPCVW.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.D6t261w0.js';
|
|
11
11
|
import 'node:console';
|
|
12
12
|
import 'node:stream';
|
|
13
13
|
import 'tinyrainbow';
|
|
14
|
-
import '../chunks/date.
|
|
15
|
-
import '../chunks/utils.
|
|
16
|
-
import '../chunks/execute.
|
|
14
|
+
import '../chunks/date.CDOsz-HY.js';
|
|
15
|
+
import '../chunks/utils.CtocqOoE.js';
|
|
16
|
+
import '../chunks/execute.CwmnH2oH.js';
|
|
17
17
|
import 'node:fs';
|
|
18
18
|
import '@vitest/utils/error';
|
|
19
19
|
import 'vite-node/client';
|
|
@@ -23,24 +23,24 @@ import 'node:module';
|
|
|
23
23
|
import 'vite-node/constants';
|
|
24
24
|
|
|
25
25
|
class ForksVmWorker {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
26
|
+
getRpcOptions() {
|
|
27
|
+
return createForksRpcOptions(v8);
|
|
28
|
+
}
|
|
29
|
+
async executeTests(method, state) {
|
|
30
|
+
const exit = process.exit;
|
|
31
|
+
state.ctx.config = unwrapSerializableConfig(state.ctx.config);
|
|
32
|
+
try {
|
|
33
|
+
await runVmTests(method, state);
|
|
34
|
+
} finally {
|
|
35
|
+
process.exit = exit;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
runTests(state) {
|
|
39
|
+
return this.executeTests("run", state);
|
|
40
|
+
}
|
|
41
|
+
collectTests(state) {
|
|
42
|
+
return this.executeTests("collect", state);
|
|
43
|
+
}
|
|
44
44
|
}
|
|
45
45
|
const worker = new ForksVmWorker();
|
|
46
46
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { a as createThreadsRpcOptions } from '../chunks/utils.
|
|
2
|
-
import { r as runVmTests } from '../chunks/vm.
|
|
1
|
+
import { a as createThreadsRpcOptions } from '../chunks/utils.BfxieIyZ.js';
|
|
2
|
+
import { r as runVmTests } from '../chunks/vm.Lp7mPCVW.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.D6t261w0.js';
|
|
10
10
|
import 'node:console';
|
|
11
11
|
import 'node:stream';
|
|
12
12
|
import 'tinyrainbow';
|
|
13
|
-
import '../chunks/date.
|
|
14
|
-
import '../chunks/utils.
|
|
15
|
-
import '../chunks/execute.
|
|
13
|
+
import '../chunks/date.CDOsz-HY.js';
|
|
14
|
+
import '../chunks/utils.CtocqOoE.js';
|
|
15
|
+
import '../chunks/execute.CwmnH2oH.js';
|
|
16
16
|
import 'node:fs';
|
|
17
17
|
import '@vitest/utils/error';
|
|
18
18
|
import 'vite-node/client';
|
|
@@ -22,15 +22,15 @@ import 'node:module';
|
|
|
22
22
|
import 'vite-node/constants';
|
|
23
23
|
|
|
24
24
|
class ThreadsVmWorker {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
getRpcOptions(ctx) {
|
|
26
|
+
return createThreadsRpcOptions(ctx);
|
|
27
|
+
}
|
|
28
|
+
runTests(state) {
|
|
29
|
+
return runVmTests("run", state);
|
|
30
|
+
}
|
|
31
|
+
collectTests(state) {
|
|
32
|
+
return runVmTests("collect", state);
|
|
33
|
+
}
|
|
34
34
|
}
|
|
35
35
|
const worker = new ThreadsVmWorker();
|
|
36
36
|
|
package/dist/workers.d.ts
CHANGED
|
@@ -35,4 +35,5 @@ declare function unwrapSerializableConfig(config: SerializedConfig): SerializedC
|
|
|
35
35
|
|
|
36
36
|
declare function runVmTests(method: "run" | "collect", state: WorkerGlobalState): Promise<void>;
|
|
37
37
|
|
|
38
|
-
export {
|
|
38
|
+
export { collect as collectVitestWorkerTests, createForksRpcOptions, createThreadsRpcOptions, provideWorkerState, runBaseTests, run as runVitestWorker, runVmTests, unwrapSerializableConfig };
|
|
39
|
+
export type { VitestWorker, WorkerRpcOptions };
|