vitest 4.0.6 → 4.0.8
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 +1 -1
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +2 -2
- package/dist/chunks/base.BgTO2qAg.js +156 -0
- package/dist/chunks/{benchmark.DHKMYAts.js → benchmark.B3N2zMcH.js} +9 -4
- package/dist/chunks/{browser.d.ScGeWTou.d.ts → browser.d.DTTM2PTh.d.ts} +1 -1
- package/dist/chunks/{cac.BBqWH4nd.js → cac.CfkWq8Qy.js} +117 -43
- package/dist/chunks/{cli-api.UL3SwFUb.js → cli-api.BQ-bjcRi.js} +1870 -847
- package/dist/chunks/console.Cf-YriPC.js +146 -0
- package/dist/chunks/{coverage.DuCn_Tmx.js → coverage.NVjCOln1.js} +281 -103
- package/dist/chunks/{creator.cqqifzG7.js → creator.fzVyoMf3.js} +74 -30
- package/dist/chunks/{date.-jtEtIeV.js → date.Bq6ZW5rf.js} +17 -6
- package/dist/chunks/{git.BFNcloKD.js → git.Bm2pzPAa.js} +3 -3
- package/dist/chunks/{global.d.DdOkMiVb.d.ts → global.d.DVdCfKp5.d.ts} +1 -1
- package/dist/chunks/{globals.BGT_RUsD.js → globals.DOh96BiR.js} +5 -5
- package/dist/chunks/{resolveSnapshotEnvironment.BZzLjzkh.js → index.BY4-tcno.js} +42 -25
- package/dist/chunks/{index.Bgo3tNWt.js → index.DAL392Ss.js} +40 -15
- package/dist/chunks/{index.RwjEGCQ0.js → index.DIFZf73e.js} +2 -2
- package/dist/chunks/{index.DV0mQLEO.js → index.DfKyPFVi.js} +195 -64
- package/dist/chunks/{index.BL8Hg4Uk.js → index.kotH7DY7.js} +837 -380
- package/dist/chunks/{index.CpdwpN7L.js → index.op2Re5rn.js} +22 -12
- package/dist/chunks/{init-forks.CSGFj9zN.js → init-forks.2hx7cf78.js} +16 -5
- package/dist/chunks/{init-threads.CIJLeFO8.js → init-threads.Cm4OCIWA.js} +3 -2
- package/dist/chunks/{init.DUeOfNO9.js → init.DMDG-idf.js} +124 -54
- package/dist/chunks/{inspector.DLZxSeU3.js → inspector.CvyFGlXm.js} +25 -10
- package/dist/chunks/{moduleRunner.d.TP-w6tIQ.d.ts → moduleRunner.d.CzOZ_4wC.d.ts} +1 -1
- package/dist/chunks/{node.BwAWWjHZ.js → node.Ce0vMQM7.js} +1 -1
- package/dist/chunks/{plugin.d.lctzD3Wk.d.ts → plugin.d.D4RrtywJ.d.ts} +1 -1
- package/dist/chunks/{reporters.d.PEs0tXod.d.ts → reporters.d.Da1D1VbQ.d.ts} +19 -9
- package/dist/chunks/rpc.BUV7uWKJ.js +76 -0
- package/dist/chunks/{setup-common.DR1sucx6.js → setup-common.LGjNSzXp.js} +20 -8
- package/dist/chunks/{startModuleRunner.Di-EZqh0.js → startModuleRunner.BOmUtLIO.js} +228 -105
- package/dist/chunks/{test.CnspO-X4.js → test.ClrAtjMv.js} +48 -22
- package/dist/chunks/{utils.CG9h5ccR.js → utils.DvEY5TfP.js} +14 -5
- package/dist/chunks/{vi.BZvkKVkM.js → vi.Bgcdy3bQ.js} +261 -111
- package/dist/chunks/{vm.Co_lR2NL.js → vm.BIkCDs68.js} +177 -70
- package/dist/chunks/{worker.d.B4Hthdvt.d.ts → worker.d.DadbA89M.d.ts} +52 -6
- package/dist/cli.js +2 -2
- package/dist/config.d.ts +5 -5
- package/dist/coverage.d.ts +3 -3
- package/dist/coverage.js +1 -1
- package/dist/environments.js +2 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/module-evaluator.d.ts +2 -2
- package/dist/module-evaluator.js +85 -35
- package/dist/module-runner.js +2 -2
- package/dist/node.d.ts +7 -7
- package/dist/node.js +16 -12
- package/dist/reporters.d.ts +3 -3
- package/dist/reporters.js +2 -2
- package/dist/runners.js +7 -7
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.d.ts +2 -1
- package/dist/worker.js +27 -27
- package/dist/workers/forks.js +34 -31
- package/dist/workers/runVmTests.js +41 -22
- package/dist/workers/threads.js +34 -31
- package/dist/workers/vmForks.js +14 -14
- package/dist/workers/vmThreads.js +14 -14
- package/package.json +20 -20
- package/dist/chunks/base.BAf_bYeI.js +0 -128
- package/dist/chunks/console.CTJL2nuH.js +0 -115
- package/dist/chunks/rpc.Dv1Jt3i2.js +0 -66
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { getSafeTimers } from '@vitest/utils/timers';
|
|
2
|
+
import { c as createBirpc } from './index.DAL392Ss.js';
|
|
3
|
+
import { g as getWorkerState } from './utils.DvEY5TfP.js';
|
|
4
|
+
|
|
5
|
+
const { get } = Reflect;
|
|
6
|
+
function withSafeTimers(fn) {
|
|
7
|
+
const { setTimeout, clearTimeout, nextTick, setImmediate, clearImmediate } = getSafeTimers();
|
|
8
|
+
const currentSetTimeout = globalThis.setTimeout;
|
|
9
|
+
const currentClearTimeout = globalThis.clearTimeout;
|
|
10
|
+
const currentSetImmediate = globalThis.setImmediate;
|
|
11
|
+
const currentClearImmediate = globalThis.clearImmediate;
|
|
12
|
+
const currentNextTick = globalThis.process?.nextTick;
|
|
13
|
+
try {
|
|
14
|
+
globalThis.setTimeout = setTimeout;
|
|
15
|
+
globalThis.clearTimeout = clearTimeout;
|
|
16
|
+
if (setImmediate) globalThis.setImmediate = setImmediate;
|
|
17
|
+
if (clearImmediate) globalThis.clearImmediate = clearImmediate;
|
|
18
|
+
if (globalThis.process && nextTick) globalThis.process.nextTick = nextTick;
|
|
19
|
+
return fn();
|
|
20
|
+
} finally {
|
|
21
|
+
globalThis.setTimeout = currentSetTimeout;
|
|
22
|
+
globalThis.clearTimeout = currentClearTimeout;
|
|
23
|
+
globalThis.setImmediate = currentSetImmediate;
|
|
24
|
+
globalThis.clearImmediate = currentClearImmediate;
|
|
25
|
+
if (globalThis.process && nextTick) nextTick(() => {
|
|
26
|
+
globalThis.process.nextTick = currentNextTick;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const promises = /* @__PURE__ */ new Set();
|
|
31
|
+
async function rpcDone() {
|
|
32
|
+
if (!promises.size) return;
|
|
33
|
+
const awaitable = Array.from(promises);
|
|
34
|
+
return Promise.all(awaitable);
|
|
35
|
+
}
|
|
36
|
+
const onCancelCallbacks = [];
|
|
37
|
+
function onCancel(callback) {
|
|
38
|
+
onCancelCallbacks.push(callback);
|
|
39
|
+
}
|
|
40
|
+
function createRuntimeRpc(options) {
|
|
41
|
+
return createSafeRpc(createBirpc({ async onCancel(reason) {
|
|
42
|
+
await Promise.all(onCancelCallbacks.map((fn) => fn(reason)));
|
|
43
|
+
} }, {
|
|
44
|
+
eventNames: [
|
|
45
|
+
"onUserConsoleLog",
|
|
46
|
+
"onCollected",
|
|
47
|
+
"onCancel"
|
|
48
|
+
],
|
|
49
|
+
timeout: -1,
|
|
50
|
+
...options
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
function createSafeRpc(rpc) {
|
|
54
|
+
return new Proxy(rpc, { get(target, p, handler) {
|
|
55
|
+
// keep $rejectPendingCalls as sync function
|
|
56
|
+
if (p === "$rejectPendingCalls") return rpc.$rejectPendingCalls;
|
|
57
|
+
const sendCall = get(target, p, handler);
|
|
58
|
+
const safeSendCall = (...args) => withSafeTimers(async () => {
|
|
59
|
+
const result = sendCall(...args);
|
|
60
|
+
promises.add(result);
|
|
61
|
+
try {
|
|
62
|
+
return await result;
|
|
63
|
+
} finally {
|
|
64
|
+
promises.delete(result);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
safeSendCall.asEvent = sendCall.asEvent;
|
|
68
|
+
return safeSendCall;
|
|
69
|
+
} });
|
|
70
|
+
}
|
|
71
|
+
function rpc() {
|
|
72
|
+
const { rpc } = getWorkerState();
|
|
73
|
+
return rpc;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { rpcDone as a, createRuntimeRpc as c, onCancel as o, rpc as r };
|
|
@@ -1,38 +1,50 @@
|
|
|
1
1
|
import { r as resolveCoverageProviderModule } from './coverage.D_JHT54q.js';
|
|
2
2
|
import { addSerializer } from '@vitest/snapshot';
|
|
3
3
|
import { setSafeTimers } from '@vitest/utils/timers';
|
|
4
|
-
import { g as getWorkerState } from './utils.
|
|
4
|
+
import { g as getWorkerState } from './utils.DvEY5TfP.js';
|
|
5
5
|
|
|
6
6
|
async function startCoverageInsideWorker(options, loader, runtimeOptions) {
|
|
7
7
|
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
8
|
-
|
|
8
|
+
if (coverageModule) return coverageModule.startCoverage?.(runtimeOptions);
|
|
9
|
+
return null;
|
|
9
10
|
}
|
|
10
11
|
async function takeCoverageInsideWorker(options, loader) {
|
|
11
12
|
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
12
|
-
|
|
13
|
+
if (coverageModule) return coverageModule.takeCoverage?.({ moduleExecutionInfo: loader.moduleExecutionInfo });
|
|
14
|
+
return null;
|
|
13
15
|
}
|
|
14
16
|
async function stopCoverageInsideWorker(options, loader, runtimeOptions) {
|
|
15
17
|
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
16
|
-
|
|
18
|
+
if (coverageModule) return coverageModule.stopCoverage?.(runtimeOptions);
|
|
19
|
+
return null;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
let globalSetup = false;
|
|
20
23
|
async function setupCommonEnv(config) {
|
|
21
|
-
|
|
24
|
+
setupDefines(config);
|
|
25
|
+
setupEnv(config.env);
|
|
26
|
+
if (globalSetup) return;
|
|
27
|
+
globalSetup = true;
|
|
28
|
+
setSafeTimers();
|
|
29
|
+
if (config.globals) (await import('./globals.DOh96BiR.js')).registerApiGlobally();
|
|
22
30
|
}
|
|
23
31
|
function setupDefines(config) {
|
|
24
32
|
for (const key in config.defines) globalThis[key] = config.defines[key];
|
|
25
33
|
}
|
|
26
34
|
function setupEnv(env) {
|
|
27
|
-
const state = getWorkerState()
|
|
28
|
-
|
|
35
|
+
const state = getWorkerState();
|
|
36
|
+
// same boolean-to-string assignment as VitestPlugin.configResolved
|
|
37
|
+
const { PROD, DEV,...restEnvs } = env;
|
|
38
|
+
state.metaEnv.PROD = PROD;
|
|
39
|
+
state.metaEnv.DEV = DEV;
|
|
40
|
+
for (const key in restEnvs) state.metaEnv[key] = env[key];
|
|
29
41
|
}
|
|
30
42
|
async function loadDiffConfig(config, moduleRunner) {
|
|
31
43
|
if (typeof config.diff === "object") return config.diff;
|
|
32
44
|
if (typeof config.diff !== "string") return;
|
|
33
45
|
const diffModule = await moduleRunner.import(config.diff);
|
|
34
46
|
if (diffModule && typeof diffModule.default === "object" && diffModule.default != null) return diffModule.default;
|
|
35
|
-
throw new Error(`invalid diff config file ${config.diff}. Must have a default export with config object`);
|
|
47
|
+
else throw new Error(`invalid diff config file ${config.diff}. Must have a default export with config object`);
|
|
36
48
|
}
|
|
37
49
|
async function loadSnapshotSerializers(config, moduleRunner) {
|
|
38
50
|
const files = config.snapshotSerializers;
|