vitest 3.2.0-beta.3 → 3.2.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.d.ts +1 -1
- package/dist/browser.js +2 -2
- package/dist/chunks/{base.D4119yLM.js → base.Cg0miDlQ.js} +10 -14
- package/dist/chunks/{benchmark.Cf_PACH1.js → benchmark.CYdenmiT.js} +4 -6
- package/dist/chunks/{cac.DWaWHIIE.js → cac.6rXCxFY1.js} +66 -136
- package/dist/chunks/{cli-api.CnmEXkxs.js → cli-api.Cej3MBjA.js} +1250 -1335
- package/dist/chunks/{console.Cwr-MFPV.js → console.CtFJOzRO.js} +24 -45
- package/dist/chunks/{coverage.0iPg4Wrz.js → coverage.DVF1vEu8.js} +4 -12
- package/dist/chunks/{coverage.C73DaDgS.js → coverage.EIiagJJP.js} +484 -1003
- package/dist/chunks/{creator.C8WKy2eW.js → creator.GK6I-cL4.js} +29 -76
- package/dist/chunks/{date.ByMsSlOr.js → date.Bq6ZW5rf.js} +3 -8
- package/dist/chunks/{defaults.DpVH7vbg.js → defaults.B7q_naMc.js} +1 -1
- package/dist/chunks/{env.Dq0hM4Xv.js → env.D4Lgay0q.js} +1 -1
- package/dist/chunks/{execute.B3q-2LPV.js → execute.B7h3T_Hc.js} +104 -220
- package/dist/chunks/{git.DXfdBEfR.js → git.BVQ8w_Sw.js} +1 -3
- package/dist/chunks/{global.d.BNLIi6yo.d.ts → global.d.MAmajcmJ.d.ts} +2 -0
- package/dist/chunks/{globals.CI21aWXF.js → globals.DEHgCU4V.js} +5 -5
- package/dist/chunks/{index.Bter3jj9.js → index.BZ0g1JD2.js} +366 -628
- package/dist/chunks/{index.CbT4iuwc.js → index.BbB8_kAK.js} +22 -24
- package/dist/chunks/{index.JOzufsrU.js → index.CIyJn3t1.js} +37 -82
- package/dist/chunks/{index.DNgLEKsQ.js → index.CdQS2e2Q.js} +2 -2
- package/dist/chunks/{index.2jgTs_Q5.js → index.CmSc2RE5.js} +69 -107
- package/dist/chunks/{inspector.BFsh5KO0.js → inspector.C914Efll.js} +1 -1
- package/dist/chunks/{node.Be-ntJnD.js → node.fjCdwEIl.js} +1 -1
- package/dist/chunks/{reporters.d.Bt4IGtsa.d.ts → reporters.d.C1ogPriE.d.ts} +24 -4
- package/dist/chunks/{rpc.BKExFSRG.js → rpc.Iovn4oWe.js} +9 -19
- package/dist/chunks/{runBaseTests.B_M1TTsK.js → runBaseTests.Dd85QTll.js} +18 -31
- package/dist/chunks/{setup-common.CF-O-dZX.js → setup-common.Dd054P77.js} +15 -42
- package/dist/chunks/{typechecker.BgzF-6iO.js → typechecker.DRKU1-1g.js} +106 -186
- package/dist/chunks/{utils.DPCq3gzW.js → utils.CAioKnHs.js} +6 -14
- package/dist/chunks/{utils.BlI4TC7Y.js → utils.XdZDrNZV.js} +5 -13
- package/dist/chunks/{vi.pkoYCV6A.js → vi.bdSIJ99Y.js} +118 -267
- package/dist/chunks/{vite.d.B-Kx3KCF.d.ts → vite.d.DqE4-hhK.d.ts} +1 -1
- package/dist/chunks/{vm.DPYem2so.js → vm.BThCzidc.js} +98 -214
- package/dist/chunks/{worker.d.Bl1O4kuf.d.ts → worker.d.DvqK5Vmu.d.ts} +1 -1
- package/dist/chunks/{worker.d.BKbBp2ga.d.ts → worker.d.tQu2eJQy.d.ts} +3 -1
- package/dist/cli.js +4 -4
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +4 -4
- package/dist/config.js +2 -2
- package/dist/coverage.d.ts +2 -2
- package/dist/coverage.js +5 -5
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.js +5 -5
- package/dist/node.d.ts +7 -7
- package/dist/node.js +12 -14
- package/dist/reporters.d.ts +2 -2
- package/dist/reporters.js +4 -4
- package/dist/runners.d.ts +5 -2
- package/dist/runners.js +51 -80
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +36 -42
- package/dist/workers/forks.js +4 -4
- package/dist/workers/runVmTests.js +15 -21
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +6 -6
- package/dist/workers/vmThreads.js +6 -6
- package/dist/workers.d.ts +2 -2
- package/dist/workers.js +10 -10
- package/package.json +16 -14
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Task, TaskMeta, Suite, File, TaskResultPack, SequenceSetupFiles, SequenceHooks, CancelReason } from '@vitest/runner';
|
|
1
|
+
import { Task, TaskMeta, Suite, File, TestAnnotation, ImportDuration, TaskResultPack, TaskEventPack, SequenceSetupFiles, SequenceHooks, CancelReason } from '@vitest/runner';
|
|
2
2
|
import { b as Awaitable, U as UserConsoleLog, c as Arrayable$1, A as AfterSuiteRunMeta, L as LabelColor, f as EnvironmentOptions, P as ProvidedContext } from './environment.d.cL3nLXbE.js';
|
|
3
3
|
import { ParsedStack, TestError, SerializedError, ErrorWithDiff, Arrayable, Awaitable as Awaitable$1 } from '@vitest/utils';
|
|
4
4
|
import { Writable } from 'node:stream';
|
|
@@ -6,7 +6,7 @@ import { TransformResult as TransformResult$1, UserConfig as UserConfig$1, DepOp
|
|
|
6
6
|
import { Console } from 'node:console';
|
|
7
7
|
import { MockedModule } from '@vitest/mocker';
|
|
8
8
|
import { StackTraceParserOptions } from '@vitest/utils/source-map';
|
|
9
|
-
import { T as TestExecutionMethod } from './worker.d.
|
|
9
|
+
import { T as TestExecutionMethod } from './worker.d.tQu2eJQy.js';
|
|
10
10
|
import { a as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.D2ROskhv.js';
|
|
11
11
|
import { PrettyFormatOptions } from '@vitest/pretty-format';
|
|
12
12
|
import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
|
|
@@ -133,6 +133,10 @@ declare class TestCase extends ReportedTaskImplementation {
|
|
|
133
133
|
*/
|
|
134
134
|
result(): TestResult;
|
|
135
135
|
/**
|
|
136
|
+
* Test annotations added via the `task.annotate` API during the test execution.
|
|
137
|
+
*/
|
|
138
|
+
annotations(): ReadonlyArray<TestAnnotation>;
|
|
139
|
+
/**
|
|
136
140
|
* Useful information about the test like duration, memory usage, etc.
|
|
137
141
|
* Diagnostic is only available after the test has finished.
|
|
138
142
|
*/
|
|
@@ -373,6 +377,10 @@ interface ModuleDiagnostic {
|
|
|
373
377
|
* This value is only available if the test was executed with `logHeapUsage` flag.
|
|
374
378
|
*/
|
|
375
379
|
readonly heap: number | undefined;
|
|
380
|
+
/**
|
|
381
|
+
* The time spent importing every non-externalized dependency that Vitest has processed.
|
|
382
|
+
*/
|
|
383
|
+
readonly importDurations: Record<string, ImportDuration>;
|
|
376
384
|
}
|
|
377
385
|
|
|
378
386
|
type BuiltinPool = "browser" | "threads" | "forks" | "vmThreads" | "vmForks" | "typescript";
|
|
@@ -573,7 +581,7 @@ interface Reporter {
|
|
|
573
581
|
/**
|
|
574
582
|
* @deprecated use `onTestModuleQueued`, `onTestModuleStart`, `onTestModuleEnd`, `onTestCaseReady`, `onTestCaseResult` instead
|
|
575
583
|
*/
|
|
576
|
-
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
584
|
+
onTaskUpdate?: (packs: TaskResultPack[], events: TaskEventPack[]) => Awaitable<void>;
|
|
577
585
|
onTestRemoved?: (trigger?: string) => Awaitable<void>;
|
|
578
586
|
onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
579
587
|
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
@@ -615,6 +623,10 @@ interface Reporter {
|
|
|
615
623
|
*/
|
|
616
624
|
onTestCaseResult?: (testCase: TestCase) => Awaitable<void>;
|
|
617
625
|
/**
|
|
626
|
+
* Called when annotation is added via the `task.annotate` API.
|
|
627
|
+
*/
|
|
628
|
+
onTestCaseAnnotate?: (testCase: TestCase, annotation: TestAnnotation) => Awaitable<void>;
|
|
629
|
+
/**
|
|
618
630
|
* Called when test suite is ready to run.
|
|
619
631
|
* Called before the `beforeAll` hooks for the test are run.
|
|
620
632
|
*/
|
|
@@ -666,6 +678,7 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
666
678
|
protected getTestName(test: Task, separator?: string): string;
|
|
667
679
|
protected formatShortError(error: ErrorWithDiff): string;
|
|
668
680
|
protected getTestIndentation(_test: Task): string;
|
|
681
|
+
protected printAnnotations(test: TestCase, console: "log" | "error", padding?: number): void;
|
|
669
682
|
protected getDurationPrefix(task: Task): string;
|
|
670
683
|
onWatcherStart(files?: File[], errors?: unknown[]): void;
|
|
671
684
|
onWatcherRerun(files: string[], trigger?: string): void;
|
|
@@ -956,6 +969,7 @@ declare class GithubActionsReporter implements Reporter {
|
|
|
956
969
|
options: GithubActionsReporterOptions;
|
|
957
970
|
constructor(options?: GithubActionsReporterOptions);
|
|
958
971
|
onInit(ctx: Vitest): void;
|
|
972
|
+
onTestCaseAnnotate(testCase: TestCase, annotation: TestAnnotation): void;
|
|
959
973
|
onFinished(files?: File[], errors?: unknown[]): void;
|
|
960
974
|
}
|
|
961
975
|
|
|
@@ -1982,7 +1996,7 @@ interface InlineConfig {
|
|
|
1982
1996
|
maxConcurrency?: number;
|
|
1983
1997
|
/**
|
|
1984
1998
|
* Options for configuring cache policy.
|
|
1985
|
-
* @default { dir: 'node_modules/.vite/vitest' }
|
|
1999
|
+
* @default { dir: 'node_modules/.vite/vitest/{project-hash}' }
|
|
1986
2000
|
*/
|
|
1987
2001
|
cache?: false | {
|
|
1988
2002
|
/**
|
|
@@ -2140,6 +2154,12 @@ interface InlineConfig {
|
|
|
2140
2154
|
* @default false
|
|
2141
2155
|
*/
|
|
2142
2156
|
includeTaskLocation?: boolean;
|
|
2157
|
+
/**
|
|
2158
|
+
* Directory path for storing attachments created by `context.annotate`
|
|
2159
|
+
*
|
|
2160
|
+
* @default '.vitest-attachments'
|
|
2161
|
+
*/
|
|
2162
|
+
attachmentsDir?: string;
|
|
2143
2163
|
}
|
|
2144
2164
|
interface TypecheckConfig {
|
|
2145
2165
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getSafeTimers } from '@vitest/utils';
|
|
2
2
|
import { c as createBirpc } from './index.CJ0plNrh.js';
|
|
3
|
-
import { g as getWorkerState } from './utils.
|
|
3
|
+
import { g as getWorkerState } from './utils.XdZDrNZV.js';
|
|
4
4
|
|
|
5
5
|
const { get } = Reflect;
|
|
6
6
|
function withSafeTimers(fn) {
|
|
@@ -15,9 +15,7 @@ function withSafeTimers(fn) {
|
|
|
15
15
|
globalThis.clearTimeout = clearTimeout;
|
|
16
16
|
globalThis.setImmediate = setImmediate;
|
|
17
17
|
globalThis.clearImmediate = clearImmediate;
|
|
18
|
-
if (globalThis.process)
|
|
19
|
-
globalThis.process.nextTick = nextTick;
|
|
20
|
-
}
|
|
18
|
+
if (globalThis.process) globalThis.process.nextTick = nextTick;
|
|
21
19
|
const result = fn();
|
|
22
20
|
return result;
|
|
23
21
|
} finally {
|
|
@@ -25,18 +23,14 @@ function withSafeTimers(fn) {
|
|
|
25
23
|
globalThis.clearTimeout = currentClearTimeout;
|
|
26
24
|
globalThis.setImmediate = currentSetImmediate;
|
|
27
25
|
globalThis.clearImmediate = currentClearImmediate;
|
|
28
|
-
if (globalThis.process) {
|
|
29
|
-
nextTick
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
}
|
|
26
|
+
if (globalThis.process) nextTick(() => {
|
|
27
|
+
globalThis.process.nextTick = currentNextTick;
|
|
28
|
+
});
|
|
33
29
|
}
|
|
34
30
|
}
|
|
35
|
-
const promises = new Set();
|
|
31
|
+
const promises = /* @__PURE__ */ new Set();
|
|
36
32
|
async function rpcDone() {
|
|
37
|
-
if (!promises.size)
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
33
|
+
if (!promises.size) return;
|
|
40
34
|
const awaitable = Array.from(promises);
|
|
41
35
|
return Promise.all(awaitable);
|
|
42
36
|
}
|
|
@@ -53,13 +47,9 @@ function createRuntimeRpc(options) {
|
|
|
53
47
|
],
|
|
54
48
|
onTimeoutError(functionName, args) {
|
|
55
49
|
let message = `[vitest-worker]: Timeout calling "${functionName}"`;
|
|
56
|
-
if (functionName === "fetch" || functionName === "transform" || functionName === "resolveId") {
|
|
57
|
-
message += ` with "${JSON.stringify(args)}"`;
|
|
58
|
-
}
|
|
50
|
+
if (functionName === "fetch" || functionName === "transform" || functionName === "resolveId") message += ` with "${JSON.stringify(args)}"`;
|
|
59
51
|
// JSON.stringify cannot serialize Error instances
|
|
60
|
-
if (functionName === "onUnhandledError") {
|
|
61
|
-
message += ` with "${args[0]?.message || args[0]}"`;
|
|
62
|
-
}
|
|
52
|
+
if (functionName === "onUnhandledError") message += ` with "${args[0]?.message || args[0]}"`;
|
|
63
53
|
throw new Error(message);
|
|
64
54
|
},
|
|
65
55
|
...options
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
2
|
import { startTests, collectTests } from '@vitest/runner';
|
|
3
|
-
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.
|
|
4
|
-
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './setup-common.
|
|
5
|
-
import { a as globalExpect, v as vi } from './vi.
|
|
6
|
-
import { c as closeInspector } from './inspector.
|
|
3
|
+
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.BbB8_kAK.js';
|
|
4
|
+
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './setup-common.Dd054P77.js';
|
|
5
|
+
import { a as globalExpect, v as vi } from './vi.bdSIJ99Y.js';
|
|
6
|
+
import { c as closeInspector } from './inspector.C914Efll.js';
|
|
7
7
|
import { createRequire } from 'node:module';
|
|
8
8
|
import timers from 'node:timers';
|
|
9
9
|
import timersPromises from 'node:timers/promises';
|
|
@@ -11,15 +11,15 @@ import util from 'node:util';
|
|
|
11
11
|
import { getSafeTimers } from '@vitest/utils';
|
|
12
12
|
import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
|
|
13
13
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
14
|
-
import { V as VitestIndex } from './index.
|
|
15
|
-
import { g as getWorkerState, r as resetModules } from './utils.
|
|
14
|
+
import { V as VitestIndex } from './index.CdQS2e2Q.js';
|
|
15
|
+
import { g as getWorkerState, r as resetModules } from './utils.XdZDrNZV.js';
|
|
16
16
|
import 'chai';
|
|
17
17
|
import 'node:path';
|
|
18
18
|
import '../path.js';
|
|
19
19
|
import 'node:url';
|
|
20
|
-
import './rpc.
|
|
20
|
+
import './rpc.Iovn4oWe.js';
|
|
21
21
|
import './index.CJ0plNrh.js';
|
|
22
|
-
import './coverage.
|
|
22
|
+
import './coverage.DVF1vEu8.js';
|
|
23
23
|
import '@vitest/snapshot';
|
|
24
24
|
import '@vitest/expect';
|
|
25
25
|
import '@vitest/runner/utils';
|
|
@@ -27,8 +27,8 @@ import './_commonjsHelpers.BFTU3MAI.js';
|
|
|
27
27
|
import '@vitest/utils/error';
|
|
28
28
|
import '@vitest/spy';
|
|
29
29
|
import '@vitest/utils/source-map';
|
|
30
|
-
import './date.
|
|
31
|
-
import './benchmark.
|
|
30
|
+
import './date.Bq6ZW5rf.js';
|
|
31
|
+
import './benchmark.CYdenmiT.js';
|
|
32
32
|
import 'expect-type';
|
|
33
33
|
|
|
34
34
|
// this should only be used in Node
|
|
@@ -40,12 +40,8 @@ async function setupGlobalEnv(config, { environment }, executor) {
|
|
|
40
40
|
enumerable: false
|
|
41
41
|
});
|
|
42
42
|
const state = getWorkerState();
|
|
43
|
-
if (!state.config.snapshotOptions.snapshotEnvironment)
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
if (globalSetup) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
43
|
+
if (!state.config.snapshotOptions.snapshotEnvironment) state.config.snapshotOptions.snapshotEnvironment = await resolveSnapshotEnvironment(config, executor);
|
|
44
|
+
if (globalSetup) return;
|
|
49
45
|
globalSetup = true;
|
|
50
46
|
if (environment.transformMode === "web") {
|
|
51
47
|
const _require = createRequire(import.meta.url);
|
|
@@ -59,9 +55,7 @@ async function setupGlobalEnv(config, { environment }, executor) {
|
|
|
59
55
|
_require.extensions[`.${type}`] = resolveAsset;
|
|
60
56
|
});
|
|
61
57
|
process.env.SSR = "";
|
|
62
|
-
} else
|
|
63
|
-
process.env.SSR = "1";
|
|
64
|
-
}
|
|
58
|
+
} else process.env.SSR = "1";
|
|
65
59
|
// @ts-expect-error not typed global for patched timers
|
|
66
60
|
globalThis.__vitest_required__ = {
|
|
67
61
|
util,
|
|
@@ -69,9 +63,7 @@ async function setupGlobalEnv(config, { environment }, executor) {
|
|
|
69
63
|
timersPromises
|
|
70
64
|
};
|
|
71
65
|
installSourcemapsSupport({ getSourceMap: (source) => state.moduleCache.getSourceMap(source) });
|
|
72
|
-
if (!config.disableConsoleIntercept)
|
|
73
|
-
await setupConsoleLogSpy();
|
|
74
|
-
}
|
|
66
|
+
if (!config.disableConsoleIntercept) await setupConsoleLogSpy();
|
|
75
67
|
}
|
|
76
68
|
function resolveCss(mod) {
|
|
77
69
|
mod.exports = "";
|
|
@@ -80,7 +72,7 @@ function resolveAsset(mod, url) {
|
|
|
80
72
|
mod.exports = url;
|
|
81
73
|
}
|
|
82
74
|
async function setupConsoleLogSpy() {
|
|
83
|
-
const { createCustomConsole } = await import('./console.
|
|
75
|
+
const { createCustomConsole } = await import('./console.CtFJOzRO.js');
|
|
84
76
|
globalThis.console = createCustomConsole();
|
|
85
77
|
}
|
|
86
78
|
async function withEnv({ environment }, options, fn) {
|
|
@@ -106,9 +98,7 @@ async function run(method, files, config, environment, executor) {
|
|
|
106
98
|
const isolate = isIsolatedThreads || isIsolatedForks;
|
|
107
99
|
await setupGlobalEnv(config, environment, executor);
|
|
108
100
|
await startCoverageInsideWorker(config.coverage, executor, { isolate });
|
|
109
|
-
if (config.chaiConfig)
|
|
110
|
-
setupChaiConfig(config.chaiConfig);
|
|
111
|
-
}
|
|
101
|
+
if (config.chaiConfig) setupChaiConfig(config.chaiConfig);
|
|
112
102
|
const runner = await resolveTestRunner(config, executor);
|
|
113
103
|
workerState.onCancel.then((reason) => {
|
|
114
104
|
closeInspector(config);
|
|
@@ -124,11 +114,8 @@ async function run(method, files, config, environment, executor) {
|
|
|
124
114
|
resetModules(workerState.moduleCache, true);
|
|
125
115
|
}
|
|
126
116
|
workerState.filepath = file.filepath;
|
|
127
|
-
if (method === "run")
|
|
128
|
-
|
|
129
|
-
} else {
|
|
130
|
-
await collectTests([file], runner);
|
|
131
|
-
}
|
|
117
|
+
if (method === "run") await startTests([file], runner);
|
|
118
|
+
else await collectTests([file], runner);
|
|
132
119
|
// reset after tests, because user might call `vi.setConfig` in setupFile
|
|
133
120
|
vi.resetConfig();
|
|
134
121
|
// mocks should not affect different files
|
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
import { r as resolveCoverageProviderModule } from './coverage.
|
|
1
|
+
import { r as resolveCoverageProviderModule } from './coverage.DVF1vEu8.js';
|
|
2
2
|
import { addSerializer } from '@vitest/snapshot';
|
|
3
3
|
import { setSafeTimers } from '@vitest/utils';
|
|
4
4
|
|
|
5
5
|
async function startCoverageInsideWorker(options, loader, runtimeOptions) {
|
|
6
6
|
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
7
|
-
if (coverageModule)
|
|
8
|
-
return coverageModule.startCoverage?.(runtimeOptions);
|
|
9
|
-
}
|
|
7
|
+
if (coverageModule) return coverageModule.startCoverage?.(runtimeOptions);
|
|
10
8
|
return null;
|
|
11
9
|
}
|
|
12
10
|
async function takeCoverageInsideWorker(options, loader) {
|
|
13
11
|
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
14
|
-
if (coverageModule) {
|
|
15
|
-
return coverageModule.takeCoverage?.({ moduleExecutionInfo: loader.moduleExecutionInfo });
|
|
16
|
-
}
|
|
12
|
+
if (coverageModule) return coverageModule.takeCoverage?.({ moduleExecutionInfo: loader.moduleExecutionInfo });
|
|
17
13
|
return null;
|
|
18
14
|
}
|
|
19
15
|
async function stopCoverageInsideWorker(options, loader, runtimeOptions) {
|
|
20
16
|
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
21
|
-
if (coverageModule)
|
|
22
|
-
return coverageModule.stopCoverage?.(runtimeOptions);
|
|
23
|
-
}
|
|
17
|
+
if (coverageModule) return coverageModule.stopCoverage?.(runtimeOptions);
|
|
24
18
|
return null;
|
|
25
19
|
}
|
|
26
20
|
|
|
@@ -28,57 +22,36 @@ let globalSetup = false;
|
|
|
28
22
|
async function setupCommonEnv(config) {
|
|
29
23
|
setupDefines(config.defines);
|
|
30
24
|
setupEnv(config.env);
|
|
31
|
-
if (globalSetup)
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
25
|
+
if (globalSetup) return;
|
|
34
26
|
globalSetup = true;
|
|
35
27
|
setSafeTimers();
|
|
36
|
-
if (config.globals)
|
|
37
|
-
(await import('./globals.CI21aWXF.js')).registerApiGlobally();
|
|
38
|
-
}
|
|
28
|
+
if (config.globals) (await import('./globals.DEHgCU4V.js')).registerApiGlobally();
|
|
39
29
|
}
|
|
40
30
|
function setupDefines(defines) {
|
|
41
|
-
for (const key in defines)
|
|
42
|
-
globalThis[key] = defines[key];
|
|
43
|
-
}
|
|
31
|
+
for (const key in defines) globalThis[key] = defines[key];
|
|
44
32
|
}
|
|
45
33
|
function setupEnv(env) {
|
|
46
|
-
if (typeof process === "undefined")
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
34
|
+
if (typeof process === "undefined") return;
|
|
49
35
|
// same boolean-to-string assignment as VitestPlugin.configResolved
|
|
50
36
|
const { PROD, DEV,...restEnvs } = env;
|
|
51
37
|
process.env.PROD = PROD ? "1" : "";
|
|
52
38
|
process.env.DEV = DEV ? "1" : "";
|
|
53
|
-
for (const key in restEnvs)
|
|
54
|
-
process.env[key] = env[key];
|
|
55
|
-
}
|
|
39
|
+
for (const key in restEnvs) process.env[key] = env[key];
|
|
56
40
|
}
|
|
57
41
|
async function loadDiffConfig(config, executor) {
|
|
58
|
-
if (typeof config.diff === "object")
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
if (typeof config.diff !== "string") {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
42
|
+
if (typeof config.diff === "object") return config.diff;
|
|
43
|
+
if (typeof config.diff !== "string") return;
|
|
64
44
|
const diffModule = await executor.executeId(config.diff);
|
|
65
|
-
if (diffModule && typeof diffModule.default === "object" && diffModule.default != null)
|
|
66
|
-
|
|
67
|
-
} else {
|
|
68
|
-
throw new Error(`invalid diff config file ${config.diff}. Must have a default export with config object`);
|
|
69
|
-
}
|
|
45
|
+
if (diffModule && typeof diffModule.default === "object" && diffModule.default != null) return diffModule.default;
|
|
46
|
+
else throw new Error(`invalid diff config file ${config.diff}. Must have a default export with config object`);
|
|
70
47
|
}
|
|
71
48
|
async function loadSnapshotSerializers(config, executor) {
|
|
72
49
|
const files = config.snapshotSerializers;
|
|
73
50
|
const snapshotSerializers = await Promise.all(files.map(async (file) => {
|
|
74
51
|
const mo = await executor.executeId(file);
|
|
75
|
-
if (!mo || typeof mo.default !== "object" || mo.default === null) {
|
|
76
|
-
throw new Error(`invalid snapshot serializer file ${file}. Must export a default object`);
|
|
77
|
-
}
|
|
52
|
+
if (!mo || typeof mo.default !== "object" || mo.default === null) throw new Error(`invalid snapshot serializer file ${file}. Must export a default object`);
|
|
78
53
|
const config = mo.default;
|
|
79
|
-
if (typeof config.test !== "function" || typeof config.serialize !== "function" && typeof config.print !== "function") {
|
|
80
|
-
throw new TypeError(`invalid snapshot serializer in ${file}. Must have a 'test' method along with either a 'serialize' or 'print' method.`);
|
|
81
|
-
}
|
|
54
|
+
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.`);
|
|
82
55
|
return config;
|
|
83
56
|
}));
|
|
84
57
|
snapshotSerializers.forEach((serializer) => addSerializer(serializer));
|