vitest 2.0.0-beta.2 → 2.0.0-beta.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/dist/browser.d.ts +5 -1
- package/dist/browser.js +18 -2
- package/dist/chunks/{integrations-globals.B5Jl0grA.js → integrations-globals.BK0Cn4q1.js} +3 -4
- package/dist/chunks/{runtime-console.CUES-L8X.js → runtime-console.DiVMr5d4.js} +54 -24
- package/dist/chunks/{runtime-runBaseTests._dXkRAZc.js → runtime-runBaseTests.C-Bkopka.js} +5 -6
- package/dist/cli.js +2 -2
- package/dist/config.cjs +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/config.js +2 -2
- package/dist/coverage.d.ts +1 -1
- package/dist/environments.d.ts +1 -1
- package/dist/execute.d.ts +2 -2
- package/dist/execute.js +1 -1
- package/dist/index-C7JhjWOq.d.ts +1565 -0
- package/dist/index.d.ts +6 -1445
- package/dist/index.js +3 -4
- package/dist/node.d.ts +3 -6
- package/dist/node.js +7 -7
- package/dist/{reporters-DFgqsvtL.d.ts → reporters-qky6mwBH.d.ts} +398 -195
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +4 -4
- package/dist/runners.d.ts +4 -2
- package/dist/runners.js +9 -1
- package/dist/{suite-C_sqQjdz.d.ts → suite-B5_jYIf8.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/vendor/{base.VFkIJ66g.js → base.D4XK-wRp.js} +2 -2
- package/dist/vendor/{cac.CtP0aXu-.js → cac.sXjWMctD.js} +58 -20
- package/dist/vendor/{cli-api.B2QW76dQ.js → cli-api.BH9TJcYU.js} +487 -357
- package/dist/vendor/{constants.5SOfHUj0.js → constants.TCjCaw2D.js} +4 -3
- package/dist/vendor/{execute.CLLNVNnK.js → execute.BHj6OMh4.js} +3 -3
- package/dist/vendor/{index.CRxYS9H3.js → index.CyGfDRbW.js} +266 -49
- package/dist/vendor/{index.BfoZyXD1.js → index.DHRpy7zp.js} +1 -1
- package/dist/vendor/{index.CmILuxzC.js → index.DwR86H5i.js} +26 -3
- package/dist/vendor/{setup-common.XeoZAW8t.js → setup-common.BhJvzjns.js} +2 -2
- package/dist/vendor/{utils.D5gGkwyH.js → utils.YuQ3LT2a.js} +1 -1
- package/dist/vendor/{vi.ClD3hi7L.js → vi.C6AfDXK6.js} +97 -46
- package/dist/vendor/{vm.Bi3bljci.js → vm.Ow-X2mkS.js} +2 -2
- package/dist/workers/forks.js +2 -2
- package/dist/workers/runVmTests.js +4 -5
- package/dist/workers/threads.js +2 -2
- package/dist/workers/vmForks.js +3 -3
- package/dist/workers/vmThreads.js +3 -3
- package/dist/workers.d.ts +1 -1
- package/dist/workers.js +4 -4
- package/package.json +10 -10
- package/dist/vendor/run-once.DLomgGUH.js +0 -27
|
@@ -3,9 +3,10 @@ const defaultBrowserPort = 63315;
|
|
|
3
3
|
const defaultInspectPort = 9229;
|
|
4
4
|
const EXIT_CODE_RESTART = 43;
|
|
5
5
|
const API_PATH = "/__vitest_api__";
|
|
6
|
+
const BROWSER_API_PATH = "/__vitest_browser_api__";
|
|
6
7
|
const extraInlineDeps = [
|
|
7
|
-
/^(?!.*
|
|
8
|
-
/^(?!.*
|
|
8
|
+
/^(?!.*node_modules).*\.mjs$/,
|
|
9
|
+
/^(?!.*node_modules).*\.cjs\.js$/,
|
|
9
10
|
// Vite client
|
|
10
11
|
/vite\w*\/dist\/client\/env.mjs/,
|
|
11
12
|
// Nuxt
|
|
@@ -62,4 +63,4 @@ const globalApis = [
|
|
|
62
63
|
"onTestFailed"
|
|
63
64
|
];
|
|
64
65
|
|
|
65
|
-
export { API_PATH as A, CONFIG_NAMES as C, EXIT_CODE_RESTART as E, defaultBrowserPort as a, defaultInspectPort as b, configFiles as c, defaultPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
|
|
66
|
+
export { API_PATH as A, BROWSER_API_PATH as B, CONFIG_NAMES as C, EXIT_CODE_RESTART as E, defaultBrowserPort as a, defaultInspectPort as b, configFiles as c, defaultPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
|
|
@@ -68,7 +68,7 @@ class VitestMocker {
|
|
|
68
68
|
if (this.moduleCache.has(mockId))
|
|
69
69
|
this.moduleCache.delete(mockId);
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
isModuleDirectory(path) {
|
|
72
72
|
return this.moduleDirectories.some((dir) => path.includes(dir));
|
|
73
73
|
}
|
|
74
74
|
getSuiteFilepath() {
|
|
@@ -103,7 +103,7 @@ class VitestMocker {
|
|
|
103
103
|
throw error;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
const external = !isAbsolute(fsPath) || this.
|
|
106
|
+
const external = !isAbsolute(fsPath) || this.isModuleDirectory(fsPath) ? rawId : null;
|
|
107
107
|
return {
|
|
108
108
|
id,
|
|
109
109
|
fsPath,
|
|
@@ -368,7 +368,7 @@ async function createVitestExecutor(options) {
|
|
|
368
368
|
return runner;
|
|
369
369
|
}
|
|
370
370
|
const externalizeMap = /* @__PURE__ */ new Map();
|
|
371
|
-
const bareVitestRegexp = /^@?vitest(
|
|
371
|
+
const bareVitestRegexp = /^@?vitest(?:\/|$)/;
|
|
372
372
|
const dispose = [];
|
|
373
373
|
function listenForErrors(state) {
|
|
374
374
|
dispose.forEach((fn) => fn());
|
|
@@ -5,17 +5,17 @@ import { basename, dirname, resolve, join, relative, extname, normalize } from '
|
|
|
5
5
|
import { a as getFullName, h as hasFailedSnapshot } from './tasks.WC7M-K-v.js';
|
|
6
6
|
import { getSafeTimers, notNullish, highlight, shuffle, inspect, positionToOffset, lineSplitRE } from '@vitest/utils';
|
|
7
7
|
import { i as isNode } from './env.bmJgw1qP.js';
|
|
8
|
-
import { g as getStateSymbol, f as formatProjectName, p as pointer, F as F_RIGHT, r as renderSnapshotSummary,
|
|
8
|
+
import { g as getStateSymbol, f as formatProjectName, p as pointer, F as F_RIGHT, a as F_POINTER, r as renderSnapshotSummary, b as getStateString, c as formatTimeString, d as countTestErrors, e as divider, s as stripAnsi, h as getCols, i as getHookStateSymbol } from './utils.YuQ3LT2a.js';
|
|
9
9
|
import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, getTests, hasFailed, getSuites } from '@vitest/runner/utils';
|
|
10
10
|
import { performance } from 'node:perf_hooks';
|
|
11
|
+
import { TraceMap, generatedPositionFor, parseStacktrace, parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
11
12
|
import { r as relativePath } from './index._7XLd8Kd.js';
|
|
12
|
-
import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.
|
|
13
|
+
import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.DiVMr5d4.js';
|
|
13
14
|
import { t as toArray, b as isPrimitive } from './base._gnK9Slw.js';
|
|
14
15
|
import { isCI } from 'std-env';
|
|
15
|
-
import { TraceMap, generatedPositionFor, parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
16
16
|
import nodeos__default, { hostname } from 'node:os';
|
|
17
17
|
import { Writable } from 'node:stream';
|
|
18
|
-
import { writeFile, rm } from 'node:fs/promises';
|
|
18
|
+
import { writeFile, rm, mkdir, readdir, readFile } from 'node:fs/promises';
|
|
19
19
|
import { execa } from 'execa';
|
|
20
20
|
import url from 'node:url';
|
|
21
21
|
import p$1 from 'path';
|
|
@@ -28,9 +28,116 @@ import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './_commonjsHe
|
|
|
28
28
|
import require$$0$2 from 'assert';
|
|
29
29
|
import require$$0$1 from 'events';
|
|
30
30
|
import { createHash } from 'node:crypto';
|
|
31
|
-
import { slash } from 'vite-node/utils';
|
|
31
|
+
import { slash, cleanUrl } from 'vite-node/utils';
|
|
32
32
|
import { createRequire } from 'node:module';
|
|
33
33
|
|
|
34
|
+
/// <reference types="../types/index.d.ts" />
|
|
35
|
+
|
|
36
|
+
// (c) 2020-present Andrea Giammarchi
|
|
37
|
+
|
|
38
|
+
const {parse: $parse, stringify: $stringify} = JSON;
|
|
39
|
+
const {keys} = Object;
|
|
40
|
+
|
|
41
|
+
const Primitive = String; // it could be Number
|
|
42
|
+
const primitive = 'string'; // it could be 'number'
|
|
43
|
+
|
|
44
|
+
const ignore$1 = {};
|
|
45
|
+
const object = 'object';
|
|
46
|
+
|
|
47
|
+
const noop = (_, value) => value;
|
|
48
|
+
|
|
49
|
+
const primitives = value => (
|
|
50
|
+
value instanceof Primitive ? Primitive(value) : value
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const Primitives = (_, value) => (
|
|
54
|
+
typeof value === primitive ? new Primitive(value) : value
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const revive = (input, parsed, output, $) => {
|
|
58
|
+
const lazy = [];
|
|
59
|
+
for (let ke = keys(output), {length} = ke, y = 0; y < length; y++) {
|
|
60
|
+
const k = ke[y];
|
|
61
|
+
const value = output[k];
|
|
62
|
+
if (value instanceof Primitive) {
|
|
63
|
+
const tmp = input[value];
|
|
64
|
+
if (typeof tmp === object && !parsed.has(tmp)) {
|
|
65
|
+
parsed.add(tmp);
|
|
66
|
+
output[k] = ignore$1;
|
|
67
|
+
lazy.push({k, a: [input, parsed, tmp, $]});
|
|
68
|
+
}
|
|
69
|
+
else
|
|
70
|
+
output[k] = $.call(output, k, tmp);
|
|
71
|
+
}
|
|
72
|
+
else if (output[k] !== ignore$1)
|
|
73
|
+
output[k] = $.call(output, k, value);
|
|
74
|
+
}
|
|
75
|
+
for (let {length} = lazy, i = 0; i < length; i++) {
|
|
76
|
+
const {k, a} = lazy[i];
|
|
77
|
+
output[k] = $.call(output, k, revive.apply(null, a));
|
|
78
|
+
}
|
|
79
|
+
return output;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const set = (known, input, value) => {
|
|
83
|
+
const index = Primitive(input.push(value) - 1);
|
|
84
|
+
known.set(value, index);
|
|
85
|
+
return index;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Converts a specialized flatted string into a JS value.
|
|
90
|
+
* @param {string} text
|
|
91
|
+
* @param {(this: any, key: string, value: any) => any} [reviver]
|
|
92
|
+
* @returns {any}
|
|
93
|
+
*/
|
|
94
|
+
const parse = (text, reviver) => {
|
|
95
|
+
const input = $parse(text, Primitives).map(primitives);
|
|
96
|
+
const value = input[0];
|
|
97
|
+
const $ = reviver || noop;
|
|
98
|
+
const tmp = typeof value === object && value ?
|
|
99
|
+
revive(input, new Set, value, $) :
|
|
100
|
+
value;
|
|
101
|
+
return $.call({'': tmp}, '', tmp);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Converts a JS value into a specialized flatted string.
|
|
106
|
+
* @param {any} value
|
|
107
|
+
* @param {((this: any, key: string, value: any) => any) | (string | number)[] | null | undefined} [replacer]
|
|
108
|
+
* @param {string | number | undefined} [space]
|
|
109
|
+
* @returns {string}
|
|
110
|
+
*/
|
|
111
|
+
const stringify = (value, replacer, space) => {
|
|
112
|
+
const $ = replacer && typeof replacer === object ?
|
|
113
|
+
(k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
|
|
114
|
+
(replacer || noop);
|
|
115
|
+
const known = new Map;
|
|
116
|
+
const input = [];
|
|
117
|
+
const output = [];
|
|
118
|
+
let i = +set(known, input, $.call({'': value}, '', value));
|
|
119
|
+
let firstRun = !i;
|
|
120
|
+
while (i < input.length) {
|
|
121
|
+
firstRun = true;
|
|
122
|
+
output[i] = $stringify(input[i++], replace, space);
|
|
123
|
+
}
|
|
124
|
+
return '[' + output.join(',') + ']';
|
|
125
|
+
function replace(key, value) {
|
|
126
|
+
if (firstRun) {
|
|
127
|
+
firstRun = !firstRun;
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
const after = $.call(this, key, value);
|
|
131
|
+
switch (typeof after) {
|
|
132
|
+
case object:
|
|
133
|
+
if (after === null) return after;
|
|
134
|
+
case primitive:
|
|
135
|
+
return known.get(after) || set(known, input, after);
|
|
136
|
+
}
|
|
137
|
+
return after;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
34
141
|
const REGEXP_WRAP_PREFIX = "$$vitest:";
|
|
35
142
|
function getOutputFile(config, reporter) {
|
|
36
143
|
if (!(config == null ? void 0 : config.outputFile))
|
|
@@ -863,7 +970,6 @@ class Typechecker {
|
|
|
863
970
|
}
|
|
864
971
|
}
|
|
865
972
|
|
|
866
|
-
var _a;
|
|
867
973
|
const BADGE_PADDING = " ";
|
|
868
974
|
const HELP_HINT = `${c.dim("press ")}${c.bold("h")}${c.dim(" to show help")}`;
|
|
869
975
|
const HELP_UPDATE_SNAP = c.dim("press ") + c.bold(c.yellow("u")) + c.dim(" to update snapshot");
|
|
@@ -879,7 +985,7 @@ class BaseReporter {
|
|
|
879
985
|
start = 0;
|
|
880
986
|
end = 0;
|
|
881
987
|
watchFilters;
|
|
882
|
-
isTTY
|
|
988
|
+
isTTY;
|
|
883
989
|
ctx = void 0;
|
|
884
990
|
_filesInWatchMode = /* @__PURE__ */ new Map();
|
|
885
991
|
_lastRunTimeout = 0;
|
|
@@ -887,7 +993,9 @@ class BaseReporter {
|
|
|
887
993
|
_lastRunCount = 0;
|
|
888
994
|
_timeStart = /* @__PURE__ */ new Date();
|
|
889
995
|
_offUnhandledRejection;
|
|
890
|
-
constructor() {
|
|
996
|
+
constructor(options = {}) {
|
|
997
|
+
var _a;
|
|
998
|
+
this.isTTY = options.isTTY ?? (isNode && ((_a = process.stdout) == null ? void 0 : _a.isTTY) && !isCI);
|
|
891
999
|
this.registerUnhandledRejection();
|
|
892
1000
|
}
|
|
893
1001
|
get mode() {
|
|
@@ -896,8 +1004,8 @@ class BaseReporter {
|
|
|
896
1004
|
onInit(ctx) {
|
|
897
1005
|
this.ctx = ctx;
|
|
898
1006
|
ctx.onClose(() => {
|
|
899
|
-
var
|
|
900
|
-
(
|
|
1007
|
+
var _a;
|
|
1008
|
+
(_a = this._offUnhandledRejection) == null ? void 0 : _a.call(this);
|
|
901
1009
|
});
|
|
902
1010
|
ctx.logger.printBanner();
|
|
903
1011
|
this.start = performance.now();
|
|
@@ -914,17 +1022,17 @@ class BaseReporter {
|
|
|
914
1022
|
}
|
|
915
1023
|
}
|
|
916
1024
|
onTaskUpdate(packs) {
|
|
917
|
-
var
|
|
1025
|
+
var _a, _b, _c, _d;
|
|
918
1026
|
if (this.isTTY)
|
|
919
1027
|
return;
|
|
920
1028
|
const logger = this.ctx.logger;
|
|
921
1029
|
for (const pack of packs) {
|
|
922
1030
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
923
|
-
if (task && "filepath" in task && ((
|
|
1031
|
+
if (task && "filepath" in task && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
924
1032
|
const tests = getTests(task);
|
|
925
1033
|
const failed = tests.filter((t) => {
|
|
926
|
-
var
|
|
927
|
-
return ((
|
|
1034
|
+
var _a2;
|
|
1035
|
+
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
|
|
928
1036
|
});
|
|
929
1037
|
const skipped = tests.filter((t) => t.mode === "skip" || t.mode === "todo");
|
|
930
1038
|
let state = c.dim(`${tests.length} test${tests.length > 1 ? "s" : ""}`);
|
|
@@ -1035,15 +1143,32 @@ ${PROJECT_FILTER}${FILENAME_PATTERN}${TESTNAME_PATTERN}`);
|
|
|
1035
1143
|
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
|
|
1036
1144
|
const header = c.gray(log.type + c.dim(` | ${task ? getFullName(task, c.dim(" > ")) : log.taskId !== UNKNOWN_TEST_ID ? log.taskId : "unknown test"}`));
|
|
1037
1145
|
const output = log.type === "stdout" ? this.ctx.logger.outputStream : this.ctx.logger.errorStream;
|
|
1038
|
-
output.write(
|
|
1039
|
-
|
|
1040
|
-
`);
|
|
1146
|
+
const write = (msg) => output.write(msg);
|
|
1147
|
+
write(`${header}
|
|
1148
|
+
${log.content}`);
|
|
1149
|
+
if (log.origin) {
|
|
1150
|
+
if (log.browser)
|
|
1151
|
+
write("\n");
|
|
1152
|
+
const project = log.taskId ? this.ctx.getProjectByTaskId(log.taskId) : this.ctx.getCoreWorkspaceProject();
|
|
1153
|
+
const stack = parseStacktrace(log.origin, {
|
|
1154
|
+
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file),
|
|
1155
|
+
frameFilter: project.config.onStackTrace
|
|
1156
|
+
});
|
|
1157
|
+
const highlight = task ? stack.find((i) => i.file === task.file.filepath) : null;
|
|
1158
|
+
for (const frame of stack) {
|
|
1159
|
+
const color = frame === highlight ? c.cyan : c.gray;
|
|
1160
|
+
const path = relative(project.config.root, frame.file);
|
|
1161
|
+
write(color(` ${c.dim(F_POINTER)} ${[frame.method, `${path}:${c.dim(`${frame.line}:${frame.column}`)}`].filter(Boolean).join(" ")}
|
|
1162
|
+
`));
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
write("\n");
|
|
1041
1166
|
}
|
|
1042
1167
|
shouldLog(log) {
|
|
1043
|
-
var
|
|
1168
|
+
var _a, _b;
|
|
1044
1169
|
if (this.ctx.config.silent)
|
|
1045
1170
|
return false;
|
|
1046
|
-
const shouldLog = (_b = (
|
|
1171
|
+
const shouldLog = (_b = (_a = this.ctx.config).onConsoleLog) == null ? void 0 : _b.call(_a, log.content, log.type);
|
|
1047
1172
|
if (shouldLog === false)
|
|
1048
1173
|
return shouldLog;
|
|
1049
1174
|
return true;
|
|
@@ -1067,8 +1192,8 @@ ${log.content}
|
|
|
1067
1192
|
const collectTime = files.reduce((acc, test) => acc + Math.max(0, test.collectDuration || 0), 0);
|
|
1068
1193
|
const setupTime = files.reduce((acc, test) => acc + Math.max(0, test.setupDuration || 0), 0);
|
|
1069
1194
|
const testsTime = files.reduce((acc, test) => {
|
|
1070
|
-
var
|
|
1071
|
-
return acc + Math.max(0, ((
|
|
1195
|
+
var _a;
|
|
1196
|
+
return acc + Math.max(0, ((_a = test.result) == null ? void 0 : _a.duration) || 0);
|
|
1072
1197
|
}, 0);
|
|
1073
1198
|
const transformTime = this.ctx.projects.flatMap((w) => w.vitenode.getTotalDuration()).reduce((a, b) => a + b, 0);
|
|
1074
1199
|
const environmentTime = files.reduce((acc, file) => acc + Math.max(0, file.environmentLoad || 0), 0);
|
|
@@ -1092,8 +1217,8 @@ ${log.content}
|
|
|
1092
1217
|
logger.log(padTitle("Tests"), getStateString(tests));
|
|
1093
1218
|
if (this.ctx.projects.some((c2) => c2.config.typecheck.enabled)) {
|
|
1094
1219
|
const failed = tests.filter((t) => {
|
|
1095
|
-
var
|
|
1096
|
-
return ((
|
|
1220
|
+
var _a, _b, _c;
|
|
1221
|
+
return ((_a = t.meta) == null ? void 0 : _a.typecheck) && ((_c = (_b = t.result) == null ? void 0 : _b.errors) == null ? void 0 : _c.length);
|
|
1097
1222
|
});
|
|
1098
1223
|
logger.log(padTitle("Type Errors"), failed.length ? c.bold(c.red(`${failed.length} failed`)) : c.dim("no errors"));
|
|
1099
1224
|
}
|
|
@@ -1105,8 +1230,8 @@ ${log.content}
|
|
|
1105
1230
|
} else {
|
|
1106
1231
|
let timers = `transform ${time(transformTime)}, setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)}, environment ${time(environmentTime)}, prepare ${time(prepareTime)}`;
|
|
1107
1232
|
const typecheck = this.ctx.projects.reduce((acc, c2) => {
|
|
1108
|
-
var
|
|
1109
|
-
return acc + (((
|
|
1233
|
+
var _a;
|
|
1234
|
+
return acc + (((_a = c2.typechecker) == null ? void 0 : _a.getResult().time) || 0);
|
|
1110
1235
|
}, 0);
|
|
1111
1236
|
if (typecheck)
|
|
1112
1237
|
timers += `, typecheck ${time(typecheck)}`;
|
|
@@ -1119,12 +1244,12 @@ ${log.content}
|
|
|
1119
1244
|
const suites = getSuites(files);
|
|
1120
1245
|
const tests = getTests(files);
|
|
1121
1246
|
const failedSuites = suites.filter((i) => {
|
|
1122
|
-
var
|
|
1123
|
-
return (
|
|
1247
|
+
var _a;
|
|
1248
|
+
return (_a = i.result) == null ? void 0 : _a.errors;
|
|
1124
1249
|
});
|
|
1125
1250
|
const failedTests = tests.filter((i) => {
|
|
1126
|
-
var
|
|
1127
|
-
return ((
|
|
1251
|
+
var _a;
|
|
1252
|
+
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
1128
1253
|
});
|
|
1129
1254
|
const failedTotal = countTestErrors(failedSuites) + countTestErrors(failedTests);
|
|
1130
1255
|
let current = 1;
|
|
@@ -1150,8 +1275,8 @@ ${log.content}
|
|
|
1150
1275
|
const logger = this.ctx.logger;
|
|
1151
1276
|
const benches = getTests(files);
|
|
1152
1277
|
const topBenches = benches.filter((i) => {
|
|
1153
|
-
var
|
|
1154
|
-
return ((_b = (
|
|
1278
|
+
var _a, _b;
|
|
1279
|
+
return ((_b = (_a = i.result) == null ? void 0 : _a.benchmark) == null ? void 0 : _b.rank) === 1;
|
|
1155
1280
|
});
|
|
1156
1281
|
logger.log(`
|
|
1157
1282
|
${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
@@ -1163,8 +1288,8 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1163
1288
|
const groupName = getFullName(group, c.dim(" > "));
|
|
1164
1289
|
logger.log(` ${bench.name}${c.dim(` - ${groupName}`)}`);
|
|
1165
1290
|
const siblings = group.tasks.filter((i) => {
|
|
1166
|
-
var
|
|
1167
|
-
return i.meta.benchmark && ((
|
|
1291
|
+
var _a;
|
|
1292
|
+
return i.meta.benchmark && ((_a = i.result) == null ? void 0 : _a.benchmark) && i !== bench;
|
|
1168
1293
|
}).sort((a, b) => a.result.benchmark.rank - b.result.benchmark.rank);
|
|
1169
1294
|
if (siblings.length === 0) {
|
|
1170
1295
|
logger.log("");
|
|
@@ -1178,17 +1303,17 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1178
1303
|
}
|
|
1179
1304
|
}
|
|
1180
1305
|
printTaskErrors(tasks, errorDivider) {
|
|
1181
|
-
var
|
|
1306
|
+
var _a, _b, _c;
|
|
1182
1307
|
const errorsQueue = [];
|
|
1183
1308
|
for (const task of tasks) {
|
|
1184
|
-
(_b = (
|
|
1309
|
+
(_b = (_a = task.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.forEach((error) => {
|
|
1185
1310
|
const errorItem = (error == null ? void 0 : error.stackStr) && errorsQueue.find((i) => {
|
|
1186
|
-
var
|
|
1187
|
-
const hasStr = ((
|
|
1311
|
+
var _a2, _b2, _c2, _d;
|
|
1312
|
+
const hasStr = ((_a2 = i[0]) == null ? void 0 : _a2.stackStr) === error.stackStr;
|
|
1188
1313
|
if (!hasStr)
|
|
1189
1314
|
return false;
|
|
1190
|
-
const currentProjectName = (task == null ? void 0 : task.projectName) || ((_b2 = task.file) == null ? void 0 : _b2.projectName);
|
|
1191
|
-
const projectName = ((_c2 = i[1][0]) == null ? void 0 : _c2.projectName) || ((_d = i[1][0].file) == null ? void 0 : _d.projectName);
|
|
1315
|
+
const currentProjectName = (task == null ? void 0 : task.projectName) || ((_b2 = task.file) == null ? void 0 : _b2.projectName) || "";
|
|
1316
|
+
const projectName = ((_c2 = i[1][0]) == null ? void 0 : _c2.projectName) || ((_d = i[1][0].file) == null ? void 0 : _d.projectName) || "";
|
|
1192
1317
|
return projectName === currentProjectName;
|
|
1193
1318
|
});
|
|
1194
1319
|
if (errorItem)
|
|
@@ -1200,7 +1325,7 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1200
1325
|
for (const [error, tasks2] of errorsQueue) {
|
|
1201
1326
|
for (const task of tasks2) {
|
|
1202
1327
|
const filepath = (task == null ? void 0 : task.filepath) || "";
|
|
1203
|
-
const projectName = (task == null ? void 0 : task.projectName) || ((_c = task.file) == null ? void 0 : _c.projectName);
|
|
1328
|
+
const projectName = (task == null ? void 0 : task.projectName) || ((_c = task.file) == null ? void 0 : _c.projectName) || "";
|
|
1204
1329
|
let name = getFullName(task, c.dim(" > "));
|
|
1205
1330
|
if (filepath)
|
|
1206
1331
|
name = `${name} ${c.dim(`[ ${this.relative(filepath)} ]`)}`;
|
|
@@ -2140,7 +2265,7 @@ function formatFilepath$1(path) {
|
|
|
2140
2265
|
}
|
|
2141
2266
|
function formatNumber$1(number) {
|
|
2142
2267
|
const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
|
|
2143
|
-
return res[0].replace(/(?=(?:\d{3})+$)
|
|
2268
|
+
return res[0].replace(/(?=(?:\d{3})+$)\B/g, ",") + (res[1] ? `.${res[1]}` : "");
|
|
2144
2269
|
}
|
|
2145
2270
|
function renderHookState(task, hookName, level = 0) {
|
|
2146
2271
|
var _a, _b;
|
|
@@ -4304,6 +4429,8 @@ const skipErrorProperties = /* @__PURE__ */ new Set([
|
|
|
4304
4429
|
"stackStr",
|
|
4305
4430
|
"type",
|
|
4306
4431
|
"showDiff",
|
|
4432
|
+
"ok",
|
|
4433
|
+
"operator",
|
|
4307
4434
|
"diff",
|
|
4308
4435
|
"codeFrame",
|
|
4309
4436
|
"actual",
|
|
@@ -4456,12 +4583,14 @@ function flattenTasks$1(task, baseName = "") {
|
|
|
4456
4583
|
}
|
|
4457
4584
|
}
|
|
4458
4585
|
function removeInvalidXMLCharacters(value, removeDiscouragedChars) {
|
|
4459
|
-
let regex = /(
|
|
4586
|
+
let regex = /([\0-\x08\v\f\x0E-\x1F\uFFFD\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g;
|
|
4460
4587
|
value = String(value || "").replace(regex, "");
|
|
4461
4588
|
{
|
|
4462
4589
|
regex = new RegExp(
|
|
4463
|
-
|
|
4590
|
+
/* eslint-disable regexp/prefer-character-class, regexp/no-obscure-range, regexp/no-useless-non-capturing-group */
|
|
4591
|
+
"([\\x7F-\\x84]|[\\x86-\\x9F]|[\\uFDD0-\\uFDEF]|\\uD83F[\\uDFFE\\uDFFF]|(?:\\uD87F[\\uDFFE\\uDFFF])|\\uD8BF[\\uDFFE\\uDFFF]|\\uD8FF[\\uDFFE\\uDFFF]|(?:\\uD93F[\\uDFFE\\uDFFF])|\\uD97F[\\uDFFE\\uDFFF]|\\uD9BF[\\uDFFE\\uDFFF]|\\uD9FF[\\uDFFE\\uDFFF]|\\uDA3F[\\uDFFE\\uDFFF]|\\uDA7F[\\uDFFE\\uDFFF]|\\uDABF[\\uDFFE\\uDFFF]|(?:\\uDAFF[\\uDFFE\\uDFFF])|\\uDB3F[\\uDFFE\\uDFFF]|\\uDB7F[\\uDFFE\\uDFFF]|(?:\\uDBBF[\\uDFFE\\uDFFF])|\\uDBFF[\\uDFFE\\uDFFF](?:[\\0-\\t\\v\\f\\x0E-\\u2027\\u202A-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]))",
|
|
4464
4592
|
"g"
|
|
4593
|
+
/* eslint-enable */
|
|
4465
4594
|
);
|
|
4466
4595
|
value = value.replace(regex, "");
|
|
4467
4596
|
}
|
|
@@ -4543,8 +4672,7 @@ class JUnitReporter {
|
|
|
4543
4672
|
async writeTasks(tasks, filename) {
|
|
4544
4673
|
for (const task of tasks) {
|
|
4545
4674
|
await this.writeElement("testcase", {
|
|
4546
|
-
|
|
4547
|
-
classname: this.options.classname ?? process.env.VITEST_JUNIT_CLASSNAME ?? filename,
|
|
4675
|
+
classname: this.options.classname ?? filename,
|
|
4548
4676
|
file: this.options.addFileAttribute ? filename : void 0,
|
|
4549
4677
|
name: task.name,
|
|
4550
4678
|
time: getDuration(task)
|
|
@@ -4628,8 +4756,7 @@ class JUnitReporter {
|
|
|
4628
4756
|
stats2.failures += file.stats.failures;
|
|
4629
4757
|
return stats2;
|
|
4630
4758
|
}, {
|
|
4631
|
-
|
|
4632
|
-
name: this.options.suiteName || process.env.VITEST_JUNIT_SUITE_NAME || "vitest tests",
|
|
4759
|
+
name: this.options.suiteName || "vitest tests",
|
|
4633
4760
|
tests: 0,
|
|
4634
4761
|
failures: 0,
|
|
4635
4762
|
errors: 0,
|
|
@@ -4766,6 +4893,94 @@ function escapeProperty(s) {
|
|
|
4766
4893
|
return s.replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/:/g, "%3A").replace(/,/g, "%2C");
|
|
4767
4894
|
}
|
|
4768
4895
|
|
|
4896
|
+
class BlobReporter {
|
|
4897
|
+
ctx;
|
|
4898
|
+
options;
|
|
4899
|
+
constructor(options) {
|
|
4900
|
+
this.options = options;
|
|
4901
|
+
}
|
|
4902
|
+
onInit(ctx) {
|
|
4903
|
+
if (ctx.config.watch)
|
|
4904
|
+
throw new Error("Blob reporter is not supported in watch mode");
|
|
4905
|
+
this.ctx = ctx;
|
|
4906
|
+
}
|
|
4907
|
+
async onFinished(files = [], errors = [], coverage) {
|
|
4908
|
+
let outputFile = this.options.outputFile ?? getOutputFile(this.ctx.config, "blob");
|
|
4909
|
+
if (!outputFile) {
|
|
4910
|
+
const shard = this.ctx.config.shard;
|
|
4911
|
+
outputFile = shard ? `.vitest-reports/blob-${shard.index}-${shard.count}.json` : ".vitest-reports/blob.json";
|
|
4912
|
+
}
|
|
4913
|
+
const moduleKeys = this.ctx.projects.map((project) => {
|
|
4914
|
+
return [project.getName(), [...project.server.moduleGraph.idToModuleMap.keys()]];
|
|
4915
|
+
});
|
|
4916
|
+
const report = stringify([this.ctx.version, files, errors, moduleKeys, coverage]);
|
|
4917
|
+
const reportFile = resolve(this.ctx.config.root, outputFile);
|
|
4918
|
+
const dir = dirname(reportFile);
|
|
4919
|
+
if (!existsSync(dir))
|
|
4920
|
+
await mkdir(dir, { recursive: true });
|
|
4921
|
+
await writeFile(
|
|
4922
|
+
reportFile,
|
|
4923
|
+
report,
|
|
4924
|
+
"utf-8"
|
|
4925
|
+
);
|
|
4926
|
+
this.ctx.logger.log("blob report written to", reportFile);
|
|
4927
|
+
}
|
|
4928
|
+
}
|
|
4929
|
+
async function readBlobs(blobsDirectory, projectsArray) {
|
|
4930
|
+
const resolvedDir = resolve(process.cwd(), blobsDirectory);
|
|
4931
|
+
const blobsFiles = await readdir(resolvedDir);
|
|
4932
|
+
const promises = blobsFiles.map(async (file) => {
|
|
4933
|
+
const content = await readFile(resolve(resolvedDir, file), "utf-8");
|
|
4934
|
+
const [version, files2, errors2, moduleKeys, coverage] = parse(content);
|
|
4935
|
+
return { version, files: files2, errors: errors2, moduleKeys, coverage };
|
|
4936
|
+
});
|
|
4937
|
+
const blobs = await Promise.all(promises);
|
|
4938
|
+
if (!blobs.length)
|
|
4939
|
+
throw new Error(`vitest.mergeReports() requires at least one blob file paths in the config`);
|
|
4940
|
+
const projects = Object.fromEntries(projectsArray.map((p) => [p.getName(), p]));
|
|
4941
|
+
blobs.forEach((blob) => {
|
|
4942
|
+
blob.moduleKeys.forEach(([projectName, moduleIds]) => {
|
|
4943
|
+
const project = projects[projectName];
|
|
4944
|
+
if (!project)
|
|
4945
|
+
return;
|
|
4946
|
+
moduleIds.forEach((moduleId) => {
|
|
4947
|
+
project.server.moduleGraph.idToModuleMap.set(moduleId, {
|
|
4948
|
+
id: moduleId,
|
|
4949
|
+
url: moduleId,
|
|
4950
|
+
file: cleanUrl(moduleId),
|
|
4951
|
+
ssrTransformResult: null,
|
|
4952
|
+
transformResult: null,
|
|
4953
|
+
importedBindings: null,
|
|
4954
|
+
importedModules: /* @__PURE__ */ new Set(),
|
|
4955
|
+
importers: /* @__PURE__ */ new Set(),
|
|
4956
|
+
type: "js",
|
|
4957
|
+
clientImportedModules: /* @__PURE__ */ new Set(),
|
|
4958
|
+
ssrError: null,
|
|
4959
|
+
ssrImportedModules: /* @__PURE__ */ new Set(),
|
|
4960
|
+
ssrModule: null,
|
|
4961
|
+
acceptedHmrDeps: /* @__PURE__ */ new Set(),
|
|
4962
|
+
acceptedHmrExports: null,
|
|
4963
|
+
lastHMRTimestamp: 0,
|
|
4964
|
+
lastInvalidationTimestamp: 0
|
|
4965
|
+
});
|
|
4966
|
+
});
|
|
4967
|
+
});
|
|
4968
|
+
});
|
|
4969
|
+
const files = blobs.flatMap((blob) => blob.files).sort((f1, f2) => {
|
|
4970
|
+
var _a, _b;
|
|
4971
|
+
const time1 = ((_a = f1.result) == null ? void 0 : _a.startTime) || 0;
|
|
4972
|
+
const time2 = ((_b = f2.result) == null ? void 0 : _b.startTime) || 0;
|
|
4973
|
+
return time1 - time2;
|
|
4974
|
+
});
|
|
4975
|
+
const errors = blobs.flatMap((blob) => blob.errors);
|
|
4976
|
+
const coverages = blobs.map((blob) => blob.coverage);
|
|
4977
|
+
return {
|
|
4978
|
+
files,
|
|
4979
|
+
errors,
|
|
4980
|
+
coverages
|
|
4981
|
+
};
|
|
4982
|
+
}
|
|
4983
|
+
|
|
4769
4984
|
const outputMap = /* @__PURE__ */ new WeakMap();
|
|
4770
4985
|
function formatFilepath(path) {
|
|
4771
4986
|
const lastSlash = Math.max(path.lastIndexOf("/") + 1, 0);
|
|
@@ -4778,7 +4993,7 @@ function formatFilepath(path) {
|
|
|
4778
4993
|
}
|
|
4779
4994
|
function formatNumber(number) {
|
|
4780
4995
|
const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
|
|
4781
|
-
return res[0].replace(/(?=(?:\d{3})+$)
|
|
4996
|
+
return res[0].replace(/(?=(?:\d{3})+$)\B/g, ",") + (res[1] ? `.${res[1]}` : "");
|
|
4782
4997
|
}
|
|
4783
4998
|
const tableHead = ["name", "hz", "min", "max", "mean", "p75", "p99", "p995", "p999", "rme", "samples"];
|
|
4784
4999
|
function renderBenchmarkItems(result) {
|
|
@@ -5078,6 +5293,7 @@ function createFormattedBenchamrkReport(files) {
|
|
|
5078
5293
|
benchmarks.push({
|
|
5079
5294
|
id: t.id,
|
|
5080
5295
|
sampleCount: samples.length,
|
|
5296
|
+
median: samples.length % 2 ? samples[Math.floor(samples.length / 2)] : (samples[samples.length / 2] + samples[samples.length / 2 - 1]) / 2,
|
|
5081
5297
|
...rest
|
|
5082
5298
|
});
|
|
5083
5299
|
}
|
|
@@ -5116,6 +5332,7 @@ const BenchmarkReportsMap = {
|
|
|
5116
5332
|
const ReportersMap = {
|
|
5117
5333
|
"default": DefaultReporter,
|
|
5118
5334
|
"basic": BasicReporter,
|
|
5335
|
+
"blob": BlobReporter,
|
|
5119
5336
|
"verbose": VerboseReporter,
|
|
5120
5337
|
"dot": DotReporter,
|
|
5121
5338
|
"json": JsonReporter,
|
|
@@ -5126,4 +5343,4 @@ const ReportersMap = {
|
|
|
5126
5343
|
"github-actions": GithubActionsReporter
|
|
5127
5344
|
};
|
|
5128
5345
|
|
|
5129
|
-
export { BaseSequencer as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter as J, Logger as L, ReportersMap as R, TapReporter as T, VerboseReporter as V, BasicReporter as a, DotReporter as b, JUnitReporter as c, TapFlatReporter as d, BenchmarkReportsMap as e, Typechecker as f, RandomSequencer as g, findNodeAround as h, generateCodeFrame as i, highlightCode as j, wrapSerializableConfig as w };
|
|
5346
|
+
export { BaseSequencer as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter as J, Logger as L, ReportersMap as R, TapReporter as T, VerboseReporter as V, BasicReporter as a, DotReporter as b, JUnitReporter as c, TapFlatReporter as d, BenchmarkReportsMap as e, Typechecker as f, RandomSequencer as g, findNodeAround as h, generateCodeFrame as i, highlightCode as j, BlobReporter as k, parse as p, readBlobs as r, stringify as s, wrapSerializableConfig as w };
|
|
@@ -4,7 +4,7 @@ import { distDir } from '../path.js';
|
|
|
4
4
|
import { g as getWorkerState } from './global.7bFbnyXl.js';
|
|
5
5
|
import { r as rpc } from './rpc.DRDE9Pu1.js';
|
|
6
6
|
import { t as takeCoverageInsideWorker } from './coverage.ChSqD-qS.js';
|
|
7
|
-
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.
|
|
7
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.BhJvzjns.js';
|
|
8
8
|
|
|
9
9
|
function setupChaiConfig(config) {
|
|
10
10
|
Object.assign(chai.config, config);
|
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
2
2
|
import { b as bench } from './benchmark.BNLebNi5.js';
|
|
3
|
-
import { i as isFirstRun, a as runOnce } from './run-once.DLomgGUH.js';
|
|
4
|
-
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.ClD3hi7L.js';
|
|
5
3
|
import { g as getWorkerState } from './global.7bFbnyXl.js';
|
|
4
|
+
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.C6AfDXK6.js';
|
|
6
5
|
import * as chai from 'chai';
|
|
7
6
|
import { assert, should } from 'chai';
|
|
8
7
|
|
|
8
|
+
const filesCount = /* @__PURE__ */ new Map();
|
|
9
|
+
const cache = /* @__PURE__ */ new Map();
|
|
10
|
+
function runOnce(fn, key) {
|
|
11
|
+
const filepath = getWorkerState().filepath || "__unknown_files__";
|
|
12
|
+
if (!key) {
|
|
13
|
+
filesCount.set(filepath, (filesCount.get(filepath) || 0) + 1);
|
|
14
|
+
key = String(filesCount.get(filepath));
|
|
15
|
+
}
|
|
16
|
+
const id = `${filepath}:${key}`;
|
|
17
|
+
if (!cache.has(id))
|
|
18
|
+
cache.set(id, fn());
|
|
19
|
+
return cache.get(id);
|
|
20
|
+
}
|
|
21
|
+
function isFirstRun() {
|
|
22
|
+
let firstRun = false;
|
|
23
|
+
runOnce(() => {
|
|
24
|
+
firstRun = true;
|
|
25
|
+
}, "__vitest_first_run__");
|
|
26
|
+
return firstRun;
|
|
27
|
+
}
|
|
28
|
+
function resetRunOnceCounter() {
|
|
29
|
+
filesCount.clear();
|
|
30
|
+
}
|
|
31
|
+
|
|
9
32
|
function getRunningMode() {
|
|
10
33
|
return process.env.VITEST_MODE === "WATCH" ? "watch" : "run";
|
|
11
34
|
}
|
|
@@ -128,4 +151,4 @@ var VitestIndex = /*#__PURE__*/Object.freeze({
|
|
|
128
151
|
vitest: vitest
|
|
129
152
|
});
|
|
130
153
|
|
|
131
|
-
export { VitestIndex as V,
|
|
154
|
+
export { VitestIndex as V, runOnce as a, inject as b, isWatchMode as c, dist as d, assertType as e, getRunningMode as g, isFirstRun as i, resetRunOnceCounter as r };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { setSafeTimers } from '@vitest/utils';
|
|
2
2
|
import { addSerializer } from '@vitest/snapshot';
|
|
3
|
-
import { r as resetRunOnceCounter } from './
|
|
3
|
+
import { r as resetRunOnceCounter } from './index.DwR86H5i.js';
|
|
4
4
|
|
|
5
5
|
let globalSetup = false;
|
|
6
6
|
async function setupCommonEnv(config) {
|
|
@@ -12,7 +12,7 @@ async function setupCommonEnv(config) {
|
|
|
12
12
|
globalSetup = true;
|
|
13
13
|
setSafeTimers();
|
|
14
14
|
if (config.globals)
|
|
15
|
-
(await import('../chunks/integrations-globals.
|
|
15
|
+
(await import('../chunks/integrations-globals.BK0Cn4q1.js')).registerApiGlobally();
|
|
16
16
|
}
|
|
17
17
|
function setupDefines(defines) {
|
|
18
18
|
for (const key in defines)
|
|
@@ -214,4 +214,4 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
|
214
214
|
spinnerMap: spinnerMap
|
|
215
215
|
});
|
|
216
216
|
|
|
217
|
-
export { F_RIGHT as F,
|
|
217
|
+
export { F_RIGHT as F, F_POINTER as a, getStateString as b, formatTimeString as c, countTestErrors as d, divider as e, formatProjectName as f, getStateSymbol as g, getCols as h, getHookStateSymbol as i, pointer as p, renderSnapshotSummary as r, stripAnsi as s, utils as u };
|