vitest 4.1.12 → 5.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 +192 -10
- package/browser/context.d.ts +7 -1
- package/browser/context.js +5 -5
- package/config.d.ts +0 -2
- package/dist/browser.d.ts +52 -21
- package/dist/browser.js +12 -13
- package/dist/chunks/{acorn.B2iPLyUM.js → acorn.C1kjbUFw.js} +30 -30
- package/dist/chunks/{base.B6Opl8PE.js → base.Cof-UHJf.js} +81 -52
- package/dist/chunks/{browser.d.BcoexmFG.d.ts → browser.d.C7tWgUvw.d.ts} +17 -14
- package/dist/chunks/{cac.DzDtg8hz.js → cac.BYbt0aJp.js} +143 -87
- package/dist/chunks/{cli-api.B0Pz1_R7.js → cli-api.COfZo8lK.js} +7160 -7189
- package/dist/chunks/config.d.B3YV4t0O.d.ts +3873 -0
- package/dist/chunks/{console.3WNpx0tS.js → console.CQZ877Hi.js} +69 -63
- package/dist/chunks/{constants.CPYnjOGj.js → constants.DLYM6cZY.js} +2 -2
- package/dist/chunks/coverage.9iqXE2gN.js +26 -0
- package/dist/chunks/{coverage.CTzCuANN.js → coverage.jGCktcGP.js} +7 -2
- package/dist/chunks/{creator.DgVhQm5q.js → creator.DHWmytIK.js} +65 -28
- package/dist/chunks/{defaults.9aQKnqFk.js → defaults.B1FCaFfh.js} +16 -9
- package/dist/chunks/display.BlTmubjj.js +194 -0
- package/dist/chunks/doctor.B-oPbwps.js +465 -0
- package/dist/chunks/{env.D4Lgay0q.js → env.BKKtU2WC.js} +2 -1
- package/dist/chunks/{environment.d.CrsxCzP1.d.ts → environment.d.BFQtFKdZ.d.ts} +9 -1
- package/dist/chunks/globals.ZKtKSkEf.js +29 -0
- package/dist/chunks/index.Bi0NXYPf.js +1708 -0
- package/dist/chunks/{index.CMESou6r.js → index.BoyTG_B7.js} +82 -81
- package/dist/chunks/index.CZzC1gGg.js +8501 -0
- package/dist/chunks/index.D0heQG4v.js +1318 -0
- package/dist/chunks/index.Di8au7q4.js +15665 -0
- package/dist/chunks/{index.Chj8NDwU.js → index.DmDMHCg8.js} +6 -12
- package/dist/chunks/{index.DXx9Dtk7.js → index.w_oBZ9N8.js} +25 -12
- package/dist/chunks/{init-forks.H5ZuobOQ.js → init-forks.BaDXQSD8.js} +7 -10
- package/dist/chunks/{init-threads.6kl1khcL.js → init-threads.ZX_Vov0z.js} +1 -1
- package/dist/chunks/{init.k9zZ9sLh.js → init.CO4AB7HZ.js} +113 -38
- package/dist/chunks/module-dependencies._2Eei3FO.js +71 -0
- package/dist/chunks/{native.DPzPHdi5.js → native.upB-V0CK.js} +50 -37
- package/dist/chunks/{nativeModuleMocker.BkNfQMkH.js → nativeModuleMocker.Dh5azSB4.js} +48 -19
- package/dist/chunks/{index.BCY_7LL2.js → nativeModuleRunner.9xPIMzi7.js} +110 -42
- package/dist/chunks/node.B9mkVmLH.js +47 -0
- package/dist/chunks/offset.Dy-5Fdfn.js +24 -0
- package/dist/chunks/pathe.M-eThtNZ.zq3TM4NT.js +492 -0
- package/dist/chunks/{reporters.d.DtoKVV2s.d.ts → plugin.d.LRFSN46m.d.ts} +2573 -1453
- package/dist/chunks/plugins.DPQHVT0p.js +37 -0
- package/dist/chunks/rawSnapshot.DqSiqIEx.js +356 -0
- package/dist/chunks/resolver.BzpmeQeT.js +48 -0
- package/dist/chunks/rpc.Uhkwr2NM.js +93 -0
- package/dist/chunks/rpc.d.3FOhdFx8.d.ts +75 -0
- package/dist/chunks/run.CjdgFZiW.js +4231 -0
- package/dist/chunks/setup-common.CqAQCXzx.js +36 -0
- package/dist/chunks/source-map.DakdQc29.js +1788 -0
- package/dist/chunks/source-map.d.BkG8YK_3.d.ts +89 -0
- package/dist/chunks/spy.DDMXghXv.js +509 -0
- package/dist/chunks/task-utils.d.D-gFPNFi.d.ts +144 -0
- package/dist/chunks/tinyrainbow.Do8I1XRG.js +88 -0
- package/dist/chunks/{utils.BS4fH3nR.js → utils.BBk_icFG.js} +50 -52
- package/dist/chunks/{utils.BX5Fg8C4.js → utils.DYj33du9.js} +1 -17
- package/dist/chunks/vm.b4MbCAJQ.js +1329 -0
- package/dist/chunks/{worker.d.ZpHpO4yb.d.ts → worker.d.CyJRpyfZ.d.ts} +34 -19
- package/dist/cli.js +5 -6
- package/dist/config.cjs +9 -6
- package/dist/config.d.ts +27 -25
- package/dist/config.js +3 -3
- package/dist/index.d.ts +471 -38
- package/dist/index.js +18 -19
- package/dist/module-evaluator.d.ts +64 -5
- package/dist/module-evaluator.js +122 -62
- package/dist/node.d.ts +355 -87
- package/dist/node.js +49 -73
- package/dist/runtime.d.ts +43 -6
- package/dist/runtime.js +7 -9
- package/dist/spy.js +1 -1
- package/dist/task-utils.js +290 -0
- package/dist/{chunks/traces.DT5aQ62U.js → traces.js} +3 -2
- package/dist/worker.d.ts +8 -10
- package/dist/worker.js +33 -43
- package/dist/workers/forks.js +30 -40
- package/dist/workers/runVmTests.js +66 -43
- package/dist/workers/threads.js +30 -40
- package/dist/workers/vmForks.js +19 -20
- package/dist/workers/vmThreads.js +19 -20
- package/globals.d.ts +19 -19
- package/index.cjs +3 -3
- package/optional-runtime-types.d.ts +1 -1
- package/optional-types.d.ts +1 -1
- package/package.json +59 -74
- package/suppress-warnings.cjs +1 -1
- package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -6
- package/dist/chunks/benchmark.CX_oY03V.js +0 -40
- package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +0 -24
- package/dist/chunks/config.d.A1h_Y6Jt.d.ts +0 -232
- package/dist/chunks/coverage.DM_a_rWm.js +0 -1087
- package/dist/chunks/coverage.d.BZtK59WP.d.ts +0 -37
- package/dist/chunks/evaluatedModules.Dg1zASAC.js +0 -17
- package/dist/chunks/global.d.DVsSRdQ5.d.ts +0 -100
- package/dist/chunks/globals.Dj1TGiMC.js +0 -31
- package/dist/chunks/index.DC7d2Pf8.js +0 -729
- package/dist/chunks/index.DdgEv5B1.js +0 -42
- package/dist/chunks/index.UpGiHP7g.js +0 -4255
- package/dist/chunks/index.og1WyBLx.js +0 -6358
- package/dist/chunks/nativeModuleRunner.BIakptoF.js +0 -36
- package/dist/chunks/node.COQbm6gK.js +0 -14
- package/dist/chunks/plugin.d.DwFIiJ7i.d.ts +0 -38
- package/dist/chunks/rpc.MzXet3jl.js +0 -144
- package/dist/chunks/rpc.d.B_8sPU0w.d.ts +0 -30
- package/dist/chunks/setup-common.DYx3LtFI.js +0 -60
- package/dist/chunks/startVitestModuleRunner.DB-7oCpn.js +0 -740
- package/dist/chunks/suite.d.udJtyAgw.d.ts +0 -10
- package/dist/chunks/test.DNmyFkvJ.js +0 -4430
- package/dist/chunks/traces.d.D2T_R8rx.d.ts +0 -60
- package/dist/chunks/vm.CXMd5FHa.js +0 -785
- package/dist/coverage.d.ts +0 -123
- package/dist/coverage.js +0 -27
- package/dist/environments.d.ts +0 -22
- package/dist/environments.js +0 -5
- package/dist/reporters.d.ts +0 -27
- package/dist/reporters.js +0 -26
- package/dist/runners.d.ts +0 -70
- package/dist/runners.js +0 -19
- package/dist/snapshot.d.ts +0 -9
- package/dist/snapshot.js +0 -6
- package/dist/suite.d.ts +0 -5
- package/dist/suite.js +0 -8
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { pathToFileURL } from 'node:url';
|
|
2
|
-
import { r as resolveModule } from './index.BCY_7LL2.js';
|
|
3
|
-
import { resolve } from 'pathe';
|
|
4
|
-
import { ModuleRunner } from 'vite/module-runner';
|
|
5
|
-
|
|
6
|
-
class NativeModuleRunner extends ModuleRunner {
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
mocker;
|
|
11
|
-
constructor(root, mocker) {
|
|
12
|
-
super({
|
|
13
|
-
hmr: false,
|
|
14
|
-
sourcemapInterceptor: false,
|
|
15
|
-
transport: { invoke() {
|
|
16
|
-
throw new Error("Unexpected `invoke`");
|
|
17
|
-
} }
|
|
18
|
-
});
|
|
19
|
-
this.root = root;
|
|
20
|
-
this.mocker = mocker;
|
|
21
|
-
if (mocker) Object.defineProperty(globalThis, "__vitest_mocker__", {
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: mocker
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
async import(moduleId) {
|
|
28
|
-
const path = resolveModule(moduleId, { paths: [this.root] }) ?? resolve(this.root, moduleId);
|
|
29
|
-
// resolveModule doesn't keep the query params, so we need to add them back
|
|
30
|
-
let queryParams = "";
|
|
31
|
-
if (moduleId.includes("?") && !path.includes("?")) queryParams = moduleId.slice(moduleId.indexOf("?"));
|
|
32
|
-
return import(pathToFileURL(path + queryParams).toString());
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { NativeModuleRunner as N };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
|
|
2
|
-
import { g as getWorkerState } from './utils.BX5Fg8C4.js';
|
|
3
|
-
import '@vitest/utils/timers';
|
|
4
|
-
|
|
5
|
-
class VitestNodeSnapshotEnvironment extends NodeSnapshotEnvironment {
|
|
6
|
-
getHeader() {
|
|
7
|
-
return `// Vitest Snapshot v${this.getVersion()}, https://vitest.dev/guide/snapshot.html`;
|
|
8
|
-
}
|
|
9
|
-
resolvePath(filepath) {
|
|
10
|
-
return getWorkerState().rpc.resolveSnapshotPath(filepath);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { VitestNodeSnapshotEnvironment };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { DevEnvironment } from 'vite';
|
|
2
|
-
import { V as Vitest, T as TestProject, a as TestProjectConfiguration } from './reporters.d.DtoKVV2s.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Generate a unique cache identifier.
|
|
6
|
-
*
|
|
7
|
-
* Return `false` to disable caching of the file.
|
|
8
|
-
* @experimental
|
|
9
|
-
*/
|
|
10
|
-
interface CacheKeyIdGenerator {
|
|
11
|
-
(context: CacheKeyIdGeneratorContext): string | undefined | null | false;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @experimental
|
|
15
|
-
*/
|
|
16
|
-
interface CacheKeyIdGeneratorContext {
|
|
17
|
-
environment: DevEnvironment;
|
|
18
|
-
id: string;
|
|
19
|
-
sourceCode: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface VitestPluginContext {
|
|
23
|
-
vitest: Vitest;
|
|
24
|
-
project: TestProject;
|
|
25
|
-
injectTestProjects: (config: TestProjectConfiguration | TestProjectConfiguration[]) => Promise<TestProject[]>;
|
|
26
|
-
/**
|
|
27
|
-
* Define a generator that will be applied before hashing the cache key.
|
|
28
|
-
*
|
|
29
|
-
* Use this to make sure Vitest generates correct hash. It is a good idea
|
|
30
|
-
* to define this function if your plugin can be registered with different options.
|
|
31
|
-
*
|
|
32
|
-
* This is called only if `experimental.fsModuleCache` is defined.
|
|
33
|
-
* @experimental
|
|
34
|
-
*/
|
|
35
|
-
experimental_defineCacheKeyGenerator: (callback: CacheKeyIdGenerator) => void;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type { CacheKeyIdGenerator as C, VitestPluginContext as V, CacheKeyIdGeneratorContext as a };
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { getSafeTimers } from '@vitest/utils/timers';
|
|
2
|
-
import { c as createBirpc } from './index.Chj8NDwU.js';
|
|
3
|
-
import { g as getWorkerState } from './utils.BX5Fg8C4.js';
|
|
4
|
-
|
|
5
|
-
/* Ported from https://github.com/boblauer/MockDate/blob/master/src/mockdate.ts */
|
|
6
|
-
/*
|
|
7
|
-
The MIT License (MIT)
|
|
8
|
-
|
|
9
|
-
Copyright (c) 2014 Bob Lauer
|
|
10
|
-
|
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
-
in the Software without restriction, including without limitation the rights
|
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
furnished to do so, subject to the following conditions:
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in all
|
|
19
|
-
copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
-
SOFTWARE.
|
|
28
|
-
*/
|
|
29
|
-
const RealDate = Date;
|
|
30
|
-
let now = null;
|
|
31
|
-
class MockDate extends RealDate {
|
|
32
|
-
constructor(y, m, d, h, M, s, ms) {
|
|
33
|
-
super();
|
|
34
|
-
let date;
|
|
35
|
-
switch (arguments.length) {
|
|
36
|
-
case 0:
|
|
37
|
-
if (now !== null) date = new RealDate(now.valueOf());
|
|
38
|
-
else date = new RealDate();
|
|
39
|
-
break;
|
|
40
|
-
case 1:
|
|
41
|
-
date = new RealDate(y);
|
|
42
|
-
break;
|
|
43
|
-
default:
|
|
44
|
-
d = typeof d === "undefined" ? 1 : d;
|
|
45
|
-
h = h || 0;
|
|
46
|
-
M = M || 0;
|
|
47
|
-
s = s || 0;
|
|
48
|
-
ms = ms || 0;
|
|
49
|
-
date = new RealDate(y, m, d, h, M, s, ms);
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
Object.setPrototypeOf(date, MockDate.prototype);
|
|
53
|
-
return date;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
MockDate.UTC = RealDate.UTC;
|
|
57
|
-
MockDate.now = function() {
|
|
58
|
-
return new MockDate().valueOf();
|
|
59
|
-
};
|
|
60
|
-
MockDate.parse = function(dateString) {
|
|
61
|
-
return RealDate.parse(dateString);
|
|
62
|
-
};
|
|
63
|
-
MockDate.toString = function() {
|
|
64
|
-
return RealDate.toString();
|
|
65
|
-
};
|
|
66
|
-
function mockDate(date) {
|
|
67
|
-
const dateObj = new RealDate(date.valueOf());
|
|
68
|
-
if (Number.isNaN(dateObj.getTime())) throw new TypeError(`mockdate: The time set is an invalid date: ${date}`);
|
|
69
|
-
// @ts-expect-error global
|
|
70
|
-
globalThis.Date = MockDate;
|
|
71
|
-
now = dateObj.valueOf();
|
|
72
|
-
}
|
|
73
|
-
function resetDate() {
|
|
74
|
-
globalThis.Date = RealDate;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const { get } = Reflect;
|
|
78
|
-
function withSafeTimers(fn) {
|
|
79
|
-
const { setTimeout, clearTimeout, nextTick, setImmediate, clearImmediate } = getSafeTimers();
|
|
80
|
-
const currentSetTimeout = globalThis.setTimeout;
|
|
81
|
-
const currentClearTimeout = globalThis.clearTimeout;
|
|
82
|
-
const currentSetImmediate = globalThis.setImmediate;
|
|
83
|
-
const currentClearImmediate = globalThis.clearImmediate;
|
|
84
|
-
const currentNextTick = globalThis.process?.nextTick;
|
|
85
|
-
try {
|
|
86
|
-
globalThis.setTimeout = setTimeout;
|
|
87
|
-
globalThis.clearTimeout = clearTimeout;
|
|
88
|
-
if (setImmediate) globalThis.setImmediate = setImmediate;
|
|
89
|
-
if (clearImmediate) globalThis.clearImmediate = clearImmediate;
|
|
90
|
-
if (globalThis.process && nextTick) globalThis.process.nextTick = nextTick;
|
|
91
|
-
return fn();
|
|
92
|
-
} finally {
|
|
93
|
-
globalThis.setTimeout = currentSetTimeout;
|
|
94
|
-
globalThis.clearTimeout = currentClearTimeout;
|
|
95
|
-
globalThis.setImmediate = currentSetImmediate;
|
|
96
|
-
globalThis.clearImmediate = currentClearImmediate;
|
|
97
|
-
if (globalThis.process && nextTick) nextTick(() => {
|
|
98
|
-
globalThis.process.nextTick = currentNextTick;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
const promises = /* @__PURE__ */ new Set();
|
|
103
|
-
async function rpcDone() {
|
|
104
|
-
if (!promises.size) return;
|
|
105
|
-
const awaitable = Array.from(promises);
|
|
106
|
-
return Promise.all(awaitable);
|
|
107
|
-
}
|
|
108
|
-
const onCancelCallbacks = [];
|
|
109
|
-
function onCancel(callback) {
|
|
110
|
-
onCancelCallbacks.push(callback);
|
|
111
|
-
}
|
|
112
|
-
function createRuntimeRpc(options) {
|
|
113
|
-
return createSafeRpc(createBirpc({ async onCancel(reason) {
|
|
114
|
-
await Promise.all(onCancelCallbacks.map((fn) => fn(reason)));
|
|
115
|
-
} }, {
|
|
116
|
-
eventNames: ["onCancel"],
|
|
117
|
-
timeout: -1,
|
|
118
|
-
...options
|
|
119
|
-
}));
|
|
120
|
-
}
|
|
121
|
-
function createSafeRpc(rpc) {
|
|
122
|
-
return new Proxy(rpc, { get(target, p, handler) {
|
|
123
|
-
// keep $rejectPendingCalls as sync function
|
|
124
|
-
if (p === "$rejectPendingCalls") return rpc.$rejectPendingCalls;
|
|
125
|
-
const sendCall = get(target, p, handler);
|
|
126
|
-
const safeSendCall = (...args) => withSafeTimers(async () => {
|
|
127
|
-
const result = sendCall(...args);
|
|
128
|
-
promises.add(result);
|
|
129
|
-
try {
|
|
130
|
-
return await result;
|
|
131
|
-
} finally {
|
|
132
|
-
promises.delete(result);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
safeSendCall.asEvent = sendCall.asEvent;
|
|
136
|
-
return safeSendCall;
|
|
137
|
-
} });
|
|
138
|
-
}
|
|
139
|
-
function rpc() {
|
|
140
|
-
const { rpc } = getWorkerState();
|
|
141
|
-
return rpc;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export { RealDate as R, rpcDone as a, resetDate as b, createRuntimeRpc as c, mockDate as m, onCancel as o, rpc as r };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { File, TestArtifact, TaskResultPack, TaskEventPack, CancelReason } from '@vitest/runner';
|
|
2
|
-
import { SnapshotResult } from '@vitest/snapshot';
|
|
3
|
-
import { FetchFunctionOptions, FetchResult } from 'vite/module-runner';
|
|
4
|
-
import { O as OTELCarrier, F as FetchCachedFileSystemResult, R as ResolveFunctionResult, U as UserConsoleLog, A as AsyncLeak, a as AfterSuiteRunMeta } from './traces.d.D2T_R8rx.js';
|
|
5
|
-
|
|
6
|
-
interface RuntimeRPC {
|
|
7
|
-
fetch: (id: string, importer: string | undefined, environment: string, options?: FetchFunctionOptions, otelCarrier?: OTELCarrier) => Promise<FetchResult | FetchCachedFileSystemResult>;
|
|
8
|
-
resolve: (id: string, importer: string | undefined, environment: string) => Promise<ResolveFunctionResult | null>;
|
|
9
|
-
transform: (id: string) => Promise<{
|
|
10
|
-
code?: string;
|
|
11
|
-
}>;
|
|
12
|
-
onUserConsoleLog: (log: UserConsoleLog) => void;
|
|
13
|
-
onUnhandledError: (err: unknown, type: string) => void;
|
|
14
|
-
onAsyncLeaks: (leak: AsyncLeak[]) => void;
|
|
15
|
-
onQueued: (file: File) => void;
|
|
16
|
-
onCollected: (files: File[]) => Promise<void>;
|
|
17
|
-
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
18
|
-
onTaskArtifactRecord: <Artifact extends TestArtifact>(testId: string, artifact: Artifact) => Promise<Artifact>;
|
|
19
|
-
onTaskUpdate: (pack: TaskResultPack[], events: TaskEventPack[]) => Promise<void>;
|
|
20
|
-
onCancel: (reason: CancelReason) => void;
|
|
21
|
-
getCountOfFailedTests: () => number;
|
|
22
|
-
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
23
|
-
resolveSnapshotPath: (testPath: string) => string;
|
|
24
|
-
ensureModuleGraphEntry: (id: string, importer: string) => void;
|
|
25
|
-
}
|
|
26
|
-
interface RunnerRPC {
|
|
27
|
-
onCancel: (reason: CancelReason) => void;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export type { RuntimeRPC as R, RunnerRPC as a };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { r as resolveCoverageProviderModule } from './coverage.CTzCuANN.js';
|
|
2
|
-
import { addSerializer } from '@vitest/snapshot';
|
|
3
|
-
import { setSafeTimers } from '@vitest/utils/timers';
|
|
4
|
-
import { g as getWorkerState } from './utils.BX5Fg8C4.js';
|
|
5
|
-
|
|
6
|
-
async function startCoverageInsideWorker(options, loader, runtimeOptions) {
|
|
7
|
-
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
8
|
-
if (coverageModule) return coverageModule.startCoverage?.(runtimeOptions);
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
async function takeCoverageInsideWorker(options, loader) {
|
|
12
|
-
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
13
|
-
if (coverageModule) return coverageModule.takeCoverage?.({ moduleExecutionInfo: loader.moduleExecutionInfo });
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
async function stopCoverageInsideWorker(options, loader, runtimeOptions) {
|
|
17
|
-
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
18
|
-
if (coverageModule) return coverageModule.stopCoverage?.(runtimeOptions);
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let globalSetup = false;
|
|
23
|
-
async function setupCommonEnv(config) {
|
|
24
|
-
setupDefines(config);
|
|
25
|
-
setupEnv(config.env);
|
|
26
|
-
if (globalSetup) return;
|
|
27
|
-
globalSetup = true;
|
|
28
|
-
setSafeTimers();
|
|
29
|
-
if (config.globals) (await import('./globals.Dj1TGiMC.js')).registerApiGlobally();
|
|
30
|
-
}
|
|
31
|
-
function setupDefines(config) {
|
|
32
|
-
for (const key in config.defines) globalThis[key] = config.defines[key];
|
|
33
|
-
}
|
|
34
|
-
function setupEnv(env) {
|
|
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];
|
|
41
|
-
}
|
|
42
|
-
async function loadDiffConfig(config, moduleRunner) {
|
|
43
|
-
if (typeof config.diff === "object") return config.diff;
|
|
44
|
-
if (typeof config.diff !== "string") return;
|
|
45
|
-
const diffModule = await moduleRunner.import(config.diff);
|
|
46
|
-
if (diffModule && typeof diffModule.default === "object" && diffModule.default != null) return diffModule.default;
|
|
47
|
-
else throw new Error(`invalid diff config file ${config.diff}. Must have a default export with config object`);
|
|
48
|
-
}
|
|
49
|
-
async function loadSnapshotSerializers(config, moduleRunner) {
|
|
50
|
-
const files = config.snapshotSerializers;
|
|
51
|
-
(await Promise.all(files.map(async (file) => {
|
|
52
|
-
const mo = await moduleRunner.import(file);
|
|
53
|
-
if (!mo || typeof mo.default !== "object" || mo.default === null) throw new Error(`invalid snapshot serializer file ${file}. Must export a default object`);
|
|
54
|
-
const config = mo.default;
|
|
55
|
-
if (typeof config.test !== "function" || typeof config.serialize !== "function" && typeof config.print !== "function") throw new TypeError(`invalid snapshot serializer in ${file}. Must have a 'test' method along with either a 'serialize' or 'print' method.`);
|
|
56
|
-
return config;
|
|
57
|
-
}))).forEach((serializer) => addSerializer(serializer));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { loadSnapshotSerializers as a, startCoverageInsideWorker as b, stopCoverageInsideWorker as c, loadDiffConfig as l, setupCommonEnv as s, takeCoverageInsideWorker as t };
|