vitest 1.1.3 → 1.2.1
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 +1 -1
- package/dist/browser.js +5 -31
- package/dist/chunks/{api-setup.mFKdEKxa.js → api-setup.omeaEsoT.js} +60 -6
- package/dist/chunks/{integrations-globals.tnKXwyh5.js → integrations-globals.9QpVy4UR.js} +9 -8
- package/dist/chunks/{runtime-console.hf2msWA9.js → runtime-console.Iloo9fIt.js} +2 -2
- package/dist/{entry.js → chunks/runtime-runBaseTests.S8ZSFig3.js} +20 -18
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +15 -15
- package/dist/config.cjs +12 -1
- package/dist/config.d.ts +1 -71
- package/dist/config.js +12 -2
- package/dist/coverage.d.ts +1 -1
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +8 -6
- package/dist/execute.js +4 -7
- package/dist/index.d.ts +4 -4
- package/dist/index.js +8 -7
- package/dist/node.d.ts +3 -3
- package/dist/node.js +13 -13
- package/dist/{reporters-qc5Smpt5.d.ts → reporters-rzC174PQ.d.ts} +188 -29
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +5 -5
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +7 -5
- package/dist/{suite-WwpgKT7k.d.ts → suite-MFRDkZcV.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +3 -3
- package/dist/vendor/base.4sEqnqgY.js +38 -0
- package/dist/vendor/{base._79unx2z.js → base.QYERqzkH.js} +10 -1
- package/dist/vendor/{benchmark.WVm6DARl.js → benchmark.IlKmJkUU.js} +1 -1
- package/dist/vendor/{constants.WSvnD_fn.js → constants.i1PoEnhr.js} +9 -1
- package/dist/vendor/{coverage.v6aD8iAh.js → coverage.E7sG1b3r.js} +1 -1
- package/dist/vendor/{environments.QJtma9XQ.js → environments.sU0TD7wX.js} +19 -7
- package/dist/vendor/execute.edwByI27.js +589 -0
- package/dist/vendor/{global.L7JRz1qU.js → global.CkGT_TMy.js} +10 -1
- package/dist/vendor/{index.h0j9y5vy.js → index.kwCLJK4i.js} +5 -5
- package/dist/vendor/{index.XU72Rmy8.js → index.rJjbcrrp.js} +1 -1
- package/dist/vendor/{index.IhksUGLR.js → index.vs_-lzuF.js} +6 -6
- package/dist/vendor/{node.wTZytysZ.js → node.p6h5JSuL.js} +694 -286
- package/dist/vendor/{reporters.7Y4WN6gc.js → reporters.cA9x-5v-.js} +8 -5
- package/dist/vendor/{rpc.Bl-ysZIr.js → rpc.w4v8oCkK.js} +23 -2
- package/dist/vendor/{run-once.X3E7xx3F.js → run-once.Olz_Zkd8.js} +2 -2
- package/dist/vendor/setup-common.4GIL70qB.js +29 -0
- package/dist/vendor/utils.GbToHGHI.js +41 -0
- package/dist/vendor/{vi.DTC--YO5.js → vi.Bw2UL9c9.js} +21 -8
- package/dist/vendor/vm.9N6CwTZh.js +696 -0
- package/dist/worker.js +109 -82
- package/dist/workers/forks.js +33 -0
- package/dist/{entry-vm.js → workers/runVmTests.js} +20 -16
- package/dist/workers/threads.js +26 -0
- package/dist/workers/vmForks.js +43 -0
- package/dist/workers/vmThreads.js +36 -0
- package/dist/workers.d.ts +36 -0
- package/dist/workers.js +30 -0
- package/package.json +12 -8
- package/workers.d.ts +1 -0
- package/dist/child.js +0 -125
- package/dist/vendor/execute.cedv4NLQ.js +0 -1235
- package/dist/vendor/inspector.lFAeuaAt.js +0 -26
- package/dist/vendor/loader.L9CYwKn1.js +0 -39
- package/dist/vm.js +0 -126
- /package/dist/{paths.js → path.js} +0 -0
package/dist/worker.js
CHANGED
|
@@ -1,100 +1,127 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as createBirpc } from './vendor/index.cAUulNDf.js';
|
|
1
|
+
import { pathToFileURL } from 'node:url';
|
|
3
2
|
import { workerId } from 'tinypool';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { s as
|
|
8
|
-
import {
|
|
9
|
-
import '
|
|
10
|
-
import 'vite-node/client';
|
|
11
|
-
import './vendor/environments.QJtma9XQ.js';
|
|
3
|
+
import { ViteNodeRunner, ModuleCacheMap } from 'vite-node/client';
|
|
4
|
+
import { resolve, normalize } from 'pathe';
|
|
5
|
+
import { e as environments } from './vendor/environments.sU0TD7wX.js';
|
|
6
|
+
import { i as isChildProcess, s as setProcessTitle } from './vendor/base.QYERqzkH.js';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import { c as createRuntimeRpc, a as rpcDone } from './vendor/rpc.w4v8oCkK.js';
|
|
12
9
|
import 'node:console';
|
|
13
|
-
import 'node:url';
|
|
14
|
-
import 'node:vm';
|
|
15
|
-
import 'vite-node/utils';
|
|
16
|
-
import '@vitest/utils/error';
|
|
17
|
-
import './paths.js';
|
|
18
|
-
import 'node:fs';
|
|
19
10
|
import '@vitest/utils';
|
|
20
|
-
import './vendor/
|
|
21
|
-
import '
|
|
22
|
-
import 'node:module';
|
|
23
|
-
import 'vite-node/constants';
|
|
11
|
+
import './vendor/index.cAUulNDf.js';
|
|
12
|
+
import './vendor/global.CkGT_TMy.js';
|
|
24
13
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
eventNames: ["onUserConsoleLog", "onFinished", "onCollected", "onWorkerExit", "onCancel"],
|
|
45
|
-
post(v) {
|
|
46
|
-
port.postMessage(v);
|
|
47
|
-
},
|
|
48
|
-
on(fn) {
|
|
49
|
-
port.addListener("message", fn);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
));
|
|
53
|
-
const environment = await loadEnvironment(ctx.environment.name, {
|
|
14
|
+
function isBuiltinEnvironment(env) {
|
|
15
|
+
return env in environments;
|
|
16
|
+
}
|
|
17
|
+
const _loaders = /* @__PURE__ */ new Map();
|
|
18
|
+
async function createEnvironmentLoader(options) {
|
|
19
|
+
if (!_loaders.has(options.root)) {
|
|
20
|
+
const loader = new ViteNodeRunner(options);
|
|
21
|
+
await loader.executeId("/@vite/env");
|
|
22
|
+
_loaders.set(options.root, loader);
|
|
23
|
+
}
|
|
24
|
+
return _loaders.get(options.root);
|
|
25
|
+
}
|
|
26
|
+
async function loadEnvironment(ctx, rpc) {
|
|
27
|
+
var _a;
|
|
28
|
+
const name = ctx.environment.name;
|
|
29
|
+
if (isBuiltinEnvironment(name))
|
|
30
|
+
return environments[name];
|
|
31
|
+
const loader = await createEnvironmentLoader({
|
|
54
32
|
root: ctx.config.root,
|
|
55
33
|
fetchModule: (id) => rpc.fetch(id, "ssr"),
|
|
56
34
|
resolveId: (id, importer) => rpc.resolveId(id, importer, "ssr")
|
|
57
35
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
onCancel,
|
|
66
|
-
environment,
|
|
67
|
-
durations: {
|
|
68
|
-
environment: 0,
|
|
69
|
-
prepare: performance.now()
|
|
70
|
-
},
|
|
71
|
-
rpc,
|
|
72
|
-
providedContext
|
|
73
|
-
};
|
|
74
|
-
Object.defineProperty(globalThis, "__vitest_worker__", {
|
|
75
|
-
value: state,
|
|
76
|
-
configurable: true,
|
|
77
|
-
writable: true,
|
|
78
|
-
enumerable: false
|
|
79
|
-
});
|
|
80
|
-
if (ctx.invalidates) {
|
|
81
|
-
ctx.invalidates.forEach((fsPath) => {
|
|
82
|
-
moduleCache.delete(fsPath);
|
|
83
|
-
moduleCache.delete(`mock:${fsPath}`);
|
|
84
|
-
});
|
|
36
|
+
const root = loader.root;
|
|
37
|
+
const packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : ((_a = await rpc.resolveId(`vitest-environment-${name}`, void 0, "ssr")) == null ? void 0 : _a.id) ?? resolve(root, name);
|
|
38
|
+
const pkg = await loader.executeId(normalize(packageId));
|
|
39
|
+
if (!pkg || !pkg.default || typeof pkg.default !== "object") {
|
|
40
|
+
throw new TypeError(
|
|
41
|
+
`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`
|
|
42
|
+
);
|
|
85
43
|
}
|
|
86
|
-
|
|
87
|
-
|
|
44
|
+
const environment = pkg.default;
|
|
45
|
+
if (environment.transformMode !== "web" && environment.transformMode !== "ssr") {
|
|
46
|
+
throw new TypeError(
|
|
47
|
+
`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "transformMode" method equal to "ssr" or "web".`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return environment;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const __require = createRequire(import.meta.url);
|
|
54
|
+
let inspector;
|
|
55
|
+
function setupInspect(config) {
|
|
56
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
57
|
+
const isEnabled = config.inspect || config.inspectBrk;
|
|
58
|
+
if (isEnabled) {
|
|
59
|
+
inspector = __require("node:inspector");
|
|
60
|
+
const isOpen = inspector.url() !== void 0;
|
|
61
|
+
if (!isOpen) {
|
|
62
|
+
inspector.open();
|
|
63
|
+
if (config.inspectBrk)
|
|
64
|
+
inspector.waitForDebugger();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const isIsolatedSingleThread = config.pool === "threads" && ((_b = (_a = config.poolOptions) == null ? void 0 : _a.threads) == null ? void 0 : _b.isolate) === false && ((_d = (_c = config.poolOptions) == null ? void 0 : _c.threads) == null ? void 0 : _d.singleThread);
|
|
68
|
+
const isIsolatedSingleFork = config.pool === "forks" && ((_f = (_e = config.poolOptions) == null ? void 0 : _e.forks) == null ? void 0 : _f.isolate) === false && ((_h = (_g = config.poolOptions) == null ? void 0 : _g.forks) == null ? void 0 : _h.singleFork);
|
|
69
|
+
const keepOpen = config.watch && (isIsolatedSingleFork || isIsolatedSingleThread);
|
|
70
|
+
return function cleanup() {
|
|
71
|
+
if (isEnabled && !keepOpen && inspector)
|
|
72
|
+
inspector.close();
|
|
73
|
+
};
|
|
88
74
|
}
|
|
75
|
+
|
|
76
|
+
if (isChildProcess())
|
|
77
|
+
setProcessTitle(`vitest ${workerId}`);
|
|
89
78
|
async function run(ctx) {
|
|
79
|
+
const prepareStart = performance.now();
|
|
90
80
|
const inspectorCleanup = setupInspect(ctx.config);
|
|
81
|
+
process.env.VITEST_WORKER_ID = String(ctx.workerId);
|
|
82
|
+
process.env.VITEST_POOL_ID = String(workerId);
|
|
83
|
+
let state = null;
|
|
91
84
|
try {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
await
|
|
85
|
+
if (ctx.worker[0] === ".")
|
|
86
|
+
throw new Error(`Path to the test runner cannot be relative, received "${ctx.worker}"`);
|
|
87
|
+
const file = ctx.worker.startsWith("file:") ? ctx.worker : pathToFileURL(ctx.worker).toString();
|
|
88
|
+
const testRunnerModule = await import(file);
|
|
89
|
+
if (!testRunnerModule.default || typeof testRunnerModule.default !== "object")
|
|
90
|
+
throw new TypeError(`Test worker object should be exposed as a default export. Received "${typeof testRunnerModule.default}"`);
|
|
91
|
+
const worker = testRunnerModule.default;
|
|
92
|
+
if (!worker.getRpcOptions || typeof worker.getRpcOptions !== "function")
|
|
93
|
+
throw new TypeError(`Test worker should expose "getRpcOptions" method. Received "${typeof worker.getRpcOptions}".`);
|
|
94
|
+
const { rpc, onCancel } = createRuntimeRpc(worker.getRpcOptions(ctx));
|
|
95
|
+
const beforeEnvironmentTime = performance.now();
|
|
96
|
+
const environment = await loadEnvironment(ctx, rpc);
|
|
97
|
+
if (ctx.environment.transformMode)
|
|
98
|
+
environment.transformMode = ctx.environment.transformMode;
|
|
99
|
+
state = {
|
|
100
|
+
ctx,
|
|
101
|
+
// here we create a new one, workers can reassign this if they need to keep it non-isolated
|
|
102
|
+
moduleCache: new ModuleCacheMap(),
|
|
103
|
+
mockMap: /* @__PURE__ */ new Map(),
|
|
104
|
+
config: ctx.config,
|
|
105
|
+
onCancel,
|
|
106
|
+
environment,
|
|
107
|
+
durations: {
|
|
108
|
+
environment: beforeEnvironmentTime,
|
|
109
|
+
prepare: prepareStart
|
|
110
|
+
},
|
|
111
|
+
rpc,
|
|
112
|
+
providedContext: ctx.providedContext
|
|
113
|
+
};
|
|
114
|
+
if (!worker.runTests || typeof worker.runTests !== "function")
|
|
115
|
+
throw new TypeError(`Test worker should expose "runTests" method. Received "${typeof worker.runTests}".`);
|
|
116
|
+
await worker.runTests(state);
|
|
96
117
|
} finally {
|
|
118
|
+
await rpcDone().catch(() => {
|
|
119
|
+
});
|
|
97
120
|
inspectorCleanup();
|
|
121
|
+
if (state) {
|
|
122
|
+
state.environment = null;
|
|
123
|
+
state = null;
|
|
124
|
+
}
|
|
98
125
|
}
|
|
99
126
|
}
|
|
100
127
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import v8 from 'node:v8';
|
|
2
|
+
import { c as createForksRpcOptions, u as unwrapForksConfig } from '../vendor/utils.GbToHGHI.js';
|
|
3
|
+
import { r as runBaseTests } from '../vendor/base.4sEqnqgY.js';
|
|
4
|
+
import '@vitest/utils';
|
|
5
|
+
import 'vite-node/client';
|
|
6
|
+
import '../vendor/global.CkGT_TMy.js';
|
|
7
|
+
import '../vendor/execute.edwByI27.js';
|
|
8
|
+
import 'node:vm';
|
|
9
|
+
import 'node:url';
|
|
10
|
+
import 'vite-node/utils';
|
|
11
|
+
import 'pathe';
|
|
12
|
+
import '@vitest/utils/error';
|
|
13
|
+
import '../path.js';
|
|
14
|
+
import 'node:fs';
|
|
15
|
+
import '../vendor/base.QYERqzkH.js';
|
|
16
|
+
|
|
17
|
+
class ForksBaseWorker {
|
|
18
|
+
getRpcOptions() {
|
|
19
|
+
return createForksRpcOptions(v8);
|
|
20
|
+
}
|
|
21
|
+
async runTests(state) {
|
|
22
|
+
const exit = process.exit;
|
|
23
|
+
state.ctx.config = unwrapForksConfig(state.ctx.config);
|
|
24
|
+
try {
|
|
25
|
+
await runBaseTests(state);
|
|
26
|
+
} finally {
|
|
27
|
+
process.exit = exit;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
var forks = new ForksBaseWorker();
|
|
32
|
+
|
|
33
|
+
export { forks as default };
|
|
@@ -5,37 +5,39 @@ import timers from 'node:timers';
|
|
|
5
5
|
import { performance } from 'node:perf_hooks';
|
|
6
6
|
import { startTests } from '@vitest/runner';
|
|
7
7
|
import { setupColors, createColors } from '@vitest/utils';
|
|
8
|
-
import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '
|
|
9
|
-
import {
|
|
10
|
-
import { g as getWorkerState } from '
|
|
11
|
-
import {
|
|
12
|
-
import { setupCommonEnv } from '
|
|
8
|
+
import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '../vendor/index.kwCLJK4i.js';
|
|
9
|
+
import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from '../vendor/coverage.E7sG1b3r.js';
|
|
10
|
+
import { g as getWorkerState } from '../vendor/global.CkGT_TMy.js';
|
|
11
|
+
import { V as VitestIndex } from '../vendor/index.vs_-lzuF.js';
|
|
12
|
+
import { s as setupCommonEnv } from '../vendor/setup-common.4GIL70qB.js';
|
|
13
13
|
import 'chai';
|
|
14
14
|
import '@vitest/snapshot/environment';
|
|
15
15
|
import 'pathe';
|
|
16
|
-
import '
|
|
16
|
+
import '../path.js';
|
|
17
17
|
import 'node:url';
|
|
18
|
-
import '
|
|
19
|
-
import '
|
|
18
|
+
import '../vendor/rpc.w4v8oCkK.js';
|
|
19
|
+
import '../vendor/index.cAUulNDf.js';
|
|
20
|
+
import '../vendor/benchmark.IlKmJkUU.js';
|
|
20
21
|
import '@vitest/runner/utils';
|
|
21
|
-
import '
|
|
22
|
+
import '../vendor/index.rJjbcrrp.js';
|
|
22
23
|
import 'std-env';
|
|
23
|
-
import '
|
|
24
|
-
import '
|
|
25
|
-
import '
|
|
24
|
+
import '../vendor/run-once.Olz_Zkd8.js';
|
|
25
|
+
import '../vendor/vi.Bw2UL9c9.js';
|
|
26
|
+
import '../vendor/_commonjsHelpers.jjO7Zipk.js';
|
|
26
27
|
import '@vitest/expect';
|
|
27
28
|
import '@vitest/snapshot';
|
|
28
29
|
import '@vitest/utils/error';
|
|
29
|
-
import '
|
|
30
|
+
import '../vendor/tasks.IknbGB2n.js';
|
|
30
31
|
import '@vitest/utils/source-map';
|
|
31
|
-
import '
|
|
32
|
+
import '../vendor/base.QYERqzkH.js';
|
|
33
|
+
import '../vendor/date.Ns1pGd_X.js';
|
|
32
34
|
import '@vitest/spy';
|
|
33
35
|
|
|
34
36
|
async function run(files, config, executor) {
|
|
35
37
|
const workerState = getWorkerState();
|
|
36
38
|
await setupCommonEnv(config);
|
|
37
39
|
Object.defineProperty(globalThis, "__vitest_index__", {
|
|
38
|
-
value:
|
|
40
|
+
value: VitestIndex,
|
|
39
41
|
enumerable: false
|
|
40
42
|
});
|
|
41
43
|
config.snapshotOptions.snapshotEnvironment = new VitestSnapshotEnvironment(workerState.rpc);
|
|
@@ -56,10 +58,12 @@ async function run(files, config, executor) {
|
|
|
56
58
|
setupChaiConfig(config.chaiConfig);
|
|
57
59
|
const runner = await resolveTestRunner(config, executor);
|
|
58
60
|
workerState.durations.prepare = performance.now() - workerState.durations.prepare;
|
|
61
|
+
const { vi } = VitestIndex;
|
|
59
62
|
for (const file of files) {
|
|
60
63
|
workerState.filepath = file;
|
|
61
64
|
await startTests([file], runner);
|
|
62
|
-
|
|
65
|
+
vi.resetConfig();
|
|
66
|
+
vi.restoreAllMocks();
|
|
63
67
|
}
|
|
64
68
|
await stopCoverageInsideWorker(config.coverage, executor);
|
|
65
69
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { r as runBaseTests } from '../vendor/base.4sEqnqgY.js';
|
|
2
|
+
import { a as createThreadsRpcOptions } from '../vendor/utils.GbToHGHI.js';
|
|
3
|
+
import 'vite-node/client';
|
|
4
|
+
import '../vendor/global.CkGT_TMy.js';
|
|
5
|
+
import '../vendor/execute.edwByI27.js';
|
|
6
|
+
import 'node:vm';
|
|
7
|
+
import 'node:url';
|
|
8
|
+
import 'vite-node/utils';
|
|
9
|
+
import 'pathe';
|
|
10
|
+
import '@vitest/utils/error';
|
|
11
|
+
import '../path.js';
|
|
12
|
+
import 'node:fs';
|
|
13
|
+
import '@vitest/utils';
|
|
14
|
+
import '../vendor/base.QYERqzkH.js';
|
|
15
|
+
|
|
16
|
+
class ThreadsBaseWorker {
|
|
17
|
+
getRpcOptions(ctx) {
|
|
18
|
+
return createThreadsRpcOptions(ctx);
|
|
19
|
+
}
|
|
20
|
+
runTests(state) {
|
|
21
|
+
return runBaseTests(state);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
var threads = new ThreadsBaseWorker();
|
|
25
|
+
|
|
26
|
+
export { threads as default };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import v8 from 'node:v8';
|
|
2
|
+
import { c as createForksRpcOptions, u as unwrapForksConfig } from '../vendor/utils.GbToHGHI.js';
|
|
3
|
+
import { r as runVmTests } from '../vendor/vm.9N6CwTZh.js';
|
|
4
|
+
import '@vitest/utils';
|
|
5
|
+
import 'node:vm';
|
|
6
|
+
import 'node:url';
|
|
7
|
+
import 'pathe';
|
|
8
|
+
import '../chunks/runtime-console.Iloo9fIt.js';
|
|
9
|
+
import 'node:stream';
|
|
10
|
+
import 'node:console';
|
|
11
|
+
import 'node:path';
|
|
12
|
+
import '../vendor/date.Ns1pGd_X.js';
|
|
13
|
+
import '../vendor/execute.edwByI27.js';
|
|
14
|
+
import 'vite-node/client';
|
|
15
|
+
import 'vite-node/utils';
|
|
16
|
+
import '@vitest/utils/error';
|
|
17
|
+
import '../path.js';
|
|
18
|
+
import 'node:fs';
|
|
19
|
+
import '../vendor/base.QYERqzkH.js';
|
|
20
|
+
import 'node:module';
|
|
21
|
+
import 'vite-node/constants';
|
|
22
|
+
import '../vendor/index.rJjbcrrp.js';
|
|
23
|
+
import 'std-env';
|
|
24
|
+
import '@vitest/runner/utils';
|
|
25
|
+
import '../vendor/global.CkGT_TMy.js';
|
|
26
|
+
|
|
27
|
+
class ForksVmWorker {
|
|
28
|
+
getRpcOptions() {
|
|
29
|
+
return createForksRpcOptions(v8);
|
|
30
|
+
}
|
|
31
|
+
async runTests(state) {
|
|
32
|
+
const exit = process.exit;
|
|
33
|
+
state.ctx.config = unwrapForksConfig(state.ctx.config);
|
|
34
|
+
try {
|
|
35
|
+
await runVmTests(state);
|
|
36
|
+
} finally {
|
|
37
|
+
process.exit = exit;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
var vmForks = new ForksVmWorker();
|
|
42
|
+
|
|
43
|
+
export { vmForks as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { a as createThreadsRpcOptions } from '../vendor/utils.GbToHGHI.js';
|
|
2
|
+
import { r as runVmTests } from '../vendor/vm.9N6CwTZh.js';
|
|
3
|
+
import '@vitest/utils';
|
|
4
|
+
import 'node:vm';
|
|
5
|
+
import 'node:url';
|
|
6
|
+
import 'pathe';
|
|
7
|
+
import '../chunks/runtime-console.Iloo9fIt.js';
|
|
8
|
+
import 'node:stream';
|
|
9
|
+
import 'node:console';
|
|
10
|
+
import 'node:path';
|
|
11
|
+
import '../vendor/date.Ns1pGd_X.js';
|
|
12
|
+
import '../vendor/execute.edwByI27.js';
|
|
13
|
+
import 'vite-node/client';
|
|
14
|
+
import 'vite-node/utils';
|
|
15
|
+
import '@vitest/utils/error';
|
|
16
|
+
import '../path.js';
|
|
17
|
+
import 'node:fs';
|
|
18
|
+
import '../vendor/base.QYERqzkH.js';
|
|
19
|
+
import 'node:module';
|
|
20
|
+
import 'vite-node/constants';
|
|
21
|
+
import '../vendor/index.rJjbcrrp.js';
|
|
22
|
+
import 'std-env';
|
|
23
|
+
import '@vitest/runner/utils';
|
|
24
|
+
import '../vendor/global.CkGT_TMy.js';
|
|
25
|
+
|
|
26
|
+
class ThreadsVmWorker {
|
|
27
|
+
getRpcOptions(ctx) {
|
|
28
|
+
return createThreadsRpcOptions(ctx);
|
|
29
|
+
}
|
|
30
|
+
runTests(state) {
|
|
31
|
+
return runVmTests(state);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
var vmThreads = new ThreadsVmWorker();
|
|
35
|
+
|
|
36
|
+
export { vmThreads as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as v8 from 'v8';
|
|
2
|
+
import { n as BirpcOptions, f as RuntimeRPC, o as ContextRPC, p as WorkerGlobalState, q as WorkerContext, R as ResolvedConfig } from './reporters-rzC174PQ.js';
|
|
3
|
+
import { Awaitable } from '@vitest/utils';
|
|
4
|
+
import 'vite';
|
|
5
|
+
import '@vitest/runner';
|
|
6
|
+
import 'vite-node';
|
|
7
|
+
import '@vitest/snapshot';
|
|
8
|
+
import '@vitest/expect';
|
|
9
|
+
import '@vitest/runner/utils';
|
|
10
|
+
import 'tinybench';
|
|
11
|
+
import 'vite-node/client';
|
|
12
|
+
import '@vitest/snapshot/manager';
|
|
13
|
+
import 'vite-node/server';
|
|
14
|
+
import 'node:worker_threads';
|
|
15
|
+
import 'node:fs';
|
|
16
|
+
import 'chai';
|
|
17
|
+
|
|
18
|
+
type WorkerRpcOptions = Pick<BirpcOptions<RuntimeRPC>, 'on' | 'post' | 'serialize' | 'deserialize'>;
|
|
19
|
+
interface VitestWorker {
|
|
20
|
+
getRpcOptions(ctx: ContextRPC): WorkerRpcOptions;
|
|
21
|
+
runTests(state: WorkerGlobalState): Awaitable<unknown>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare function createThreadsRpcOptions({ port }: WorkerContext): WorkerRpcOptions;
|
|
25
|
+
declare function createForksRpcOptions(nodeV8: typeof v8): WorkerRpcOptions;
|
|
26
|
+
declare function unwrapForksConfig(config: ResolvedConfig): ResolvedConfig;
|
|
27
|
+
|
|
28
|
+
declare function provideWorkerState(context: any, state: WorkerGlobalState): WorkerGlobalState;
|
|
29
|
+
|
|
30
|
+
declare function run(ctx: ContextRPC): Promise<void>;
|
|
31
|
+
|
|
32
|
+
declare function runVmTests(state: WorkerGlobalState): Promise<void>;
|
|
33
|
+
|
|
34
|
+
declare function runBaseTests(state: WorkerGlobalState): Promise<void>;
|
|
35
|
+
|
|
36
|
+
export { type VitestWorker, type WorkerRpcOptions, createForksRpcOptions, createThreadsRpcOptions, provideWorkerState, runBaseTests, run as runVitestWorker, runVmTests, unwrapForksConfig };
|
package/dist/workers.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapForksConfig } from './vendor/utils.GbToHGHI.js';
|
|
2
|
+
export { p as provideWorkerState } from './vendor/global.CkGT_TMy.js';
|
|
3
|
+
export { run as runVitestWorker } from './worker.js';
|
|
4
|
+
export { r as runVmTests } from './vendor/vm.9N6CwTZh.js';
|
|
5
|
+
export { r as runBaseTests } from './vendor/base.4sEqnqgY.js';
|
|
6
|
+
import '@vitest/utils';
|
|
7
|
+
import 'node:url';
|
|
8
|
+
import 'tinypool';
|
|
9
|
+
import 'vite-node/client';
|
|
10
|
+
import 'pathe';
|
|
11
|
+
import './vendor/environments.sU0TD7wX.js';
|
|
12
|
+
import 'node:console';
|
|
13
|
+
import './vendor/base.QYERqzkH.js';
|
|
14
|
+
import 'node:module';
|
|
15
|
+
import './vendor/rpc.w4v8oCkK.js';
|
|
16
|
+
import './vendor/index.cAUulNDf.js';
|
|
17
|
+
import 'node:vm';
|
|
18
|
+
import './chunks/runtime-console.Iloo9fIt.js';
|
|
19
|
+
import 'node:stream';
|
|
20
|
+
import 'node:path';
|
|
21
|
+
import './vendor/date.Ns1pGd_X.js';
|
|
22
|
+
import './vendor/execute.edwByI27.js';
|
|
23
|
+
import 'vite-node/utils';
|
|
24
|
+
import '@vitest/utils/error';
|
|
25
|
+
import './path.js';
|
|
26
|
+
import 'node:fs';
|
|
27
|
+
import 'vite-node/constants';
|
|
28
|
+
import './vendor/index.rJjbcrrp.js';
|
|
29
|
+
import 'std-env';
|
|
30
|
+
import '@vitest/runner/utils';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1
|
|
4
|
+
"version": "1.2.1",
|
|
5
5
|
"description": "Next generation testing framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -52,6 +52,10 @@
|
|
|
52
52
|
"types": "./dist/execute.d.ts",
|
|
53
53
|
"default": "./dist/execute.js"
|
|
54
54
|
},
|
|
55
|
+
"./workers": {
|
|
56
|
+
"types": "./dist/workers.d.ts",
|
|
57
|
+
"import": "./dist/workers.js"
|
|
58
|
+
},
|
|
55
59
|
"./browser": {
|
|
56
60
|
"types": "./dist/browser.d.ts",
|
|
57
61
|
"default": "./dist/browser.js"
|
|
@@ -132,7 +136,7 @@
|
|
|
132
136
|
}
|
|
133
137
|
},
|
|
134
138
|
"dependencies": {
|
|
135
|
-
"acorn-walk": "^8.3.
|
|
139
|
+
"acorn-walk": "^8.3.2",
|
|
136
140
|
"cac": "^6.7.14",
|
|
137
141
|
"chai": "^4.3.10",
|
|
138
142
|
"debug": "^4.3.4",
|
|
@@ -147,12 +151,12 @@
|
|
|
147
151
|
"tinypool": "^0.8.1",
|
|
148
152
|
"vite": "^5.0.0",
|
|
149
153
|
"why-is-node-running": "^2.2.2",
|
|
150
|
-
"@vitest/
|
|
151
|
-
"@vitest/
|
|
152
|
-
"@vitest/
|
|
153
|
-
"@vitest/
|
|
154
|
-
"
|
|
155
|
-
"
|
|
154
|
+
"@vitest/expect": "1.2.1",
|
|
155
|
+
"@vitest/snapshot": "1.2.1",
|
|
156
|
+
"@vitest/runner": "1.2.1",
|
|
157
|
+
"@vitest/spy": "1.2.1",
|
|
158
|
+
"vite-node": "1.2.1",
|
|
159
|
+
"@vitest/utils": "1.2.1"
|
|
156
160
|
},
|
|
157
161
|
"devDependencies": {
|
|
158
162
|
"@ampproject/remapping": "^2.2.1",
|
package/workers.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/workers.js'
|
package/dist/child.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { performance } from 'node:perf_hooks';
|
|
2
|
-
import v8 from 'node:v8';
|
|
3
|
-
import { c as createBirpc } from './vendor/index.cAUulNDf.js';
|
|
4
|
-
import { parseRegexp } from '@vitest/utils';
|
|
5
|
-
import { workerId } from 'tinypool';
|
|
6
|
-
import { l as loadEnvironment } from './vendor/loader.L9CYwKn1.js';
|
|
7
|
-
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor/execute.cedv4NLQ.js';
|
|
8
|
-
import { r as rpcDone, c as createSafeRpc } from './vendor/rpc.Bl-ysZIr.js';
|
|
9
|
-
import { s as setupInspect } from './vendor/inspector.lFAeuaAt.js';
|
|
10
|
-
import 'pathe';
|
|
11
|
-
import 'vite-node/client';
|
|
12
|
-
import './vendor/environments.QJtma9XQ.js';
|
|
13
|
-
import 'node:console';
|
|
14
|
-
import 'node:url';
|
|
15
|
-
import 'node:vm';
|
|
16
|
-
import 'vite-node/utils';
|
|
17
|
-
import '@vitest/utils/error';
|
|
18
|
-
import './paths.js';
|
|
19
|
-
import 'node:fs';
|
|
20
|
-
import './vendor/base._79unx2z.js';
|
|
21
|
-
import 'node:path';
|
|
22
|
-
import 'node:module';
|
|
23
|
-
import 'vite-node/constants';
|
|
24
|
-
import './vendor/global.L7JRz1qU.js';
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
process.title = `node (vitest ${workerId})`;
|
|
28
|
-
} catch {
|
|
29
|
-
}
|
|
30
|
-
async function init(ctx) {
|
|
31
|
-
const { config, workerId: workerId$1, providedContext } = ctx;
|
|
32
|
-
process.env.VITEST_WORKER_ID = String(workerId$1);
|
|
33
|
-
process.env.VITEST_POOL_ID = String(workerId);
|
|
34
|
-
let setCancel = (_reason) => {
|
|
35
|
-
};
|
|
36
|
-
const onCancel = new Promise((resolve) => {
|
|
37
|
-
setCancel = resolve;
|
|
38
|
-
});
|
|
39
|
-
const rpc = createSafeRpc(createBirpc(
|
|
40
|
-
{
|
|
41
|
-
onCancel: setCancel
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
eventNames: ["onUserConsoleLog", "onFinished", "onCollected", "onWorkerExit", "onCancel"],
|
|
45
|
-
serialize: v8.serialize,
|
|
46
|
-
deserialize: (v) => v8.deserialize(Buffer.from(v)),
|
|
47
|
-
post(v) {
|
|
48
|
-
var _a;
|
|
49
|
-
(_a = process.send) == null ? void 0 : _a.call(process, v);
|
|
50
|
-
},
|
|
51
|
-
on(fn) {
|
|
52
|
-
process.on("message", (message, ...extras) => {
|
|
53
|
-
if (message == null ? void 0 : message.__tinypool_worker_message__)
|
|
54
|
-
return;
|
|
55
|
-
return fn(message, ...extras);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
));
|
|
60
|
-
const environment = await loadEnvironment(ctx.environment.name, {
|
|
61
|
-
root: ctx.config.root,
|
|
62
|
-
fetchModule: (id) => rpc.fetch(id, "ssr"),
|
|
63
|
-
resolveId: (id, importer) => rpc.resolveId(id, importer, "ssr")
|
|
64
|
-
});
|
|
65
|
-
if (ctx.environment.transformMode)
|
|
66
|
-
environment.transformMode = ctx.environment.transformMode;
|
|
67
|
-
const state = {
|
|
68
|
-
ctx,
|
|
69
|
-
moduleCache,
|
|
70
|
-
config,
|
|
71
|
-
mockMap,
|
|
72
|
-
onCancel,
|
|
73
|
-
environment,
|
|
74
|
-
durations: {
|
|
75
|
-
environment: 0,
|
|
76
|
-
prepare: performance.now()
|
|
77
|
-
},
|
|
78
|
-
rpc,
|
|
79
|
-
providedContext,
|
|
80
|
-
isChildProcess: true
|
|
81
|
-
};
|
|
82
|
-
Object.defineProperty(globalThis, "__vitest_worker__", {
|
|
83
|
-
value: state,
|
|
84
|
-
configurable: true,
|
|
85
|
-
writable: true,
|
|
86
|
-
enumerable: false
|
|
87
|
-
});
|
|
88
|
-
if (ctx.invalidates) {
|
|
89
|
-
ctx.invalidates.forEach((fsPath) => {
|
|
90
|
-
moduleCache.delete(fsPath);
|
|
91
|
-
moduleCache.delete(`mock:${fsPath}`);
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
ctx.files.forEach((i) => moduleCache.delete(i));
|
|
95
|
-
return state;
|
|
96
|
-
}
|
|
97
|
-
function parsePossibleRegexp(str) {
|
|
98
|
-
const prefix = "$$vitest:";
|
|
99
|
-
if (typeof str === "string" && str.startsWith(prefix))
|
|
100
|
-
return parseRegexp(str.slice(prefix.length));
|
|
101
|
-
return str;
|
|
102
|
-
}
|
|
103
|
-
function unwrapConfig(config) {
|
|
104
|
-
if (config.testNamePattern)
|
|
105
|
-
config.testNamePattern = parsePossibleRegexp(config.testNamePattern);
|
|
106
|
-
return config;
|
|
107
|
-
}
|
|
108
|
-
async function run(ctx) {
|
|
109
|
-
const exit = process.exit;
|
|
110
|
-
ctx.config = unwrapConfig(ctx.config);
|
|
111
|
-
const inspectorCleanup = setupInspect(ctx.config);
|
|
112
|
-
try {
|
|
113
|
-
const state = await init(ctx);
|
|
114
|
-
const { run: run2, executor } = await startViteNode({
|
|
115
|
-
state
|
|
116
|
-
});
|
|
117
|
-
await run2(ctx.files, ctx.config, { environment: state.environment, options: ctx.environment.options }, executor);
|
|
118
|
-
await rpcDone();
|
|
119
|
-
} finally {
|
|
120
|
-
inspectorCleanup();
|
|
121
|
-
process.exit = exit;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export { run };
|