vitest 2.0.0-beta.1 → 2.0.0-beta.3
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 +1 -1
- package/dist/browser.js +1 -1
- package/dist/chunks/{integrations-globals.B5Jl0grA.js → integrations-globals.D0I8wu4f.js} +3 -3
- package/dist/chunks/{runtime-runBaseTests._dXkRAZc.js → runtime-runBaseTests.CsxVA4nP.js} +4 -4
- package/dist/cli.js +2 -2
- package/dist/config.cjs +3 -3
- package/dist/config.d.ts +2 -2
- package/dist/config.js +3 -3
- package/dist/coverage.d.ts +1 -1
- package/dist/environments.d.ts +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.js +3 -3
- package/dist/node.d.ts +3 -2
- package/dist/node.js +5 -5
- package/dist/{reporters-MGvT5U9f.d.ts → reporters-C-3dxOaA.d.ts} +166 -109
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +1 -1
- package/dist/runners.d.ts +3 -2
- package/dist/runners.js +4 -1
- package/dist/{suite-8WAe-urM.d.ts → suite-V5kCKZme.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/vendor/{base.VFkIJ66g.js → base.CfOCwoIE.js} +2 -2
- package/dist/vendor/{cac.DzKZaJu2.js → cac.f5m2SesE.js} +15 -8
- package/dist/vendor/{cli-api.DTeni0Qq.js → cli-api.pZNNj7LX.js} +140 -182
- package/dist/vendor/{constants.5SOfHUj0.js → constants.XmjJgDXx.js} +2 -2
- package/dist/vendor/{execute.CLLNVNnK.js → execute.Bwzklsfj.js} +1 -1
- package/dist/vendor/{index.BfoZyXD1.js → index.BHPXakMe.js} +1 -1
- package/dist/vendor/{index.CmILuxzC.js → index.BkeKAX-R.js} +1 -1
- package/dist/vendor/{index.CRxYS9H3.js → index.DOAUPIJU.js} +237 -40
- package/dist/vendor/{setup-common.XeoZAW8t.js → setup-common.6St9QHh1.js} +1 -1
- package/dist/vendor/{vi.ClD3hi7L.js → vi.B31D70yH.js} +75 -36
- package/dist/vendor/{vm.Bi3bljci.js → vm.rKHnSoLJ.js} +1 -1
- package/dist/workers/forks.js +2 -2
- package/dist/workers/runVmTests.js +4 -4
- package/dist/workers/threads.js +2 -2
- package/dist/workers/vmForks.js +2 -2
- package/dist/workers/vmThreads.js +2 -2
- package/dist/workers.d.ts +1 -1
- package/dist/workers.js +3 -3
- package/package.json +10 -10
|
@@ -15,7 +15,7 @@ import { isCI } from 'std-env';
|
|
|
15
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" : ""}`);
|
|
@@ -1040,10 +1148,10 @@ ${log.content}
|
|
|
1040
1148
|
`);
|
|
1041
1149
|
}
|
|
1042
1150
|
shouldLog(log) {
|
|
1043
|
-
var
|
|
1151
|
+
var _a, _b;
|
|
1044
1152
|
if (this.ctx.config.silent)
|
|
1045
1153
|
return false;
|
|
1046
|
-
const shouldLog = (_b = (
|
|
1154
|
+
const shouldLog = (_b = (_a = this.ctx.config).onConsoleLog) == null ? void 0 : _b.call(_a, log.content, log.type);
|
|
1047
1155
|
if (shouldLog === false)
|
|
1048
1156
|
return shouldLog;
|
|
1049
1157
|
return true;
|
|
@@ -1067,8 +1175,8 @@ ${log.content}
|
|
|
1067
1175
|
const collectTime = files.reduce((acc, test) => acc + Math.max(0, test.collectDuration || 0), 0);
|
|
1068
1176
|
const setupTime = files.reduce((acc, test) => acc + Math.max(0, test.setupDuration || 0), 0);
|
|
1069
1177
|
const testsTime = files.reduce((acc, test) => {
|
|
1070
|
-
var
|
|
1071
|
-
return acc + Math.max(0, ((
|
|
1178
|
+
var _a;
|
|
1179
|
+
return acc + Math.max(0, ((_a = test.result) == null ? void 0 : _a.duration) || 0);
|
|
1072
1180
|
}, 0);
|
|
1073
1181
|
const transformTime = this.ctx.projects.flatMap((w) => w.vitenode.getTotalDuration()).reduce((a, b) => a + b, 0);
|
|
1074
1182
|
const environmentTime = files.reduce((acc, file) => acc + Math.max(0, file.environmentLoad || 0), 0);
|
|
@@ -1092,8 +1200,8 @@ ${log.content}
|
|
|
1092
1200
|
logger.log(padTitle("Tests"), getStateString(tests));
|
|
1093
1201
|
if (this.ctx.projects.some((c2) => c2.config.typecheck.enabled)) {
|
|
1094
1202
|
const failed = tests.filter((t) => {
|
|
1095
|
-
var
|
|
1096
|
-
return ((
|
|
1203
|
+
var _a, _b, _c;
|
|
1204
|
+
return ((_a = t.meta) == null ? void 0 : _a.typecheck) && ((_c = (_b = t.result) == null ? void 0 : _b.errors) == null ? void 0 : _c.length);
|
|
1097
1205
|
});
|
|
1098
1206
|
logger.log(padTitle("Type Errors"), failed.length ? c.bold(c.red(`${failed.length} failed`)) : c.dim("no errors"));
|
|
1099
1207
|
}
|
|
@@ -1105,8 +1213,8 @@ ${log.content}
|
|
|
1105
1213
|
} else {
|
|
1106
1214
|
let timers = `transform ${time(transformTime)}, setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)}, environment ${time(environmentTime)}, prepare ${time(prepareTime)}`;
|
|
1107
1215
|
const typecheck = this.ctx.projects.reduce((acc, c2) => {
|
|
1108
|
-
var
|
|
1109
|
-
return acc + (((
|
|
1216
|
+
var _a;
|
|
1217
|
+
return acc + (((_a = c2.typechecker) == null ? void 0 : _a.getResult().time) || 0);
|
|
1110
1218
|
}, 0);
|
|
1111
1219
|
if (typecheck)
|
|
1112
1220
|
timers += `, typecheck ${time(typecheck)}`;
|
|
@@ -1119,12 +1227,12 @@ ${log.content}
|
|
|
1119
1227
|
const suites = getSuites(files);
|
|
1120
1228
|
const tests = getTests(files);
|
|
1121
1229
|
const failedSuites = suites.filter((i) => {
|
|
1122
|
-
var
|
|
1123
|
-
return (
|
|
1230
|
+
var _a;
|
|
1231
|
+
return (_a = i.result) == null ? void 0 : _a.errors;
|
|
1124
1232
|
});
|
|
1125
1233
|
const failedTests = tests.filter((i) => {
|
|
1126
|
-
var
|
|
1127
|
-
return ((
|
|
1234
|
+
var _a;
|
|
1235
|
+
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
1128
1236
|
});
|
|
1129
1237
|
const failedTotal = countTestErrors(failedSuites) + countTestErrors(failedTests);
|
|
1130
1238
|
let current = 1;
|
|
@@ -1150,8 +1258,8 @@ ${log.content}
|
|
|
1150
1258
|
const logger = this.ctx.logger;
|
|
1151
1259
|
const benches = getTests(files);
|
|
1152
1260
|
const topBenches = benches.filter((i) => {
|
|
1153
|
-
var
|
|
1154
|
-
return ((_b = (
|
|
1261
|
+
var _a, _b;
|
|
1262
|
+
return ((_b = (_a = i.result) == null ? void 0 : _a.benchmark) == null ? void 0 : _b.rank) === 1;
|
|
1155
1263
|
});
|
|
1156
1264
|
logger.log(`
|
|
1157
1265
|
${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
@@ -1163,8 +1271,8 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1163
1271
|
const groupName = getFullName(group, c.dim(" > "));
|
|
1164
1272
|
logger.log(` ${bench.name}${c.dim(` - ${groupName}`)}`);
|
|
1165
1273
|
const siblings = group.tasks.filter((i) => {
|
|
1166
|
-
var
|
|
1167
|
-
return i.meta.benchmark && ((
|
|
1274
|
+
var _a;
|
|
1275
|
+
return i.meta.benchmark && ((_a = i.result) == null ? void 0 : _a.benchmark) && i !== bench;
|
|
1168
1276
|
}).sort((a, b) => a.result.benchmark.rank - b.result.benchmark.rank);
|
|
1169
1277
|
if (siblings.length === 0) {
|
|
1170
1278
|
logger.log("");
|
|
@@ -1178,13 +1286,13 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1178
1286
|
}
|
|
1179
1287
|
}
|
|
1180
1288
|
printTaskErrors(tasks, errorDivider) {
|
|
1181
|
-
var
|
|
1289
|
+
var _a, _b, _c;
|
|
1182
1290
|
const errorsQueue = [];
|
|
1183
1291
|
for (const task of tasks) {
|
|
1184
|
-
(_b = (
|
|
1292
|
+
(_b = (_a = task.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.forEach((error) => {
|
|
1185
1293
|
const errorItem = (error == null ? void 0 : error.stackStr) && errorsQueue.find((i) => {
|
|
1186
|
-
var
|
|
1187
|
-
const hasStr = ((
|
|
1294
|
+
var _a2, _b2, _c2, _d;
|
|
1295
|
+
const hasStr = ((_a2 = i[0]) == null ? void 0 : _a2.stackStr) === error.stackStr;
|
|
1188
1296
|
if (!hasStr)
|
|
1189
1297
|
return false;
|
|
1190
1298
|
const currentProjectName = (task == null ? void 0 : task.projectName) || ((_b2 = task.file) == null ? void 0 : _b2.projectName);
|
|
@@ -2140,7 +2248,7 @@ function formatFilepath$1(path) {
|
|
|
2140
2248
|
}
|
|
2141
2249
|
function formatNumber$1(number) {
|
|
2142
2250
|
const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
|
|
2143
|
-
return res[0].replace(/(?=(?:\d{3})+$)
|
|
2251
|
+
return res[0].replace(/(?=(?:\d{3})+$)\B/g, ",") + (res[1] ? `.${res[1]}` : "");
|
|
2144
2252
|
}
|
|
2145
2253
|
function renderHookState(task, hookName, level = 0) {
|
|
2146
2254
|
var _a, _b;
|
|
@@ -4304,6 +4412,8 @@ const skipErrorProperties = /* @__PURE__ */ new Set([
|
|
|
4304
4412
|
"stackStr",
|
|
4305
4413
|
"type",
|
|
4306
4414
|
"showDiff",
|
|
4415
|
+
"ok",
|
|
4416
|
+
"operator",
|
|
4307
4417
|
"diff",
|
|
4308
4418
|
"codeFrame",
|
|
4309
4419
|
"actual",
|
|
@@ -4456,12 +4566,14 @@ function flattenTasks$1(task, baseName = "") {
|
|
|
4456
4566
|
}
|
|
4457
4567
|
}
|
|
4458
4568
|
function removeInvalidXMLCharacters(value, removeDiscouragedChars) {
|
|
4459
|
-
let regex = /(
|
|
4569
|
+
let regex = /([\0-\x08\v\f\x0E-\x1F\uFFFD\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g;
|
|
4460
4570
|
value = String(value || "").replace(regex, "");
|
|
4461
4571
|
{
|
|
4462
4572
|
regex = new RegExp(
|
|
4463
|
-
|
|
4573
|
+
/* eslint-disable regexp/prefer-character-class, regexp/no-obscure-range, regexp/no-useless-non-capturing-group */
|
|
4574
|
+
"([\\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
4575
|
"g"
|
|
4576
|
+
/* eslint-enable */
|
|
4465
4577
|
);
|
|
4466
4578
|
value = value.replace(regex, "");
|
|
4467
4579
|
}
|
|
@@ -4543,8 +4655,7 @@ class JUnitReporter {
|
|
|
4543
4655
|
async writeTasks(tasks, filename) {
|
|
4544
4656
|
for (const task of tasks) {
|
|
4545
4657
|
await this.writeElement("testcase", {
|
|
4546
|
-
|
|
4547
|
-
classname: this.options.classname ?? process.env.VITEST_JUNIT_CLASSNAME ?? filename,
|
|
4658
|
+
classname: this.options.classname ?? filename,
|
|
4548
4659
|
file: this.options.addFileAttribute ? filename : void 0,
|
|
4549
4660
|
name: task.name,
|
|
4550
4661
|
time: getDuration(task)
|
|
@@ -4628,8 +4739,7 @@ class JUnitReporter {
|
|
|
4628
4739
|
stats2.failures += file.stats.failures;
|
|
4629
4740
|
return stats2;
|
|
4630
4741
|
}, {
|
|
4631
|
-
|
|
4632
|
-
name: this.options.suiteName || process.env.VITEST_JUNIT_SUITE_NAME || "vitest tests",
|
|
4742
|
+
name: this.options.suiteName || "vitest tests",
|
|
4633
4743
|
tests: 0,
|
|
4634
4744
|
failures: 0,
|
|
4635
4745
|
errors: 0,
|
|
@@ -4766,6 +4876,92 @@ function escapeProperty(s) {
|
|
|
4766
4876
|
return s.replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/:/g, "%3A").replace(/,/g, "%2C");
|
|
4767
4877
|
}
|
|
4768
4878
|
|
|
4879
|
+
class BlobReporter {
|
|
4880
|
+
ctx;
|
|
4881
|
+
options;
|
|
4882
|
+
constructor(options) {
|
|
4883
|
+
this.options = options;
|
|
4884
|
+
}
|
|
4885
|
+
onInit(ctx) {
|
|
4886
|
+
if (ctx.config.watch)
|
|
4887
|
+
throw new Error("Blob reporter is not supported in watch mode");
|
|
4888
|
+
this.ctx = ctx;
|
|
4889
|
+
}
|
|
4890
|
+
async onFinished(files = [], errors = []) {
|
|
4891
|
+
let outputFile = this.options.outputFile ?? getOutputFile(this.ctx.config, "blob");
|
|
4892
|
+
if (!outputFile) {
|
|
4893
|
+
const shard = this.ctx.config.shard;
|
|
4894
|
+
outputFile = shard ? `.vitest-reports/blob-${shard.index}-${shard.count}.json` : ".vitest-reports/blob.json";
|
|
4895
|
+
}
|
|
4896
|
+
const moduleKeys = this.ctx.projects.map((project) => {
|
|
4897
|
+
return [project.getName(), [...project.server.moduleGraph.idToModuleMap.keys()]];
|
|
4898
|
+
});
|
|
4899
|
+
const report = stringify([this.ctx.version, files, errors, moduleKeys]);
|
|
4900
|
+
const reportFile = resolve(this.ctx.config.root, outputFile);
|
|
4901
|
+
const dir = dirname(reportFile);
|
|
4902
|
+
if (!existsSync(dir))
|
|
4903
|
+
await mkdir(dir, { recursive: true });
|
|
4904
|
+
await writeFile(
|
|
4905
|
+
reportFile,
|
|
4906
|
+
report,
|
|
4907
|
+
"utf-8"
|
|
4908
|
+
);
|
|
4909
|
+
this.ctx.logger.log("blob report written to", reportFile);
|
|
4910
|
+
}
|
|
4911
|
+
}
|
|
4912
|
+
async function readBlobs(blobsDirectory, projectsArray) {
|
|
4913
|
+
const resolvedDir = resolve(process.cwd(), blobsDirectory);
|
|
4914
|
+
const blobsFiles = await readdir(resolvedDir);
|
|
4915
|
+
const promises = blobsFiles.map(async (file) => {
|
|
4916
|
+
const content = await readFile(resolve(resolvedDir, file), "utf-8");
|
|
4917
|
+
const [version, files2, errors2, moduleKeys] = parse(content);
|
|
4918
|
+
return { version, files: files2, errors: errors2, moduleKeys };
|
|
4919
|
+
});
|
|
4920
|
+
const blobs = await Promise.all(promises);
|
|
4921
|
+
if (!blobs.length)
|
|
4922
|
+
throw new Error(`vitest.mergeReports() requires at least one blob file paths in the config`);
|
|
4923
|
+
const projects = Object.fromEntries(projectsArray.map((p) => [p.getName(), p]));
|
|
4924
|
+
blobs.forEach((blob) => {
|
|
4925
|
+
blob.moduleKeys.forEach(([projectName, moduleIds]) => {
|
|
4926
|
+
const project = projects[projectName];
|
|
4927
|
+
if (!project)
|
|
4928
|
+
return;
|
|
4929
|
+
moduleIds.forEach((moduleId) => {
|
|
4930
|
+
project.server.moduleGraph.idToModuleMap.set(moduleId, {
|
|
4931
|
+
id: moduleId,
|
|
4932
|
+
url: moduleId,
|
|
4933
|
+
file: cleanUrl(moduleId),
|
|
4934
|
+
ssrTransformResult: null,
|
|
4935
|
+
transformResult: null,
|
|
4936
|
+
importedBindings: null,
|
|
4937
|
+
importedModules: /* @__PURE__ */ new Set(),
|
|
4938
|
+
importers: /* @__PURE__ */ new Set(),
|
|
4939
|
+
type: "js",
|
|
4940
|
+
clientImportedModules: /* @__PURE__ */ new Set(),
|
|
4941
|
+
ssrError: null,
|
|
4942
|
+
ssrImportedModules: /* @__PURE__ */ new Set(),
|
|
4943
|
+
ssrModule: null,
|
|
4944
|
+
acceptedHmrDeps: /* @__PURE__ */ new Set(),
|
|
4945
|
+
acceptedHmrExports: null,
|
|
4946
|
+
lastHMRTimestamp: 0,
|
|
4947
|
+
lastInvalidationTimestamp: 0
|
|
4948
|
+
});
|
|
4949
|
+
});
|
|
4950
|
+
});
|
|
4951
|
+
});
|
|
4952
|
+
const files = blobs.flatMap((blob) => blob.files).sort((f1, f2) => {
|
|
4953
|
+
var _a, _b;
|
|
4954
|
+
const time1 = ((_a = f1.result) == null ? void 0 : _a.startTime) || 0;
|
|
4955
|
+
const time2 = ((_b = f2.result) == null ? void 0 : _b.startTime) || 0;
|
|
4956
|
+
return time1 - time2;
|
|
4957
|
+
});
|
|
4958
|
+
const errors = blobs.flatMap((blob) => blob.errors);
|
|
4959
|
+
return {
|
|
4960
|
+
files,
|
|
4961
|
+
errors
|
|
4962
|
+
};
|
|
4963
|
+
}
|
|
4964
|
+
|
|
4769
4965
|
const outputMap = /* @__PURE__ */ new WeakMap();
|
|
4770
4966
|
function formatFilepath(path) {
|
|
4771
4967
|
const lastSlash = Math.max(path.lastIndexOf("/") + 1, 0);
|
|
@@ -4778,7 +4974,7 @@ function formatFilepath(path) {
|
|
|
4778
4974
|
}
|
|
4779
4975
|
function formatNumber(number) {
|
|
4780
4976
|
const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
|
|
4781
|
-
return res[0].replace(/(?=(?:\d{3})+$)
|
|
4977
|
+
return res[0].replace(/(?=(?:\d{3})+$)\B/g, ",") + (res[1] ? `.${res[1]}` : "");
|
|
4782
4978
|
}
|
|
4783
4979
|
const tableHead = ["name", "hz", "min", "max", "mean", "p75", "p99", "p995", "p999", "rme", "samples"];
|
|
4784
4980
|
function renderBenchmarkItems(result) {
|
|
@@ -5116,6 +5312,7 @@ const BenchmarkReportsMap = {
|
|
|
5116
5312
|
const ReportersMap = {
|
|
5117
5313
|
"default": DefaultReporter,
|
|
5118
5314
|
"basic": BasicReporter,
|
|
5315
|
+
"blob": BlobReporter,
|
|
5119
5316
|
"verbose": VerboseReporter,
|
|
5120
5317
|
"dot": DotReporter,
|
|
5121
5318
|
"json": JsonReporter,
|
|
@@ -5126,4 +5323,4 @@ const ReportersMap = {
|
|
|
5126
5323
|
"github-actions": GithubActionsReporter
|
|
5127
5324
|
};
|
|
5128
5325
|
|
|
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 };
|
|
5326
|
+
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 };
|
|
@@ -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.D0I8wu4f.js')).registerApiGlobally();
|
|
16
16
|
}
|
|
17
17
|
function setupDefines(defines) {
|
|
18
18
|
for (const key in defines)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as chai$1 from 'chai';
|
|
2
2
|
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
|
|
3
|
-
import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT
|
|
3
|
+
import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters } from '@vitest/expect';
|
|
4
4
|
import { stripSnapshotIndentation, addSerializer, SnapshotClient } from '@vitest/snapshot';
|
|
5
5
|
import { getNames } from '@vitest/runner/utils';
|
|
6
6
|
import '@vitest/utils/error';
|
|
@@ -142,32 +142,6 @@ var chaiSubset = {exports: {}};
|
|
|
142
142
|
var chaiSubsetExports = chaiSubset.exports;
|
|
143
143
|
var Subset = /*@__PURE__*/getDefaultExportFromCjs(chaiSubsetExports);
|
|
144
144
|
|
|
145
|
-
const MATCHERS_OBJECT = Symbol.for("matchers-object");
|
|
146
|
-
const JEST_MATCHERS_OBJECT = Symbol.for("$$jest-matchers-object");
|
|
147
|
-
const GLOBAL_EXPECT = Symbol.for("expect-global");
|
|
148
|
-
const ASYMMETRIC_MATCHERS_OBJECT = Symbol.for("asymmetric-matchers-object");
|
|
149
|
-
|
|
150
|
-
if (!Object.prototype.hasOwnProperty.call(globalThis, MATCHERS_OBJECT)) {
|
|
151
|
-
const globalState = /* @__PURE__ */ new WeakMap();
|
|
152
|
-
const matchers = /* @__PURE__ */ Object.create(null);
|
|
153
|
-
const customEqualityTesters = [];
|
|
154
|
-
const assymetricMatchers = /* @__PURE__ */ Object.create(null);
|
|
155
|
-
Object.defineProperty(globalThis, MATCHERS_OBJECT, {
|
|
156
|
-
get: () => globalState
|
|
157
|
-
});
|
|
158
|
-
Object.defineProperty(globalThis, JEST_MATCHERS_OBJECT, {
|
|
159
|
-
configurable: true,
|
|
160
|
-
get: () => ({
|
|
161
|
-
state: globalState.get(globalThis[GLOBAL_EXPECT]),
|
|
162
|
-
matchers,
|
|
163
|
-
customEqualityTesters
|
|
164
|
-
})
|
|
165
|
-
});
|
|
166
|
-
Object.defineProperty(globalThis, ASYMMETRIC_MATCHERS_OBJECT, {
|
|
167
|
-
get: () => assymetricMatchers
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
145
|
function recordAsyncExpect(test, promise) {
|
|
172
146
|
if (test && promise instanceof Promise) {
|
|
173
147
|
promise = promise.finally(() => {
|
|
@@ -359,10 +333,78 @@ chai$1.use(Subset);
|
|
|
359
333
|
chai$1.use(SnapshotPlugin);
|
|
360
334
|
chai$1.use(JestAsymmetricMatchers);
|
|
361
335
|
|
|
336
|
+
const unsupported = [
|
|
337
|
+
// .poll is meant to retry matchers until they succeed, and
|
|
338
|
+
// snapshots will always succeed as long as the poll method doesn't thow an error
|
|
339
|
+
// in this case using the `vi.waitFor` method is more appropriate
|
|
340
|
+
"matchSnapshot",
|
|
341
|
+
"toMatchSnapshot",
|
|
342
|
+
"toMatchInlineSnapshot",
|
|
343
|
+
"toThrowErrorMatchingSnapshot",
|
|
344
|
+
"toThrowErrorMatchingInlineSnapshot",
|
|
345
|
+
// toThrow will never succeed because we call the poll callback until it doesn't throw
|
|
346
|
+
"throws",
|
|
347
|
+
"Throw",
|
|
348
|
+
"throw",
|
|
349
|
+
"toThrow",
|
|
350
|
+
"toThrowError"
|
|
351
|
+
// these are not supported because you can call them without `.poll`,
|
|
352
|
+
// we throw an error inside the rejects/resolves methods to prevent this
|
|
353
|
+
// rejects,
|
|
354
|
+
// resolves
|
|
355
|
+
];
|
|
356
|
+
function createExpectPoll(expect) {
|
|
357
|
+
return function poll(fn, options = {}) {
|
|
358
|
+
const { interval = 50, timeout = 1e3, message } = options;
|
|
359
|
+
const assertion = expect(null, message).withContext({ poll: true });
|
|
360
|
+
const proxy = new Proxy(assertion, {
|
|
361
|
+
get(target, key, receiver) {
|
|
362
|
+
const result = Reflect.get(target, key, receiver);
|
|
363
|
+
if (typeof result !== "function")
|
|
364
|
+
return result instanceof chai$1.Assertion ? proxy : result;
|
|
365
|
+
if (key === "assert")
|
|
366
|
+
return result;
|
|
367
|
+
if (typeof key === "string" && unsupported.includes(key))
|
|
368
|
+
throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
|
|
369
|
+
return function(...args) {
|
|
370
|
+
const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
|
|
371
|
+
return new Promise((resolve, reject) => {
|
|
372
|
+
let intervalId;
|
|
373
|
+
let lastError;
|
|
374
|
+
const { setTimeout, clearTimeout } = getSafeTimers();
|
|
375
|
+
const timeoutId = setTimeout(() => {
|
|
376
|
+
clearTimeout(intervalId);
|
|
377
|
+
reject(copyStackTrace$1(new Error(`Matcher did not succeed in ${timeout}ms`, { cause: lastError }), STACK_TRACE_ERROR));
|
|
378
|
+
}, timeout);
|
|
379
|
+
const check = async () => {
|
|
380
|
+
try {
|
|
381
|
+
chai$1.util.flag(this, "object", await fn());
|
|
382
|
+
resolve(await result.call(this, ...args));
|
|
383
|
+
clearTimeout(intervalId);
|
|
384
|
+
clearTimeout(timeoutId);
|
|
385
|
+
} catch (err) {
|
|
386
|
+
lastError = err;
|
|
387
|
+
intervalId = setTimeout(check, interval);
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
check();
|
|
391
|
+
});
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
return proxy;
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
function copyStackTrace$1(target, source) {
|
|
399
|
+
if (source.stack !== void 0)
|
|
400
|
+
target.stack = source.stack.replace(source.message, target.message);
|
|
401
|
+
return target;
|
|
402
|
+
}
|
|
403
|
+
|
|
362
404
|
function createExpect(test) {
|
|
363
405
|
const expect = (value, message) => {
|
|
364
406
|
const { assertionCalls } = getState(expect);
|
|
365
|
-
setState({ assertionCalls: assertionCalls + 1
|
|
407
|
+
setState({ assertionCalls: assertionCalls + 1 }, expect);
|
|
366
408
|
const assert2 = chai$1.expect(value, message);
|
|
367
409
|
const _test = test || getCurrentTest();
|
|
368
410
|
if (_test)
|
|
@@ -371,10 +413,10 @@ function createExpect(test) {
|
|
|
371
413
|
return assert2;
|
|
372
414
|
};
|
|
373
415
|
Object.assign(expect, chai$1.expect);
|
|
374
|
-
Object.assign(expect, globalThis[ASYMMETRIC_MATCHERS_OBJECT
|
|
416
|
+
Object.assign(expect, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
|
|
375
417
|
expect.getState = () => getState(expect);
|
|
376
418
|
expect.setState = (state) => setState(state, expect);
|
|
377
|
-
const globalState = getState(globalThis[GLOBAL_EXPECT
|
|
419
|
+
const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
|
|
378
420
|
const testPath = getTestFile(test);
|
|
379
421
|
setState({
|
|
380
422
|
// this should also add "snapshotState" that is added conditionally
|
|
@@ -391,12 +433,9 @@ function createExpect(test) {
|
|
|
391
433
|
expect.extend = (matchers) => chai$1.expect.extend(expect, matchers);
|
|
392
434
|
expect.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
|
|
393
435
|
expect.soft = (...args) => {
|
|
394
|
-
|
|
395
|
-
expect.setState({
|
|
396
|
-
soft: true
|
|
397
|
-
});
|
|
398
|
-
return assert2;
|
|
436
|
+
return expect(...args).withContext({ soft: true });
|
|
399
437
|
};
|
|
438
|
+
expect.poll = createExpectPoll(expect);
|
|
400
439
|
expect.unreachable = (message) => {
|
|
401
440
|
chai$1.assert.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
|
|
402
441
|
};
|
|
@@ -429,7 +468,7 @@ function getTestFile(test) {
|
|
|
429
468
|
return state.filepath;
|
|
430
469
|
}
|
|
431
470
|
const globalExpect = createExpect();
|
|
432
|
-
Object.defineProperty(globalThis, GLOBAL_EXPECT
|
|
471
|
+
Object.defineProperty(globalThis, GLOBAL_EXPECT, {
|
|
433
472
|
value: globalExpect,
|
|
434
473
|
writable: true,
|
|
435
474
|
configurable: true
|
|
@@ -2,7 +2,7 @@ import vm, { isContext } from 'node:vm';
|
|
|
2
2
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
3
3
|
import { dirname, basename, extname, normalize, join, resolve } from 'pathe';
|
|
4
4
|
import { createCustomConsole } from '../chunks/runtime-console.CUES-L8X.js';
|
|
5
|
-
import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.
|
|
5
|
+
import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.Bwzklsfj.js';
|
|
6
6
|
import { distDir } from '../path.js';
|
|
7
7
|
import { dirname as dirname$1 } from 'node:path';
|
|
8
8
|
import { statSync, existsSync, promises, readFileSync } from 'node:fs';
|
package/dist/workers/forks.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import v8 from 'node:v8';
|
|
2
2
|
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../vendor/utils.CUjzkRH7.js';
|
|
3
|
-
import { r as runBaseTests } from '../vendor/base.
|
|
3
|
+
import { r as runBaseTests } from '../vendor/base.CfOCwoIE.js';
|
|
4
4
|
import '@vitest/utils';
|
|
5
5
|
import 'vite-node/client';
|
|
6
6
|
import '../vendor/global.7bFbnyXl.js';
|
|
7
|
-
import '../vendor/execute.
|
|
7
|
+
import '../vendor/execute.Bwzklsfj.js';
|
|
8
8
|
import 'node:vm';
|
|
9
9
|
import 'node:url';
|
|
10
10
|
import 'node:fs';
|
|
@@ -6,11 +6,11 @@ import { performance } from 'node:perf_hooks';
|
|
|
6
6
|
import { startTests } from '@vitest/runner';
|
|
7
7
|
import { setupColors, createColors } from '@vitest/utils';
|
|
8
8
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
9
|
-
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../vendor/index.
|
|
9
|
+
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../vendor/index.BHPXakMe.js';
|
|
10
10
|
import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from '../vendor/coverage.ChSqD-qS.js';
|
|
11
11
|
import { g as getWorkerState } from '../vendor/global.7bFbnyXl.js';
|
|
12
|
-
import { V as VitestIndex } from '../vendor/index.
|
|
13
|
-
import { s as setupCommonEnv } from '../vendor/setup-common.
|
|
12
|
+
import { V as VitestIndex } from '../vendor/index.BkeKAX-R.js';
|
|
13
|
+
import { s as setupCommonEnv } from '../vendor/setup-common.6St9QHh1.js';
|
|
14
14
|
import { c as closeInspector } from '../vendor/inspector.hPQncR7V.js';
|
|
15
15
|
import 'chai';
|
|
16
16
|
import 'pathe';
|
|
@@ -24,7 +24,7 @@ import '../vendor/index._7XLd8Kd.js';
|
|
|
24
24
|
import '../vendor/env.bmJgw1qP.js';
|
|
25
25
|
import 'std-env';
|
|
26
26
|
import '../vendor/run-once.DLomgGUH.js';
|
|
27
|
-
import '../vendor/vi.
|
|
27
|
+
import '../vendor/vi.B31D70yH.js';
|
|
28
28
|
import '../vendor/_commonjsHelpers.BFTU3MAI.js';
|
|
29
29
|
import '@vitest/expect';
|
|
30
30
|
import '@vitest/snapshot';
|