vitest 2.0.3 → 2.0.5
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 +21 -0
- package/dist/browser.d.ts +21 -42
- package/dist/browser.js +5 -5
- package/dist/{vendor/base.CC6UHsNs.js → chunks/base.CC5R_kgU.js} +3 -3
- package/dist/{vendor/base.CTYV4Gnz.js → chunks/base.DSsbfkDg.js} +5 -4
- package/dist/{vendor/benchmark.B6pblCp2.js → chunks/benchmark.DDmpNjj-.js} +1 -1
- package/dist/chunks/benchmark.puBFxyfE.d.ts +22 -0
- package/dist/{vendor/cac.DUiZvzF_.js → chunks/cac.DGgmCKmU.js} +18 -21
- package/dist/{vendor/cli-api.CsgSG1Ir.js → chunks/cli-api.OKfd3qJ0.js} +666 -487
- package/dist/chunks/config.DCnyCTbs.d.ts +203 -0
- package/dist/chunks/{runtime-console.C2L2zykk.js → console.Bgn7_A1x.js} +11 -14
- package/dist/{vendor/constants.CsnA4eRy.js → chunks/constants.CaAN7icJ.js} +1 -3
- package/dist/{vendor/coverage.BhYSDdTT.js → chunks/coverage.CqfT4xaf.js} +4 -7
- package/dist/chunks/{browser-creator.CyaOd8pl.js → creator.a3OfuIEW.js} +8 -8
- package/dist/{vendor/env.2ltrQNq0.js → chunks/env.BU041cs9.js} +2 -3
- package/dist/chunks/environment.0M5R1SX_.d.ts +173 -0
- package/dist/{vendor/execute.Dx503nGn.js → chunks/execute.Cjlr2CRw.js} +28 -20
- package/dist/chunks/globals.BliuJFNR.js +31 -0
- package/dist/{vendor/index.Hqvcg1pf.js → chunks/index.BfeNhc0N.js} +43 -43
- package/dist/{vendor/index.D6GZqexG.js → chunks/index.CM5UI-4O.js} +2 -2
- package/dist/{vendor/index.BJmtb_7W.js → chunks/index.DYufA6CZ.js} +2 -2
- package/dist/{vendor/index.BCwvoAaf.js → chunks/index.JbiJutJ_.js} +516 -258
- package/dist/{vendor/index.CROIsoiT.js → chunks/index.R1VjssW9.js} +11 -12
- package/dist/{vendor/index.D4nqnQWz.js → chunks/index.lVXYBqEP.js} +1 -18
- package/dist/{vendor/inspector.-FCQUzqR.js → chunks/inspector.70d6emsh.js} +4 -5
- package/dist/chunks/{environments-node.XE5FbRPQ.js → node.DS3zEPa7.js} +2 -2
- package/dist/{reporters-BECoY4-b.d.ts → chunks/reporters.C_zwCd4j.d.ts} +850 -1003
- package/dist/{vendor/rpc.BGx7q_k2.js → chunks/rpc.B7Mfb-Yf.js} +3 -5
- package/dist/{vendor/run-once.Db8Hgq9X.js → chunks/run-once.Sxe67Wng.js} +1 -1
- package/dist/chunks/{runtime-runBaseTests.hkIOeriM.js → runBaseTests.CyvqmuC9.js} +35 -27
- package/dist/{vendor/setup-common.yHaxjRhz.js → chunks/setup-common.CNzatKMx.js} +2 -2
- package/dist/{suite-BWgaIsVn.d.ts → chunks/suite.CcK46U-P.d.ts} +1 -1
- package/dist/{vendor/tasks.DhVtQBtW.js → chunks/tasks.BZnCS9aT.js} +2 -3
- package/dist/{vendor/utils.DkxLWvS1.js → chunks/utils.C3_cBsyn.js} +3 -4
- package/dist/{vendor/global.7bFbnyXl.js → chunks/utils.Ck2hJTRs.js} +1 -1
- package/dist/{vendor/utils.DyTe1Nxn.js → chunks/utils.DpP_sDwr.js} +8 -21
- package/dist/{vendor/vi.DXACdGTu.js → chunks/vi.fiQ7lMRF.js} +13 -18
- package/dist/{vendor/vm.D1T5Rxan.js → chunks/vm.DcSuuaHr.js} +40 -68
- package/dist/chunks/worker.C5iHKIaJ.d.ts +144 -0
- package/dist/chunks/worker.DKkAC4Qw.d.ts +8 -0
- package/dist/cli.js +3 -3
- package/dist/config.cjs +6 -9
- package/dist/config.d.ts +10 -8
- package/dist/config.js +6 -9
- package/dist/coverage.d.ts +10 -8
- package/dist/coverage.js +11 -7
- package/dist/environments.d.ts +3 -19
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +8 -17
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +267 -34
- package/dist/index.js +12 -12
- package/dist/node.d.ts +15 -9
- package/dist/node.js +16 -19
- package/dist/reporters.d.ts +10 -8
- package/dist/reporters.js +12 -15
- package/dist/runners.d.ts +7 -19
- package/dist/runners.js +12 -13
- package/dist/snapshot.js +3 -3
- package/dist/suite.d.ts +2 -16
- package/dist/suite.js +4 -4
- package/dist/worker.js +7 -8
- package/dist/workers/forks.js +5 -5
- package/dist/workers/runVmTests.js +32 -23
- package/dist/workers/threads.js +5 -5
- package/dist/workers/vmForks.js +8 -8
- package/dist/workers/vmThreads.js +8 -8
- package/dist/workers.d.ts +13 -8
- package/dist/workers.js +13 -13
- package/package.json +15 -15
- package/dist/chunks/integrations-globals.CzYWb38r.js +0 -31
- /package/dist/{vendor → chunks}/_commonjsHelpers.BFTU3MAI.js +0 -0
- /package/dist/{vendor → chunks}/date.W2xKR2qe.js +0 -0
- /package/dist/chunks/{node-git.ZtkbKc8u.js → git.ZtkbKc8u.js} +0 -0
- /package/dist/{vendor → chunks}/index.BMmMjLIQ.js +0 -0
- /package/dist/{vendor → chunks}/index.BpSiYbpB.js +0 -0
- /package/dist/chunks/{install-pkg.DNUmWFkO.js → index.DNUmWFkO.js} +0 -0
- /package/dist/{vendor → chunks}/spy.Cf_4R5Oe.js +0 -0
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { getSafeTimers } from '@vitest/utils';
|
|
2
2
|
import { c as createBirpc } from './index.BpSiYbpB.js';
|
|
3
|
-
import { g as getWorkerState } from './
|
|
3
|
+
import { g as getWorkerState } from './utils.Ck2hJTRs.js';
|
|
4
4
|
|
|
5
5
|
const { get } = Reflect;
|
|
6
6
|
function withSafeTimers(fn) {
|
|
7
|
-
var _a;
|
|
8
7
|
const { setTimeout, clearTimeout, nextTick, setImmediate, clearImmediate } = getSafeTimers();
|
|
9
8
|
const currentSetTimeout = globalThis.setTimeout;
|
|
10
9
|
const currentClearTimeout = globalThis.clearTimeout;
|
|
11
10
|
const currentSetImmediate = globalThis.setImmediate;
|
|
12
11
|
const currentClearImmediate = globalThis.clearImmediate;
|
|
13
|
-
const currentNextTick =
|
|
12
|
+
const currentNextTick = globalThis.process?.nextTick;
|
|
14
13
|
try {
|
|
15
14
|
globalThis.setTimeout = setTimeout;
|
|
16
15
|
globalThis.clearTimeout = clearTimeout;
|
|
@@ -60,13 +59,12 @@ function createRuntimeRpc(options) {
|
|
|
60
59
|
"onCancel"
|
|
61
60
|
],
|
|
62
61
|
onTimeoutError(functionName, args) {
|
|
63
|
-
var _a;
|
|
64
62
|
let message = `[vitest-worker]: Timeout calling "${functionName}"`;
|
|
65
63
|
if (functionName === "fetch" || functionName === "transform" || functionName === "resolveId") {
|
|
66
64
|
message += ` with "${JSON.stringify(args)}"`;
|
|
67
65
|
}
|
|
68
66
|
if (functionName === "onUnhandledError") {
|
|
69
|
-
message += ` with "${
|
|
67
|
+
message += ` with "${args[0]?.message || args[0]}"`;
|
|
70
68
|
}
|
|
71
69
|
throw new Error(message);
|
|
72
70
|
},
|
|
@@ -3,36 +3,37 @@ import { startTests, collectTests } from '@vitest/runner';
|
|
|
3
3
|
import 'pathe';
|
|
4
4
|
import '@vitest/runner/utils';
|
|
5
5
|
import { getSafeTimers } from '@vitest/utils';
|
|
6
|
-
import { g as getWorkerState } from '
|
|
7
|
-
import '
|
|
8
|
-
import { a as globalExpect, r as resetModules, v as vi } from '
|
|
9
|
-
import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from '
|
|
10
|
-
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '
|
|
6
|
+
import { g as getWorkerState } from './utils.Ck2hJTRs.js';
|
|
7
|
+
import './env.BU041cs9.js';
|
|
8
|
+
import { a as globalExpect, r as resetModules, v as vi } from './vi.fiQ7lMRF.js';
|
|
9
|
+
import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from './coverage.CqfT4xaf.js';
|
|
10
|
+
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.R1VjssW9.js';
|
|
11
11
|
import { createRequire } from 'node:module';
|
|
12
12
|
import util from 'node:util';
|
|
13
13
|
import timers from 'node:timers';
|
|
14
14
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
15
|
+
import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
|
|
16
|
+
import { V as VitestIndex } from './index.BfeNhc0N.js';
|
|
17
|
+
import { s as setupCommonEnv } from './setup-common.CNzatKMx.js';
|
|
18
|
+
import { c as closeInspector } from './inspector.70d6emsh.js';
|
|
18
19
|
import 'std-env';
|
|
19
20
|
import 'chai';
|
|
20
|
-
import '
|
|
21
|
+
import './_commonjsHelpers.BFTU3MAI.js';
|
|
21
22
|
import '@vitest/expect';
|
|
22
23
|
import '@vitest/snapshot';
|
|
23
24
|
import '@vitest/utils/error';
|
|
24
|
-
import '
|
|
25
|
+
import './tasks.BZnCS9aT.js';
|
|
25
26
|
import '@vitest/utils/source-map';
|
|
26
|
-
import '
|
|
27
|
-
import '
|
|
27
|
+
import './base.DSsbfkDg.js';
|
|
28
|
+
import './date.W2xKR2qe.js';
|
|
28
29
|
import '@vitest/spy';
|
|
29
30
|
import '../path.js';
|
|
30
31
|
import 'node:url';
|
|
31
|
-
import '
|
|
32
|
-
import '
|
|
33
|
-
import '
|
|
34
|
-
import '
|
|
35
|
-
import '
|
|
32
|
+
import './rpc.B7Mfb-Yf.js';
|
|
33
|
+
import './index.BpSiYbpB.js';
|
|
34
|
+
import './benchmark.DDmpNjj-.js';
|
|
35
|
+
import './index.DYufA6CZ.js';
|
|
36
|
+
import './run-once.Sxe67Wng.js';
|
|
36
37
|
|
|
37
38
|
let globalSetup = false;
|
|
38
39
|
async function setupGlobalEnv(config, { environment }, executor) {
|
|
@@ -51,10 +52,13 @@ async function setupGlobalEnv(config, { environment }, executor) {
|
|
|
51
52
|
globalSetup = true;
|
|
52
53
|
if (environment.transformMode === "web") {
|
|
53
54
|
const _require = createRequire(import.meta.url);
|
|
54
|
-
_require.extensions[".css"] =
|
|
55
|
-
_require.extensions[".scss"] =
|
|
56
|
-
_require.extensions[".sass"] =
|
|
57
|
-
_require.extensions[".less"] =
|
|
55
|
+
_require.extensions[".css"] = resolveCss;
|
|
56
|
+
_require.extensions[".scss"] = resolveCss;
|
|
57
|
+
_require.extensions[".sass"] = resolveCss;
|
|
58
|
+
_require.extensions[".less"] = resolveCss;
|
|
59
|
+
KNOWN_ASSET_TYPES.forEach((type) => {
|
|
60
|
+
_require.extensions[`.${type}`] = resolveAsset;
|
|
61
|
+
});
|
|
58
62
|
process.env.SSR = "";
|
|
59
63
|
} else {
|
|
60
64
|
process.env.SSR = "1";
|
|
@@ -70,8 +74,14 @@ async function setupGlobalEnv(config, { environment }, executor) {
|
|
|
70
74
|
await setupConsoleLogSpy();
|
|
71
75
|
}
|
|
72
76
|
}
|
|
77
|
+
function resolveCss(mod) {
|
|
78
|
+
mod.exports = "";
|
|
79
|
+
}
|
|
80
|
+
function resolveAsset(mod, url) {
|
|
81
|
+
mod.exports = url;
|
|
82
|
+
}
|
|
73
83
|
async function setupConsoleLogSpy() {
|
|
74
|
-
const { createCustomConsole } = await import('./
|
|
84
|
+
const { createCustomConsole } = await import('./console.Bgn7_A1x.js');
|
|
75
85
|
globalThis.console = createCustomConsole();
|
|
76
86
|
}
|
|
77
87
|
async function withEnv({ environment }, options, fn) {
|
|
@@ -98,9 +108,8 @@ async function run(method, files, config, environment, executor) {
|
|
|
98
108
|
}
|
|
99
109
|
const runner = await resolveTestRunner(config, executor);
|
|
100
110
|
workerState.onCancel.then((reason) => {
|
|
101
|
-
var _a;
|
|
102
111
|
closeInspector(config);
|
|
103
|
-
|
|
112
|
+
runner.onCancel?.(reason);
|
|
104
113
|
});
|
|
105
114
|
workerState.durations.prepare = performance.now() - workerState.durations.prepare;
|
|
106
115
|
workerState.durations.environment = performance.now();
|
|
@@ -108,11 +117,10 @@ async function run(method, files, config, environment, executor) {
|
|
|
108
117
|
environment,
|
|
109
118
|
environment.options || config.environmentOptions || {},
|
|
110
119
|
async () => {
|
|
111
|
-
var _a, _b, _c, _d;
|
|
112
120
|
workerState.durations.environment = performance.now() - workerState.durations.environment;
|
|
113
121
|
for (const file of files) {
|
|
114
|
-
const isIsolatedThreads = config.pool === "threads" && (
|
|
115
|
-
const isIsolatedForks = config.pool === "forks" && (
|
|
122
|
+
const isIsolatedThreads = config.pool === "threads" && (config.poolOptions?.threads?.isolate ?? true);
|
|
123
|
+
const isIsolatedForks = config.pool === "forks" && (config.poolOptions?.forks?.isolate ?? true);
|
|
116
124
|
if (isIsolatedThreads || isIsolatedForks) {
|
|
117
125
|
workerState.mockMap.clear();
|
|
118
126
|
resetModules(workerState.moduleCache, true);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { setSafeTimers } from '@vitest/utils';
|
|
2
2
|
import { addSerializer } from '@vitest/snapshot';
|
|
3
|
-
import { r as resetRunOnceCounter } from './run-once.
|
|
3
|
+
import { r as resetRunOnceCounter } from './run-once.Sxe67Wng.js';
|
|
4
4
|
|
|
5
5
|
let globalSetup = false;
|
|
6
6
|
async function setupCommonEnv(config) {
|
|
@@ -13,7 +13,7 @@ async function setupCommonEnv(config) {
|
|
|
13
13
|
globalSetup = true;
|
|
14
14
|
setSafeTimers();
|
|
15
15
|
if (config.globals) {
|
|
16
|
-
(await import('
|
|
16
|
+
(await import('./globals.BliuJFNR.js')).registerApiGlobally();
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
function setupDefines(defines) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Custom } from '@vitest/runner';
|
|
2
2
|
import '@vitest/runner/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { b as BenchFunction, c as BenchmarkAPI } from './benchmark.puBFxyfE.js';
|
|
4
4
|
import { Options } from 'tinybench';
|
|
5
5
|
|
|
6
6
|
declare function getBenchOptions(key: Custom): Options;
|
|
@@ -3,9 +3,8 @@ import '@vitest/utils';
|
|
|
3
3
|
|
|
4
4
|
function hasFailedSnapshot(suite) {
|
|
5
5
|
return getTests(suite).some((s) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
(e) => typeof (e == null ? void 0 : e.message) === "string" && e.message.match(/Snapshot .* mismatched/)
|
|
6
|
+
return s.result?.errors?.some(
|
|
7
|
+
(e) => typeof e?.message === "string" && e.message.match(/Snapshot .* mismatched/)
|
|
9
8
|
);
|
|
10
9
|
});
|
|
11
10
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { parseRegexp } from '@vitest/utils';
|
|
2
2
|
|
|
3
|
-
var _a, _b;
|
|
4
3
|
const REGEXP_WRAP_PREFIX = "$$vitest:";
|
|
5
|
-
const processSend =
|
|
6
|
-
const processOn =
|
|
4
|
+
const processSend = process.send?.bind(process);
|
|
5
|
+
const processOn = process.on?.bind(process);
|
|
7
6
|
function createThreadsRpcOptions({
|
|
8
7
|
port
|
|
9
8
|
}) {
|
|
@@ -25,7 +24,7 @@ function createForksRpcOptions(nodeV8) {
|
|
|
25
24
|
},
|
|
26
25
|
on(fn) {
|
|
27
26
|
processOn("message", (message, ...extras) => {
|
|
28
|
-
if (message
|
|
27
|
+
if (message?.__tinypool_worker_message__) {
|
|
29
28
|
return;
|
|
30
29
|
}
|
|
31
30
|
return fn(message, ...extras);
|
|
@@ -17,7 +17,7 @@ function provideWorkerState(context, state) {
|
|
|
17
17
|
}
|
|
18
18
|
function getCurrentEnvironment() {
|
|
19
19
|
const state = getWorkerState();
|
|
20
|
-
return state
|
|
20
|
+
return state?.environment.name;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export { getCurrentEnvironment as a, getWorkerState as g, provideWorkerState as p };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isAbsolute, relative, dirname, basename } from 'pathe';
|
|
2
2
|
import c from 'tinyrainbow';
|
|
3
|
-
import { a as slash } from './base.
|
|
3
|
+
import { a as slash } from './base.DSsbfkDg.js';
|
|
4
4
|
|
|
5
5
|
const F_RIGHT = "\u2192";
|
|
6
6
|
const F_DOWN = "\u2193";
|
|
@@ -43,8 +43,7 @@ const taskFail = c.red(F_CROSS);
|
|
|
43
43
|
const suiteFail = c.red(F_POINTER);
|
|
44
44
|
const pending = c.gray("\xB7");
|
|
45
45
|
function getCols(delta = 0) {
|
|
46
|
-
|
|
47
|
-
let length = (_a = process.stdout) == null ? void 0 : _a.columns;
|
|
46
|
+
let length = process.stdout?.columns;
|
|
48
47
|
if (!length || Number.isNaN(length)) {
|
|
49
48
|
length = 30;
|
|
50
49
|
}
|
|
@@ -67,12 +66,11 @@ function divider(text, left, right) {
|
|
|
67
66
|
return F_LONG_DASH.repeat(cols);
|
|
68
67
|
}
|
|
69
68
|
function formatTestPath(root, path) {
|
|
70
|
-
var _a;
|
|
71
69
|
if (isAbsolute(path)) {
|
|
72
70
|
path = relative(root, path);
|
|
73
71
|
}
|
|
74
72
|
const dir = dirname(path);
|
|
75
|
-
const ext =
|
|
73
|
+
const ext = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)?.[0] || "";
|
|
76
74
|
const base = basename(path, ext);
|
|
77
75
|
return slash(c.dim(`${dir}/`) + c.bold(base)) + c.dim(ext);
|
|
78
76
|
}
|
|
@@ -124,23 +122,14 @@ function renderSnapshotSummary(rootDir, snapshots) {
|
|
|
124
122
|
return summary;
|
|
125
123
|
}
|
|
126
124
|
function countTestErrors(tasks) {
|
|
127
|
-
return tasks.reduce((c2, i) =>
|
|
128
|
-
var _a, _b;
|
|
129
|
-
return c2 + (((_b = (_a = i.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.length) || 0);
|
|
130
|
-
}, 0);
|
|
125
|
+
return tasks.reduce((c2, i) => c2 + (i.result?.errors?.length || 0), 0);
|
|
131
126
|
}
|
|
132
127
|
function getStateString(tasks, name = "tests", showTotal = true) {
|
|
133
128
|
if (tasks.length === 0) {
|
|
134
129
|
return c.dim(`no ${name}`);
|
|
135
130
|
}
|
|
136
|
-
const passed = tasks.filter((i) =>
|
|
137
|
-
|
|
138
|
-
return ((_a = i.result) == null ? void 0 : _a.state) === "pass";
|
|
139
|
-
});
|
|
140
|
-
const failed = tasks.filter((i) => {
|
|
141
|
-
var _a;
|
|
142
|
-
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
143
|
-
});
|
|
131
|
+
const passed = tasks.filter((i) => i.result?.state === "pass");
|
|
132
|
+
const failed = tasks.filter((i) => i.result?.state === "fail");
|
|
144
133
|
const skipped2 = tasks.filter((i) => i.mode === "skip");
|
|
145
134
|
const todo = tasks.filter((i) => i.mode === "todo");
|
|
146
135
|
return [
|
|
@@ -151,7 +140,6 @@ function getStateString(tasks, name = "tests", showTotal = true) {
|
|
|
151
140
|
].filter(Boolean).join(c.dim(" | ")) + (showTotal ? c.gray(` (${tasks.length})`) : "");
|
|
152
141
|
}
|
|
153
142
|
function getStateSymbol(task) {
|
|
154
|
-
var _a;
|
|
155
143
|
if (task.mode === "skip" || task.mode === "todo") {
|
|
156
144
|
return skipped;
|
|
157
145
|
}
|
|
@@ -170,7 +158,7 @@ function getStateSymbol(task) {
|
|
|
170
158
|
return c.yellow(spinner());
|
|
171
159
|
}
|
|
172
160
|
if (task.result.state === "pass") {
|
|
173
|
-
return
|
|
161
|
+
return task.meta?.benchmark ? benchmarkPass : testPass;
|
|
174
162
|
}
|
|
175
163
|
if (task.result.state === "fail") {
|
|
176
164
|
return task.type === "suite" ? suiteFail : taskFail;
|
|
@@ -178,8 +166,7 @@ function getStateSymbol(task) {
|
|
|
178
166
|
return " ";
|
|
179
167
|
}
|
|
180
168
|
function getHookStateSymbol(task, hookName) {
|
|
181
|
-
|
|
182
|
-
const state = (_b = (_a = task.result) == null ? void 0 : _a.hooks) == null ? void 0 : _b[hookName];
|
|
169
|
+
const state = task.result?.hooks?.[hookName];
|
|
183
170
|
if (state && state === "run") {
|
|
184
171
|
let spinnerMap2 = hookSpinnerMap.get(task);
|
|
185
172
|
if (!spinnerMap2) {
|
|
@@ -5,13 +5,13 @@ import { stripSnapshotIndentation, addSerializer, SnapshotClient } from '@vitest
|
|
|
5
5
|
import { getNames } from '@vitest/runner/utils';
|
|
6
6
|
import '@vitest/utils/error';
|
|
7
7
|
import { getCurrentTest } from '@vitest/runner';
|
|
8
|
-
import { g as getTestName } from './tasks.
|
|
9
|
-
import { g as getWorkerState, a as getCurrentEnvironment } from './
|
|
8
|
+
import { g as getTestName } from './tasks.BZnCS9aT.js';
|
|
9
|
+
import { g as getWorkerState, a as getCurrentEnvironment } from './utils.Ck2hJTRs.js';
|
|
10
10
|
import { getSafeTimers, assertTypes, createSimpleStackTrace } from '@vitest/utils';
|
|
11
11
|
import 'pathe';
|
|
12
|
-
import './env.
|
|
12
|
+
import './env.BU041cs9.js';
|
|
13
13
|
import { parseSingleStack } from '@vitest/utils/source-map';
|
|
14
|
-
import { i as isChildProcess } from './base.
|
|
14
|
+
import { i as isChildProcess } from './base.DSsbfkDg.js';
|
|
15
15
|
import { R as RealDate, r as resetDate, m as mockDate } from './date.W2xKR2qe.js';
|
|
16
16
|
import { spyOn, fn, isMockFunction, mocks } from '@vitest/spy';
|
|
17
17
|
|
|
@@ -256,13 +256,12 @@ const SnapshotPlugin = (chai, utils) => {
|
|
|
256
256
|
chai.Assertion.prototype,
|
|
257
257
|
"toMatchInlineSnapshot",
|
|
258
258
|
function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
|
|
259
|
-
var _a;
|
|
260
259
|
const isNot = utils.flag(this, "negate");
|
|
261
260
|
if (isNot) {
|
|
262
261
|
throw new Error('toMatchInlineSnapshot cannot be used with "not"');
|
|
263
262
|
}
|
|
264
263
|
const test = utils.flag(this, "vitest-test");
|
|
265
|
-
const isInsideEach = test && (test.each ||
|
|
264
|
+
const isInsideEach = test && (test.each || test.suite?.each);
|
|
266
265
|
if (isInsideEach) {
|
|
267
266
|
throw new Error(
|
|
268
267
|
"InlineSnapshot cannot be used inside of test.each or describe.each"
|
|
@@ -317,7 +316,6 @@ const SnapshotPlugin = (chai, utils) => {
|
|
|
317
316
|
chai.Assertion.prototype,
|
|
318
317
|
"toThrowErrorMatchingInlineSnapshot",
|
|
319
318
|
function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
|
|
320
|
-
var _a;
|
|
321
319
|
const isNot = utils.flag(this, "negate");
|
|
322
320
|
if (isNot) {
|
|
323
321
|
throw new Error(
|
|
@@ -325,7 +323,7 @@ const SnapshotPlugin = (chai, utils) => {
|
|
|
325
323
|
);
|
|
326
324
|
}
|
|
327
325
|
const test = utils.flag(this, "vitest-test");
|
|
328
|
-
const isInsideEach = test && (test.each ||
|
|
326
|
+
const isInsideEach = test && (test.each || test.suite?.each);
|
|
329
327
|
if (isInsideEach) {
|
|
330
328
|
throw new Error(
|
|
331
329
|
"InlineSnapshot cannot be used inside of test.each or describe.each"
|
|
@@ -380,9 +378,8 @@ const unsupported = [
|
|
|
380
378
|
];
|
|
381
379
|
function createExpectPoll(expect) {
|
|
382
380
|
return function poll(fn, options = {}) {
|
|
383
|
-
var _a;
|
|
384
381
|
const state = getWorkerState();
|
|
385
|
-
const defaults =
|
|
382
|
+
const defaults = state.config.expect?.poll ?? {};
|
|
386
383
|
const {
|
|
387
384
|
interval = defaults.interval ?? 50,
|
|
388
385
|
timeout = defaults.timeout ?? 1e3,
|
|
@@ -3247,7 +3244,6 @@ class FakeTimers {
|
|
|
3247
3244
|
}
|
|
3248
3245
|
}
|
|
3249
3246
|
useFakeTimers() {
|
|
3250
|
-
var _a, _b, _c;
|
|
3251
3247
|
if (this._fakingDate) {
|
|
3252
3248
|
throw new Error(
|
|
3253
3249
|
'"setSystemTime" was called already and date was mocked. Reset timers using `vi.useRealTimers()` if you want to use fake timers again.'
|
|
@@ -3257,12 +3253,12 @@ class FakeTimers {
|
|
|
3257
3253
|
const toFake = Object.keys(this._fakeTimers.timers).filter(
|
|
3258
3254
|
(timer) => timer !== "nextTick"
|
|
3259
3255
|
);
|
|
3260
|
-
if (
|
|
3256
|
+
if (this._userConfig?.toFake?.includes("nextTick") && isChildProcess()) {
|
|
3261
3257
|
throw new Error(
|
|
3262
3258
|
"process.nextTick cannot be mocked inside child_process"
|
|
3263
3259
|
);
|
|
3264
3260
|
}
|
|
3265
|
-
const existingFakedMethods = (
|
|
3261
|
+
const existingFakedMethods = (this._userConfig?.toFake || toFake).filter(
|
|
3266
3262
|
(method) => {
|
|
3267
3263
|
switch (method) {
|
|
3268
3264
|
case "setImmediate":
|
|
@@ -3482,10 +3478,10 @@ function createVitest() {
|
|
|
3482
3478
|
}
|
|
3483
3479
|
const workerState = getWorkerState();
|
|
3484
3480
|
let _timers;
|
|
3485
|
-
const timers = () => _timers
|
|
3481
|
+
const timers = () => _timers ||= new FakeTimers({
|
|
3486
3482
|
global: globalThis,
|
|
3487
3483
|
config: workerState.config.fakeTimers
|
|
3488
|
-
})
|
|
3484
|
+
});
|
|
3489
3485
|
const _stubsGlobal = /* @__PURE__ */ new Map();
|
|
3490
3486
|
const _stubsEnv = /* @__PURE__ */ new Map();
|
|
3491
3487
|
const _envBooleans = ["PROD", "DEV", "SSR"];
|
|
@@ -3496,13 +3492,12 @@ function createVitest() {
|
|
|
3496
3492
|
return stack2.includes(` at Object.${name}`) || stack2.includes(`${name}@`);
|
|
3497
3493
|
});
|
|
3498
3494
|
const stack = parseSingleStack(stackArray[importerStackIndex + 1]);
|
|
3499
|
-
return
|
|
3495
|
+
return stack?.file || "";
|
|
3500
3496
|
};
|
|
3501
3497
|
const utils = {
|
|
3502
3498
|
useFakeTimers(config) {
|
|
3503
|
-
var _a, _b, _c, _d;
|
|
3504
3499
|
if (isChildProcess()) {
|
|
3505
|
-
if (
|
|
3500
|
+
if (config?.toFake?.includes("nextTick") || workerState.config?.fakeTimers?.toFake?.includes("nextTick")) {
|
|
3506
3501
|
throw new Error(
|
|
3507
3502
|
'vi.useFakeTimers({ toFake: ["nextTick"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.'
|
|
3508
3503
|
);
|