vitest 5.1.0-beta.1 → 5.1.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 +8 -6
- package/dist/browser.js +10 -10
- package/dist/chunks/{base.PJyN9N0u.js → base.C2su7_N0.js} +16 -21
- package/dist/chunks/{browser.d.D7a15z82.d.ts → browser.d.B-QwH_F6.d.ts} +3 -3
- package/dist/chunks/{cac.Ccf5Je_F.js → cac.BK306qhQ.js} +29 -22
- package/dist/chunks/{cli-api.DE22LIzq.js → cli-api.D6E8EtSi.js} +990 -166
- package/dist/chunks/{config.d.BgktgHfG.d.ts → config.d.BpJq6tRA.d.ts} +43 -2
- package/dist/chunks/{console.DrMPSuFo.js → console.VJUxd1rM.js} +3 -3
- package/dist/chunks/{coverage.-bm5IxnW.js → coverage.9iqXE2gN.js} +1 -1
- package/dist/chunks/{coverage.cTDc4uSS.js → coverage.jGCktcGP.js} +1 -1
- package/dist/chunks/{creator.BQ3onxbh.js → creator.CoOCr85O.js} +17 -15
- package/dist/chunks/{display.BlTmubjj.js → display.Cj2h2zsY.js} +1 -1
- package/dist/chunks/{doctor.CPlMs7-y.js → doctor.SRjZIZuA.js} +2 -2
- package/dist/chunks/{environment.d.CbTLsZSj.d.ts → environment.d.rlpAM-ON.d.ts} +1 -1
- package/dist/chunks/{globals.TipXUFcZ.js → globals.Mxora3_v.js} +11 -10
- package/dist/chunks/{index.BFXLpwll.js → index.C7Nn66Gy.js} +79 -41
- package/dist/chunks/{index.DmDMHCg8.js → index.CAmut2NG.js} +25 -1
- package/dist/chunks/{index.BXttT2gP.js → index.DNcttN5a.js} +288 -437
- package/dist/chunks/{index.B03wg4V0.js → index.Da_szXbS.js} +5 -5
- package/dist/chunks/{index.D14IAvnE.js → index.ER9afepi.js} +269 -141
- package/dist/chunks/{index.D0heQG4v.js → index.Or9psEGe.js} +1 -1
- package/dist/chunks/{init-forks.BL1E3__4.js → init-forks.q4IoGYZe.js} +7 -1
- package/dist/chunks/{init-threads.CYXAGzKQ.js → init-threads.Bf1Frg9S.js} +1 -1
- package/dist/chunks/{init.DVorxUyL.js → init.dGO4K2C0.js} +17 -9
- package/dist/chunks/{inspector.CvyFGlXm.js → inspector.D6o1NPo1.js} +12 -1
- package/dist/chunks/{module-dependencies.CwNPkcV4.js → module-dependencies._2Eei3FO.js} +1 -1
- package/dist/chunks/{modules.BJuCwlRJ.js → moduleSourceMap.Dp1WduWi.js} +31 -1
- package/dist/chunks/{native.cdzHIdmv.js → native.D5q1ylZC.js} +3 -2
- package/dist/chunks/{nativeModuleMocker.3uBcOd84.js → nativeModuleMocker.ihb3q7Cg.js} +6 -4
- package/dist/chunks/{nativeModuleRunner.xi64Afb2.js → nativeModuleRunner.9xPIMzi7.js} +1 -1
- package/dist/chunks/{node.uQulW0ei.js → node.B9mkVmLH.js} +1 -1
- package/dist/chunks/{pathe.M-eThtNZ.Ba-7h1rE.js → pathe.M-eThtNZ.zq3TM4NT.js} +1 -1
- package/dist/chunks/{plugin.d.olEn8IL9.d.ts → plugin.d.Du7hHZwb.d.ts} +115 -41
- package/dist/chunks/{plugins.DPQHVT0p.js → plugins.BPruPOR8.js} +1 -1
- package/dist/chunks/rawSnapshot.DvoRLRNr.js +356 -0
- package/dist/chunks/{resolver.CtCcxIy1.js → resolver.BzpmeQeT.js} +1 -1
- package/dist/chunks/{rpc.BV0XpJ5q.js → rpc.CNYWPa97.js} +3 -19
- package/dist/chunks/{rpc.d.DGFP7vWr.d.ts → rpc.d.DHfuwqP0.d.ts} +2 -2
- package/dist/chunks/{run.BfrMbGVD.js → run.zBhXlcZQ.js} +118 -51
- package/dist/chunks/{setup-common.llxJkJaD.js → setup-common.wwc_NYRJ.js} +3 -3
- package/dist/chunks/{source-map.BjWcsIL9.js → source-map.DPHGMWvM.js} +14 -14
- package/dist/chunks/{source-map.d.C5A_Tr6V.d.ts → source-map.d.xB6_75fl.d.ts} +2 -1
- package/dist/chunks/{spy.DDMXghXv.js → spy.BO0hTE3G.js} +76 -53
- package/dist/chunks/{task-utils.d.BUh7ylUT.d.ts → task-utils.d.DgSjIb7r.d.ts} +1 -1
- package/dist/chunks/{utils.DSfl_w8V.js → utils.sAsh2ClK.js} +7 -8
- package/dist/chunks/{vm.Cwj01UFE.js → vm.agn4qnmT.js} +15 -13
- package/dist/chunks/{worker.d.gsA26mmR.d.ts → worker.d.BigfbIsH.d.ts} +3 -3
- package/dist/cli.js +2 -2
- package/dist/config.d.ts +8 -8
- package/dist/index.d.ts +17 -12
- package/dist/index.js +11 -10
- package/dist/module-evaluator.d.ts +3 -3
- package/dist/module-evaluator.js +1 -1
- package/dist/node.d.ts +12 -11
- package/dist/node.js +23 -19
- package/dist/runtime.d.ts +5 -4
- package/dist/runtime.js +7 -5
- package/dist/spy.js +1 -1
- package/dist/task-utils.js +7 -3
- package/dist/worker.d.ts +4 -4
- package/dist/worker.js +23 -21
- package/dist/workers/forks.js +24 -22
- package/dist/workers/runVmTests.js +20 -17
- package/dist/workers/threads.js +24 -22
- package/dist/workers/vmForks.js +16 -15
- package/dist/workers/vmThreads.js +16 -15
- package/dist/workers/watchdog.js +20 -0
- package/package.json +21 -21
|
@@ -156,7 +156,7 @@ const serialize$5 = (val, config, indentation, depth, refs, printer) => {
|
|
|
156
156
|
if (stringedValue === "StringMatching" || stringedValue === "StringNotMatching") return stringedValue + SPACE$2 + printer(val.sample, config, indentation, depth, refs);
|
|
157
157
|
if (stringedValue === "StringContaining" || stringedValue === "StringNotContaining") return stringedValue + SPACE$2 + printer(val.sample, config, indentation, depth, refs);
|
|
158
158
|
if (typeof val.toAsymmetricMatcher !== "function") throw new TypeError(`Asymmetric matcher ${val.constructor.name} does not implement toAsymmetricMatcher()`);
|
|
159
|
-
return val.toAsymmetricMatcher();
|
|
159
|
+
return val.toAsymmetricMatcher().replaceAll("\n", `\n${indentation}`);
|
|
160
160
|
};
|
|
161
161
|
const test$5 = (val) => val && val.$$typeof === asymmetricMatcher;
|
|
162
162
|
const plugin$5 = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as init } from './init.
|
|
1
|
+
import { i as init } from './init.dGO4K2C0.js';
|
|
2
2
|
|
|
3
3
|
if (!process.send) throw new Error("Expected worker to be run in node:child_process");
|
|
4
4
|
// Store globals in case tests overwrite them
|
|
@@ -10,6 +10,7 @@ const processRemoveAllListeners = process.removeAllListeners.bind(process);
|
|
|
10
10
|
// Work-around for nodejs/node#55094
|
|
11
11
|
if (process.execArgv.some((execArg) => execArg.startsWith("--prof") || execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir"))) processOn("SIGTERM", () => processExit());
|
|
12
12
|
processOn("error", onError);
|
|
13
|
+
processOn("disconnect", onDisconnect);
|
|
13
14
|
function workerInit(options) {
|
|
14
15
|
const { runTests } = options;
|
|
15
16
|
init({
|
|
@@ -19,6 +20,7 @@ function workerInit(options) {
|
|
|
19
20
|
teardown: () => {
|
|
20
21
|
processRemoveAllListeners("message");
|
|
21
22
|
processOff("error", onError);
|
|
23
|
+
processOff("disconnect", onDisconnect);
|
|
22
24
|
// the guard installed by the test runner stays active between test
|
|
23
25
|
// files: with `isolate: false` a late process.exit would kill the
|
|
24
26
|
// other files sharing this process
|
|
@@ -34,5 +36,9 @@ function workerInit(options) {
|
|
|
34
36
|
function onError(error) {
|
|
35
37
|
if (error?.code === "ERR_IPC_CHANNEL_CLOSED" || error?.code === "EPIPE") processExit(1);
|
|
36
38
|
}
|
|
39
|
+
// Main process has died, there is no one to report results to
|
|
40
|
+
function onDisconnect() {
|
|
41
|
+
processExit(1);
|
|
42
|
+
}
|
|
37
43
|
|
|
38
44
|
export { workerInit as w };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isMainThread, parentPort } from 'node:worker_threads';
|
|
2
|
-
import { i as init } from './init.
|
|
2
|
+
import { i as init } from './init.dGO4K2C0.js';
|
|
3
3
|
|
|
4
4
|
if (isMainThread || !parentPort) throw new Error("Expected worker to be run in node:worker_threads");
|
|
5
5
|
function workerInit(options) {
|
|
@@ -2,13 +2,15 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import module$1, { isBuiltin } from 'node:module';
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
4
|
import { EvaluatedModules, ModuleRunner } from 'vite/module-runner';
|
|
5
|
-
import { e as environments, b as VitestTransport } from './index.
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { e as environments, b as VitestTransport } from './index.C7Nn66Gy.js';
|
|
6
|
+
import { s as splitSourceMap } from './moduleSourceMap.Dp1WduWi.js';
|
|
7
|
+
import { r as resolve } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
8
|
+
import { b as serializeValue, c as createStackString, p as parseStacktrace } from './source-map.DPHGMWvM.js';
|
|
8
9
|
import { w } from './tinyrainbow.Do8I1XRG.js';
|
|
9
10
|
import { Traces } from '../traces.js';
|
|
10
|
-
import { o as onCancel,
|
|
11
|
-
import { s as setupInspect } from './inspector.
|
|
11
|
+
import { o as onCancel, a as rpcDone, c as createRuntimeRpc } from './rpc.CNYWPa97.js';
|
|
12
|
+
import { s as setupInspect } from './inspector.D6o1NPo1.js';
|
|
13
|
+
import { V as VitestEvaluatedModules } from './index.CAmut2NG.js';
|
|
12
14
|
import { E as EnvironmentTeardownError } from './utils.DYj33du9.js';
|
|
13
15
|
|
|
14
16
|
function isBuiltinEnvironment(env) {
|
|
@@ -25,12 +27,18 @@ function createEnvironmentLoader(root, rpc) {
|
|
|
25
27
|
hmr: false,
|
|
26
28
|
sourcemapInterceptor: "prepareStackTrace",
|
|
27
29
|
transport: new VitestTransport({
|
|
30
|
+
// Vite's evaluator and module graph read the source map from the code
|
|
31
|
+
inlineSourceMap: true,
|
|
28
32
|
async fetchModule(id, importer, options) {
|
|
29
33
|
const result = await rpc.fetch(id, importer, "__vitest__", options);
|
|
30
|
-
if ("cached" in result)
|
|
31
|
-
code
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
if ("cached" in result) {
|
|
35
|
+
const { code, sourceMap } = splitSourceMap(readFileSync(result.tmp, "utf-8"));
|
|
36
|
+
return {
|
|
37
|
+
code,
|
|
38
|
+
sourceMap,
|
|
39
|
+
...result
|
|
40
|
+
};
|
|
41
|
+
}
|
|
34
42
|
if (isWindows && "externalize" in result)
|
|
35
43
|
// TODO: vitest returns paths for external modules, but Vite returns file://
|
|
36
44
|
// https://github.com/vitejs/vite/pull/20449
|
|
@@ -4,6 +4,17 @@ import { pathToFileURL } from 'node:url';
|
|
|
4
4
|
const __require = createRequire(import.meta.url);
|
|
5
5
|
let inspector;
|
|
6
6
|
let session;
|
|
7
|
+
// separate from `inspector`, which is only set when Vitest opens the inspector itself
|
|
8
|
+
let inspectorUrl;
|
|
9
|
+
function isInspectorOpen() {
|
|
10
|
+
if (inspectorUrl === void 0) try {
|
|
11
|
+
inspectorUrl = __require("node:inspector").url;
|
|
12
|
+
} catch {
|
|
13
|
+
// node can be built without the inspector
|
|
14
|
+
inspectorUrl = null;
|
|
15
|
+
}
|
|
16
|
+
return inspectorUrl?.() !== void 0;
|
|
17
|
+
}
|
|
7
18
|
/**
|
|
8
19
|
* Enables debugging inside `worker_threads` and `child_process`.
|
|
9
20
|
* Should be called as early as possible when worker/process has been set up.
|
|
@@ -50,4 +61,4 @@ function shouldKeepOpen(config) {
|
|
|
50
61
|
return config.watch && config.isolate === false && config.maxWorkers === 1;
|
|
51
62
|
}
|
|
52
63
|
|
|
53
|
-
export { closeInspector as c, setupInspect as s };
|
|
64
|
+
export { closeInspector as c, isInspectorOpen as i, setupInspect as s };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import module$1 from 'node:module';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import { s as slash } from './pathe.M-eThtNZ.
|
|
3
|
+
import { s as slash } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
4
4
|
import { distDir } from '../path.js';
|
|
5
5
|
|
|
6
6
|
const vitestDistDir = `${slash(distDir)}/`;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { builtinModules } from 'node:module';
|
|
2
|
+
import { Buffer } from 'node:buffer';
|
|
2
3
|
|
|
3
4
|
// copied from vite
|
|
4
5
|
// https://github.com/vitejs/vite/blob/814120f2ad387ca3d1e16c7dd403b04ca4b97f75/packages/vite/src/node/utils.ts#L106
|
|
@@ -33,4 +34,33 @@ function toBuiltin(id) {
|
|
|
33
34
|
return `node:${id}`;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
let SOURCEMAPPING_URL = "sourceMa";
|
|
38
|
+
SOURCEMAPPING_URL += "ppingURL";
|
|
39
|
+
// the source map is stored after the code in the files that workers read,
|
|
40
|
+
// it is JSON without line breaks, so the last marker is always this one
|
|
41
|
+
const SOURCE_MAP_SEPARATOR = "\n//# vitestSourceMap=";
|
|
42
|
+
function appendSourceMap(content, sourceMap) {
|
|
43
|
+
return `${content}${SOURCE_MAP_SEPARATOR}${sourceMap ?? ""}`;
|
|
44
|
+
}
|
|
45
|
+
function splitSourceMap(content) {
|
|
46
|
+
const index = content.lastIndexOf(SOURCE_MAP_SEPARATOR);
|
|
47
|
+
if (index === -1) return {
|
|
48
|
+
code: content,
|
|
49
|
+
sourceMap: void 0
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
code: content.slice(0, index),
|
|
53
|
+
sourceMap: content.slice(index + 21) || void 0
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// debuggers read the source map from the comment in the compiled script
|
|
57
|
+
function withInlineSourceMap(result) {
|
|
58
|
+
const { code, sourceMap } = result;
|
|
59
|
+
if (code == null || !sourceMap) return result;
|
|
60
|
+
return {
|
|
61
|
+
...result,
|
|
62
|
+
code: `${code}\n//# ${SOURCEMAPPING_URL}=data:application/json;base64,${Buffer.from(sourceMap).toString("base64")}\n`
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { isBrowserExternal as a, appendSourceMap as b, isBuiltin as i, splitSourceMap as s, toBuiltin as t, withInlineSourceMap as w };
|
|
@@ -2,13 +2,14 @@ import module$1, { isBuiltin } from 'node:module';
|
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { MessageChannel } from 'node:worker_threads';
|
|
4
4
|
import { initSyntaxLexers, hoistMocks } from '@vitest/mocker/transforms';
|
|
5
|
-
import { c as cleanUrl, r as resolve } from './pathe.M-eThtNZ.
|
|
5
|
+
import { c as cleanUrl, r as resolve } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
6
6
|
import { p as parse } from './acorn.C1kjbUFw.js';
|
|
7
7
|
import MagicString from 'magic-string';
|
|
8
8
|
import { $ } from './tinyrainbow.Do8I1XRG.js';
|
|
9
9
|
import { distDir } from '../path.js';
|
|
10
|
-
import { t as toBuiltin } from './
|
|
10
|
+
import { t as toBuiltin } from './moduleSourceMap.Dp1WduWi.js';
|
|
11
11
|
import 'node:path';
|
|
12
|
+
import 'node:buffer';
|
|
12
13
|
|
|
13
14
|
const NOW_LENGTH = Date.now().toString().length;
|
|
14
15
|
const REGEXP_VITEST = new RegExp(`%3Fvitest=\\d{${NOW_LENGTH}}`);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import module$1, { isBuiltin } from 'node:module';
|
|
2
2
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
3
3
|
import { automockModule, createManualModuleSource, collectModuleExports } from '@vitest/mocker/transforms';
|
|
4
|
-
import { c as cleanUrl, e as createDefer, i as isAbsolute } from './pathe.M-eThtNZ.
|
|
4
|
+
import { c as cleanUrl, e as createDefer, i as isAbsolute } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
5
5
|
import { p as parse } from './acorn.C1kjbUFw.js';
|
|
6
|
-
import { t as toBuiltin } from './
|
|
7
|
-
import { B as BareModuleMocker, n as normalizeModuleId } from './index.
|
|
6
|
+
import { t as toBuiltin } from './moduleSourceMap.Dp1WduWi.js';
|
|
7
|
+
import { B as BareModuleMocker, n as normalizeModuleId } from './index.C7Nn66Gy.js';
|
|
8
|
+
import 'node:buffer';
|
|
8
9
|
import 'node:fs';
|
|
10
|
+
import './inspector.D6o1NPo1.js';
|
|
9
11
|
import './utils.DYj33du9.js';
|
|
10
12
|
import '../path.js';
|
|
11
13
|
import 'node:path';
|
|
@@ -185,7 +187,7 @@ export { __${index} as "${key}" }
|
|
|
185
187
|
const filename = fileURLToPath(resolvedId);
|
|
186
188
|
const external = !isAbsolute(filename) || this.isModuleDirectory(resolvedId) ? normalizeModuleId(rawId) : null;
|
|
187
189
|
// file is not mocked, automock or redirect it
|
|
188
|
-
const redirect = this.findMockRedirect(filename, external);
|
|
190
|
+
const redirect = this.findMockRedirect(filename, external, rawId);
|
|
189
191
|
if (redirect) return import(pathToFileURL(redirect).toString());
|
|
190
192
|
const url = new URL(resolvedId);
|
|
191
193
|
url.searchParams.set("mock", "automock");
|
|
@@ -7,7 +7,7 @@ import fs from 'node:fs/promises';
|
|
|
7
7
|
import assert from 'node:assert';
|
|
8
8
|
import v8 from 'node:v8';
|
|
9
9
|
import { format, inspect } from 'node:util';
|
|
10
|
-
import { i as isAbsolute, r as resolve } from './pathe.M-eThtNZ.
|
|
10
|
+
import { i as isAbsolute, r as resolve } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
11
11
|
import { ModuleRunner } from 'vite/module-runner';
|
|
12
12
|
|
|
13
13
|
const JOIN_LEADING_SLASH_RE = /^\.?\//;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { g as getWorkerState } from './utils.DYj33du9.js';
|
|
2
2
|
import { promises, existsSync } from 'node:fs';
|
|
3
|
-
import { i as isAbsolute, r as resolve, d as dirname, j as join, b as basename } from './pathe.M-eThtNZ.
|
|
3
|
+
import { i as isAbsolute, r as resolve, d as dirname, j as join, b as basename } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
4
4
|
|
|
5
5
|
class NodeSnapshotEnvironment {
|
|
6
6
|
options;
|
|
@@ -489,4 +489,4 @@ const basename = function(p, extension) {
|
|
|
489
489
|
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
490
490
|
};
|
|
491
491
|
|
|
492
|
-
export {
|
|
492
|
+
export { unique as A, objectAttr as B, CSS_LANGS_RE as C, noop as D, createSimpleStackTrace as E, sanitizeFilePath as F, deepMerge as G, withTrailingSlash as H, wrapId as I, isExternalUrl as J, KNOWN_ASSET_TYPES as K, unwrapId as L, relative as a, basename as b, cleanUrl as c, dirname as d, createDefer as e, isObject as f, getType as g, getCallLastIndex as h, isAbsolute as i, join as j, extname as k, KNOWN_ASSET_RE as l, splitFileAndPostfix as m, normalize as n, isBareImport as o, isPrimitive as p, notNullish as q, resolve as r, slash as s, toArray as t, deepClone as u, getOwnProperties as v, filterOutComments as w, ordinal as x, assertTypes as y, isNegativeNaN as z };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { DevEnvironment, IndexHtmlTransformContext, IndexHtmlTransformResult, ViteDevServer, UserConfig as UserConfig$1, Plugin, ResolvedConfig as ResolvedConfig$1, TransformResult as TransformResult$1, InlineConfig as InlineConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
|
|
2
|
-
import { aW as TaskMeta, U as UserConsoleLog, Q as Suite, a as File, bk as SerializableRetry, T as TestError, h as TestAnnotation, j as TestArtifact, b2 as TestBenchmark, aL as SerializedError, a1 as ImportDuration, n as Test, A as Awaitable, Z as CancelReason, P as ParsedStack, bl as BrowserTraceViewMode, a6 as BaselineData, p as ProvidedContext, b as SerializedConfig,
|
|
1
|
+
import { DevEnvironment, IndexHtmlTransformContext, IndexHtmlTransformResult, ViteDevServer, UserConfig as UserConfig$1, Plugin, ResolvedConfig as ResolvedConfig$1, parseAstAsync, TransformResult as TransformResult$1, InlineConfig as InlineConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
|
|
2
|
+
import { aW as TaskMeta, U as UserConsoleLog, Q as Suite, a as File, bk as SerializableRetry, T as TestError, h as TestAnnotation, j as TestArtifact, b2 as TestBenchmark, aL as SerializedError, a1 as ImportDuration, n as Test, A as Awaitable, Z as CancelReason, P as ParsedStack, bl as BrowserTraceViewMode, bm as BrowserTraceViewRecordingMode, a6 as BaselineData, p as ProvidedContext, b as SerializedConfig, bn as Arrayable, a3 as AfterSuiteRunMeta, aQ as SnapshotStateOptions, aR as SnapshotSummary, aO as SnapshotResult, Y as Task, bo as AsyncLeak, k as TaskResultPack, F as FileSpecification, m as SerializedRootConfig, L as LabelColor, c as SerializedDiffOptions, bi as SequenceSetupFiles, bh as SequenceHooks, bp as PrettyFormatOptions, e as FakeTimersConfig, g as TestTagDefinition } from './config.d.BpJq6tRA.js';
|
|
3
3
|
import { Writable } from 'node:stream';
|
|
4
|
-
import { S as SerializedTestSpecification, B as BrowserTesterOptions, c as SourceModuleDiagnostic } from './browser.d.
|
|
4
|
+
import { S as SerializedTestSpecification, B as BrowserTesterOptions, c as SourceModuleDiagnostic } from './browser.d.B-QwH_F6.js';
|
|
5
5
|
import * as chai from 'chai';
|
|
6
6
|
import { happyDomTypes, jsdomTypes } from 'vitest/optional-types.js';
|
|
7
|
-
import { a as ContextTestEnvironment, b as WorkerExecuteContext, c as WorkerTestEnvironment } from './worker.d.
|
|
8
|
-
import { O as OTELCarrier } from './rpc.d.
|
|
7
|
+
import { a as ContextTestEnvironment, b as WorkerExecuteContext, c as WorkerTestEnvironment } from './worker.d.BigfbIsH.js';
|
|
8
|
+
import { O as OTELCarrier } from './rpc.d.DHfuwqP0.js';
|
|
9
9
|
import { MockedModule } from '@vitest/mocker';
|
|
10
|
-
import { S as StackTraceParserOptions, a as RuntimeCoverageProviderModule } from './source-map.d.
|
|
10
|
+
import { S as StackTraceParserOptions, a as RuntimeCoverageProviderModule } from './source-map.d.xB6_75fl.js';
|
|
11
11
|
import { CDPSession, BrowserCommands, MarkOptions } from 'vitest/browser';
|
|
12
12
|
import path from 'node:path';
|
|
13
13
|
import { Console } from 'node:console';
|
|
@@ -571,13 +571,22 @@ type BrowserBuiltinProvider = "webdriverio" | "playwright" | "preview";
|
|
|
571
571
|
interface _BrowserNames {}
|
|
572
572
|
interface BrowserTraceViewOptions {
|
|
573
573
|
/**
|
|
574
|
-
*
|
|
574
|
+
* @deprecated Use `mode` instead. `true` is the same as `mode: 'on'`.
|
|
575
|
+
*/
|
|
576
|
+
enabled?: boolean;
|
|
577
|
+
/**
|
|
578
|
+
* How trace view records tests.
|
|
575
579
|
*
|
|
576
|
-
*
|
|
580
|
+
* - `'on'`: every test gets a trace with a snapshot at every step, and Vitest UI shows steps live as tests run.
|
|
581
|
+
* - `'failure-only'`: only failed tests get a trace, with the full step timeline and a snapshot at the end.
|
|
582
|
+
* - `'off'`: no traces.
|
|
577
583
|
*
|
|
578
|
-
*
|
|
584
|
+
* Takes precedence over `enabled`.
|
|
585
|
+
*
|
|
586
|
+
* @default 'failure-only'
|
|
587
|
+
* @experimental
|
|
579
588
|
*/
|
|
580
|
-
|
|
589
|
+
mode?: BrowserTraceViewRecordingMode;
|
|
581
590
|
/**
|
|
582
591
|
* Capture canvas pixels in trace view snapshots.
|
|
583
592
|
*
|
|
@@ -599,7 +608,7 @@ interface BrowserTraceViewOptions {
|
|
|
599
608
|
/**
|
|
600
609
|
* Capture the accessibility tree alongside each trace view snapshot.
|
|
601
610
|
*
|
|
602
|
-
* The trace viewer can switch
|
|
611
|
+
* The trace viewer's snapshot pane can then switch between "DOM" and "Aria" views.
|
|
603
612
|
*
|
|
604
613
|
* @default true
|
|
605
614
|
* @experimental
|
|
@@ -722,14 +731,16 @@ interface BrowserConfigOptions {
|
|
|
722
731
|
snapshots?: boolean;
|
|
723
732
|
};
|
|
724
733
|
/**
|
|
734
|
+
* Records the actions, assertions, and marks of browser tests with DOM snapshots for the trace viewer.
|
|
725
735
|
*
|
|
726
|
-
*
|
|
727
|
-
*
|
|
728
|
-
*
|
|
736
|
+
* - `'failure-only'`: records only failed tests.
|
|
737
|
+
* - `true` or `'on'`: records every test.
|
|
738
|
+
* - `false` or `'off'`: turns trace view off.
|
|
729
739
|
*
|
|
730
|
-
* @default
|
|
740
|
+
* @default 'failure-only'
|
|
741
|
+
* @see {@link https://vitest.dev/guide/browser/trace-view}
|
|
731
742
|
*/
|
|
732
|
-
traceView?: boolean | BrowserTraceViewOptions;
|
|
743
|
+
traceView?: boolean | BrowserTraceViewRecordingMode | BrowserTraceViewOptions;
|
|
733
744
|
/**
|
|
734
745
|
* Directory where screenshots will be saved when page.screenshot() is called
|
|
735
746
|
* If not set, all screenshots are saved to __screenshots__ directory in the same folder as the test file.
|
|
@@ -1155,7 +1166,6 @@ declare class TestProject {
|
|
|
1155
1166
|
* Test if a file matches the test globs. This does the actual glob matching if the test is not cached, unlike `isCachedTestFile`.
|
|
1156
1167
|
*/
|
|
1157
1168
|
matchesTestGlob(moduleId: string, source?: () => string): boolean;
|
|
1158
|
-
private filterFiles;
|
|
1159
1169
|
/**
|
|
1160
1170
|
* Closes the project and all associated resources. This can only be called once; the closing promise is cached until the server restarts.
|
|
1161
1171
|
* If the resources are needed again, create a new project.
|
|
@@ -1699,6 +1709,8 @@ interface LinkMapper {
|
|
|
1699
1709
|
relativePath(source: ReportNode | string, target: ReportNode | string): string;
|
|
1700
1710
|
assetPath(node: ReportNode, name: string): string;
|
|
1701
1711
|
}
|
|
1712
|
+
/** color themes of the html report, `legacy` being the classic istanbul colors */
|
|
1713
|
+
type HtmlTheme = "light" | "dark" | "legacy";
|
|
1702
1714
|
/** options accepted by {@link HtmlReport} */
|
|
1703
1715
|
interface HtmlOptions {
|
|
1704
1716
|
/** show extra logging while the report is generated */
|
|
@@ -1709,11 +1721,17 @@ interface HtmlOptions {
|
|
|
1709
1721
|
subdir?: string;
|
|
1710
1722
|
/** skip nodes with no coverage */
|
|
1711
1723
|
skipEmpty?: boolean;
|
|
1724
|
+
/**
|
|
1725
|
+
* fixes the report's theme and hides the theme picker; when unset, viewers
|
|
1726
|
+
* pick a theme in the report, which otherwise follows their light/dark
|
|
1727
|
+
* preference, or the page embedding the report, like Vitest UI
|
|
1728
|
+
*/
|
|
1729
|
+
theme?: HtmlTheme;
|
|
1712
1730
|
}
|
|
1713
1731
|
|
|
1714
1732
|
//#region src/reports/html-spa/index.d.ts
|
|
1715
1733
|
/** options accepted by {@link HtmlSpaReport} */
|
|
1716
|
-
interface HtmlSpaOptions extends HtmlOptions {
|
|
1734
|
+
interface HtmlSpaOptions extends Omit<HtmlOptions, "theme"> {
|
|
1717
1735
|
/** the metrics to show in the report UI, defaults to lines, branches and functions */
|
|
1718
1736
|
metricsToShow?: ("lines" | "branches" | "functions" | "statements")[];
|
|
1719
1737
|
}
|
|
@@ -1800,6 +1818,14 @@ interface ReportOptions {
|
|
|
1800
1818
|
|
|
1801
1819
|
type TransformResult = string | Partial<TransformResult$1> | undefined | null | void;
|
|
1802
1820
|
type CoverageResults = unknown;
|
|
1821
|
+
type AstNode = CollectNodes<Awaited<ReturnType<typeof parseAstAsync>>>;
|
|
1822
|
+
type CollectNodes<
|
|
1823
|
+
T,
|
|
1824
|
+
Depth extends unknown[] = []
|
|
1825
|
+
> = Depth["length"] extends 8 ? T : CollectNodes<T | ChildNodes<T>, [...Depth, unknown]>;
|
|
1826
|
+
type ChildNodes<T> = T extends unknown ? Extract<{ [K in keyof T]: NonNullable<T[K]> extends readonly (infer U)[] ? NonNullable<U> : NonNullable<T[K]> }[keyof T], {
|
|
1827
|
+
type: string;
|
|
1828
|
+
}> : never;
|
|
1803
1829
|
interface CoverageProvider {
|
|
1804
1830
|
name: string;
|
|
1805
1831
|
/** Called when provider is being initialized before tests run */
|
|
@@ -1828,6 +1854,24 @@ interface CoverageProvider {
|
|
|
1828
1854
|
* @experimental
|
|
1829
1855
|
*/
|
|
1830
1856
|
requiresTransform?: (id: string) => boolean;
|
|
1857
|
+
/**
|
|
1858
|
+
* Version of the coverage provider. Can be used as cache key in various caching mechanisms.
|
|
1859
|
+
* @experimental
|
|
1860
|
+
*/
|
|
1861
|
+
version?: string;
|
|
1862
|
+
/**
|
|
1863
|
+
* Return data that should be stored with the transformed module in `fsModuleCache`,
|
|
1864
|
+
* e.g. data collected in `onFileTransform`. The data must be JSON serializable.
|
|
1865
|
+
* When the module is later loaded from `fsModuleCache`, `onFileTransform` is not called.
|
|
1866
|
+
* The data is passed to `restoreModuleCacheData` instead.
|
|
1867
|
+
* @experimental
|
|
1868
|
+
*/
|
|
1869
|
+
getModuleCacheData?: (environment: DevEnvironment, id: string) => unknown;
|
|
1870
|
+
/**
|
|
1871
|
+
* Called with the data returned by `getModuleCacheData` when the module is loaded from `fsModuleCache`.
|
|
1872
|
+
* @experimental
|
|
1873
|
+
*/
|
|
1874
|
+
restoreModuleCacheData?: (environment: DevEnvironment, id: string, data: unknown) => void;
|
|
1831
1875
|
/** Callback that's called when the coverage is enabled via a programmatic `enableCoverage` API. */
|
|
1832
1876
|
onEnabled?: () => void | Promise<void>;
|
|
1833
1877
|
}
|
|
@@ -1984,6 +2028,18 @@ interface CoverageOptions {
|
|
|
1984
2028
|
*/
|
|
1985
2029
|
ignoreClassMethods?: string[];
|
|
1986
2030
|
/**
|
|
2031
|
+
* Filter to ignore code from coverage based on its AST node.
|
|
2032
|
+
* Called only for nodes that Vitest's built-in filters don't already ignore.
|
|
2033
|
+
* Return `'ignore-this-and-nested-nodes'` to also ignore all nodes inside the given node.
|
|
2034
|
+
* Supported only by `v8` provider.
|
|
2035
|
+
*
|
|
2036
|
+
* @example
|
|
2037
|
+
* ```ts
|
|
2038
|
+
* ignoreNode: (node, type) => type === 'statement' && node.type === 'DebuggerStatement'
|
|
2039
|
+
* ```
|
|
2040
|
+
*/
|
|
2041
|
+
ignoreNode?: (node: AstNode, type: "function" | "statement" | "branch") => boolean | "ignore-this-and-nested-nodes" | void;
|
|
2042
|
+
/**
|
|
1987
2043
|
* Custom instrumenter factory to use instead of the default `@vitest/istanbul-lib-instrument`.
|
|
1988
2044
|
*
|
|
1989
2045
|
* The factory receives the same runtime coverage options Vitest passes to its
|
|
@@ -2305,14 +2361,7 @@ declare class StateManager {
|
|
|
2305
2361
|
/** Number of test workers that were started during the run. */
|
|
2306
2362
|
workersSpawned: number;
|
|
2307
2363
|
metadata: Record<string, {
|
|
2308
|
-
externalized: Record<string, string>;
|
|
2309
2364
|
duration: Record<string, number[]>;
|
|
2310
|
-
tmps: Record<string, string>;
|
|
2311
|
-
dumpDir?: string;
|
|
2312
|
-
outline?: {
|
|
2313
|
-
externalized: number;
|
|
2314
|
-
inlined: number;
|
|
2315
|
-
};
|
|
2316
2365
|
}>;
|
|
2317
2366
|
onUnhandledError?: OnUnhandledErrorCallback;
|
|
2318
2367
|
constructor(options: {
|
|
@@ -2342,6 +2391,12 @@ declare class StateManager {
|
|
|
2342
2391
|
cancelFiles(files: FileSpecification[], project: TestProject): void;
|
|
2343
2392
|
}
|
|
2344
2393
|
|
|
2394
|
+
type EventName = "add" | "addDir" | "change" | "unlink" | "unlinkDir";
|
|
2395
|
+
type TrackEventName = EventName | "any";
|
|
2396
|
+
type Track = (filepath: string, options?: {
|
|
2397
|
+
timeout?: number;
|
|
2398
|
+
type?: TrackEventName;
|
|
2399
|
+
}) => Promise<void>;
|
|
2345
2400
|
declare class VitestWatcher {
|
|
2346
2401
|
private vitest;
|
|
2347
2402
|
/**
|
|
@@ -2353,6 +2408,7 @@ declare class VitestWatcher {
|
|
|
2353
2408
|
*/
|
|
2354
2409
|
readonly changedTests: Set<string>;
|
|
2355
2410
|
private readonly _onRerun;
|
|
2411
|
+
private trackers;
|
|
2356
2412
|
constructor(vitest: Vitest);
|
|
2357
2413
|
close(): void;
|
|
2358
2414
|
unregisterWatcher: () => void;
|
|
@@ -2367,6 +2423,13 @@ declare class VitestWatcher {
|
|
|
2367
2423
|
* @returns A value indicating whether rerun is needed (changedTests was mutated)
|
|
2368
2424
|
*/
|
|
2369
2425
|
private handleFileChanged;
|
|
2426
|
+
createTracker(): {
|
|
2427
|
+
track: Track;
|
|
2428
|
+
stop: () => void;
|
|
2429
|
+
};
|
|
2430
|
+
private track;
|
|
2431
|
+
private handleTrackEvent;
|
|
2432
|
+
private resolveTrackEvent;
|
|
2370
2433
|
}
|
|
2371
2434
|
interface WatcherTriggerPattern {
|
|
2372
2435
|
pattern: RegExp;
|
|
@@ -2455,6 +2518,7 @@ declare class Vitest {
|
|
|
2455
2518
|
private restartsCount;
|
|
2456
2519
|
private readonly specifications;
|
|
2457
2520
|
private pool;
|
|
2521
|
+
private sequencer;
|
|
2458
2522
|
private _coverageProvider?;
|
|
2459
2523
|
/**
|
|
2460
2524
|
* @deprecated Do not rely on this property, it's always `test`. Scheduled to be removed in the next major.
|
|
@@ -2608,6 +2672,8 @@ declare class Vitest {
|
|
|
2608
2672
|
/** @default os.availableParallelism() */
|
|
2609
2673
|
concurrency?: number;
|
|
2610
2674
|
}): Promise<TestModule[]>;
|
|
2675
|
+
private preParseSpecifications;
|
|
2676
|
+
private parseFiles;
|
|
2611
2677
|
experimental_parseSpecification(specification: TestSpecification): Promise<TestModule>;
|
|
2612
2678
|
/**
|
|
2613
2679
|
* Collect tests in specified modules. Vitest will run the files to collect tests.
|
|
@@ -2618,6 +2684,7 @@ declare class Vitest {
|
|
|
2618
2684
|
* Gracefully cancel the current test run. Vitest will wait until all running tests are finished before cancelling.
|
|
2619
2685
|
*/
|
|
2620
2686
|
cancelCurrentRun(reason: CancelReason): Promise<void>;
|
|
2687
|
+
private getSequencer;
|
|
2621
2688
|
private initializeGlobalSetup;
|
|
2622
2689
|
/**
|
|
2623
2690
|
* Update snapshots in specified files. If no files are provided, it will update files with failed tests and obsolete snapshots.
|
|
@@ -3591,7 +3658,8 @@ interface DepsOptions {
|
|
|
3591
3658
|
*/
|
|
3592
3659
|
interopDefault?: boolean;
|
|
3593
3660
|
/**
|
|
3594
|
-
* A list of directories
|
|
3661
|
+
* A list of directories that contain dependencies. A file is a dependency if its path includes `/<directory>/`.
|
|
3662
|
+
* `node_modules` is always included.
|
|
3595
3663
|
*
|
|
3596
3664
|
* @default ['node_modules']
|
|
3597
3665
|
*/
|
|
@@ -3642,21 +3710,13 @@ interface InlineConfig {
|
|
|
3642
3710
|
deps?: DepsOptions;
|
|
3643
3711
|
server?: {
|
|
3644
3712
|
deps?: ServerDepsOptions;
|
|
3713
|
+
/**
|
|
3714
|
+
* @deprecated This option does nothing. To inspect or edit the transformed code,
|
|
3715
|
+
* look up the module in the `fsModuleCache` manifest.
|
|
3716
|
+
* @see {@link https://vitest.dev/config/fsmodulecache#manifest}
|
|
3717
|
+
*/
|
|
3645
3718
|
debug?: {
|
|
3646
|
-
/**
|
|
3647
|
-
* The folder where Vitest stores the contents of transformed
|
|
3648
|
-
* test files that can be inspected manually.
|
|
3649
|
-
*
|
|
3650
|
-
* If `true`, Vitest dumps the files in `.vitest-dump` folder relative to the root of the project.
|
|
3651
|
-
*
|
|
3652
|
-
* You can also use `VITEST_DEBUG_DUMP` env variable to enable this.
|
|
3653
|
-
*/
|
|
3654
3719
|
dump?: string | true;
|
|
3655
|
-
/**
|
|
3656
|
-
* If dump is enabled, should Vitest load the files from there instead of transforming them.
|
|
3657
|
-
*
|
|
3658
|
-
* You can also use `VITEST_DEBUG_LOAD_DUMP` env variable to enable this.
|
|
3659
|
-
*/
|
|
3660
3720
|
load?: boolean;
|
|
3661
3721
|
};
|
|
3662
3722
|
};
|
|
@@ -4288,6 +4348,14 @@ interface InlineConfig {
|
|
|
4288
4348
|
*/
|
|
4289
4349
|
nodeLoader?: boolean;
|
|
4290
4350
|
/**
|
|
4351
|
+
* Record `expect.poll`, `vi.waitFor`, and `vi.waitUntil` steps of each test and print them as a timeline when the test fails.
|
|
4352
|
+
* Steps of passing tests are dropped without being reported.
|
|
4353
|
+
*
|
|
4354
|
+
* This has no effect in browser mode, which records its steps with `browser.traceView`.
|
|
4355
|
+
* @default false
|
|
4356
|
+
*/
|
|
4357
|
+
traceTimeline?: boolean;
|
|
4358
|
+
/**
|
|
4291
4359
|
* Provider for detecting changed files. Used with the `--changed` flag
|
|
4292
4360
|
* to determine which files have been modified.
|
|
4293
4361
|
*
|
|
@@ -4481,7 +4549,7 @@ interface UserConfig extends InlineConfig {
|
|
|
4481
4549
|
type OnUnhandledErrorCallback = (error: (TestError | Error) & {
|
|
4482
4550
|
type: string;
|
|
4483
4551
|
}) => boolean | void;
|
|
4484
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config" | "filters" | "browser" | "coverage" | "testNamePattern" | "related" | "api" | "reporters" | "resolveSnapshotPath" | "benchmark" | "shard" | "cache" | "sequence" | "typecheck" | "runner" | "pool" | "cliExclude" | "diff" | "setupFiles" | "snapshotEnvironment" | "bail" | "name" | "vmMemoryLimit" | "fileParallelism" | "tagsFilter" | "reporter" | "ui"> {
|
|
4552
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config" | "filters" | "browser" | "coverage" | "testNamePattern" | "related" | "api" | "reporters" | "resolveSnapshotPath" | "benchmark" | "shard" | "cache" | "sequence" | "typecheck" | "runner" | "pool" | "cliExclude" | "diff" | "setupFiles" | "snapshotEnvironment" | "bail" | "name" | "vmMemoryLimit" | "fileParallelism" | "tagsFilter" | "reporter" | "ui" | "inspector"> {
|
|
4485
4553
|
name: ProjectName["label"];
|
|
4486
4554
|
color?: ProjectName["color"];
|
|
4487
4555
|
base?: string;
|
|
@@ -4500,6 +4568,13 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
|
|
|
4500
4568
|
poolRunner?: PoolRunnerInitializer;
|
|
4501
4569
|
reporters: (InlineReporter | ReporterWithOptions)[];
|
|
4502
4570
|
defines: Record<string, any>;
|
|
4571
|
+
inspector: NonNullable<UserConfig["inspector"]> & {
|
|
4572
|
+
/**
|
|
4573
|
+
* The main process has an open inspector. A debugger attached to it can attach to workers too.
|
|
4574
|
+
* @internal
|
|
4575
|
+
*/
|
|
4576
|
+
openInMainProcess: boolean;
|
|
4577
|
+
};
|
|
4503
4578
|
api: ResolvedApiConfig;
|
|
4504
4579
|
ui: boolean;
|
|
4505
4580
|
uiOptions: Required<Omit<UIOptions, "enabled">>;
|
|
@@ -4531,7 +4606,6 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
|
|
|
4531
4606
|
runner?: string;
|
|
4532
4607
|
maxWorkers: number;
|
|
4533
4608
|
vmMemoryLimit?: string | number;
|
|
4534
|
-
dumpDir?: string;
|
|
4535
4609
|
tagsFilter?: string[];
|
|
4536
4610
|
mergeReportsLabel?: string;
|
|
4537
4611
|
experimental: Omit<Required<UserConfig>["experimental"], "importDurations" | "diagnostics"> & {
|