vitest 1.4.0 → 1.5.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 +5 -1
- package/dist/browser.js +1 -1
- package/dist/chunks/{integrations-globals.trMeEBob.js → integrations-globals.k0N5-dd1.js} +3 -3
- package/dist/chunks/{runtime-console.tUKE_2UJ.js → runtime-console.kbFEN7E-.js} +14 -6
- package/dist/chunks/{runtime-runBaseTests.SKlFOhuq.js → runtime-runBaseTests.-x-nNuJ_.js} +11 -9
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +3 -61
- package/dist/config.cjs +1 -0
- package/dist/config.d.ts +2 -1
- package/dist/config.js +1 -0
- package/dist/coverage.d.ts +4 -2
- package/dist/coverage.js +2 -2
- package/dist/environments.d.ts +2 -1
- package/dist/execute.d.ts +2 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -3
- package/dist/node.d.ts +26 -4
- package/dist/node.js +15 -13
- package/dist/{reporters-P7C2ytIv.d.ts → reporters-xEmem8D4.d.ts} +124 -49
- package/dist/reporters.d.ts +2 -1
- package/dist/reporters.js +5 -4
- package/dist/runners.d.ts +2 -1
- package/dist/runners.js +3 -3
- package/dist/{suite-a18diDsI.d.ts → suite-HPAKvIxA.d.ts} +1 -1
- package/dist/suite.d.ts +3 -2
- package/dist/vendor/{base.nhvUBzQY.js → base.gAwDs8Jc.js} +1 -1
- package/dist/vendor/cac.4YOY8W-L.js +1406 -0
- package/dist/vendor/{cac.RvTIWZBK.js → cli-api.5cFYj0Lq.js} +178 -1499
- package/dist/vendor/{constants.K-Wf1PUy.js → constants.5J7I254_.js} +2 -1
- package/dist/vendor/{index.BeX1oZht.js → index.0RrMQKD8.js} +1 -1
- package/dist/vendor/{index.LNWuEnUT.js → index.gHZzsRJQ.js} +1 -1
- package/dist/vendor/{index.e9RDLAeW.js → index.waF5pgqJ.js} +52 -214
- package/dist/vendor/inspector.IgLX3ur5.js +54 -0
- package/dist/vendor/{setup-common.vyF1kALR.js → setup-common.7SXMSI--.js} +11 -1
- package/dist/vendor/{utils.w0xgzP1h.js → utils.0uYuCbzo.js} +5 -2
- package/dist/vendor/utils.VYmeMh-u.js +217 -0
- package/dist/vendor/{vi.JYQecGiw.js → vi.Y_w82WR8.js} +26 -21
- package/dist/vendor/{vm.cAHVDF92.js → vm.I_IsyNig.js} +2 -2
- package/dist/worker.js +2 -39
- package/dist/workers/forks.js +2 -2
- package/dist/workers/runVmTests.js +10 -4
- package/dist/workers/threads.js +2 -2
- package/dist/workers/vmForks.js +7 -7
- package/dist/workers/vmThreads.js +7 -7
- package/dist/workers.d.ts +2 -1
- package/dist/workers.js +8 -7
- package/package.json +11 -11
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const defaultPort = 51204;
|
|
2
2
|
const defaultBrowserPort = 63315;
|
|
3
|
+
const defaultInspectPort = 9229;
|
|
3
4
|
const EXIT_CODE_RESTART = 43;
|
|
4
5
|
const API_PATH = "/__vitest_api__";
|
|
5
6
|
const extraInlineDeps = [
|
|
@@ -61,4 +62,4 @@ const globalApis = [
|
|
|
61
62
|
"onTestFailed"
|
|
62
63
|
];
|
|
63
64
|
|
|
64
|
-
export { API_PATH as A, CONFIG_NAMES as C, EXIT_CODE_RESTART as E, defaultBrowserPort as a, configFiles as c, defaultPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
|
|
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 };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
2
2
|
import { b as bench } from './benchmark.eeqk2rd8.js';
|
|
3
3
|
import { i as isFirstRun, a as runOnce } from './run-once.Olz_Zkd8.js';
|
|
4
|
-
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.
|
|
4
|
+
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.Y_w82WR8.js';
|
|
5
5
|
import { g as getWorkerState } from './global.CkGT_TMy.js';
|
|
6
6
|
import * as chai from 'chai';
|
|
7
7
|
import { assert, should } from 'chai';
|
|
@@ -5,7 +5,7 @@ import { distDir } from '../path.js';
|
|
|
5
5
|
import { g as getWorkerState } from './global.CkGT_TMy.js';
|
|
6
6
|
import { r as rpc } from './rpc.joBhAkyK.js';
|
|
7
7
|
import { t as takeCoverageInsideWorker } from './coverage.E7sG1b3r.js';
|
|
8
|
-
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.
|
|
8
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.7SXMSI--.js';
|
|
9
9
|
|
|
10
10
|
function setupChaiConfig(config) {
|
|
11
11
|
Object.assign(chai.config, config);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { existsSync, promises, readFileSync } from 'node:fs';
|
|
2
|
-
import {
|
|
2
|
+
import { basename, dirname, resolve, join, relative, extname, normalize } from 'pathe';
|
|
3
3
|
import { a as isNode, r as relativePath } from './index.ir9i0ywP.js';
|
|
4
4
|
import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, getTests, hasFailed, getSuites } from '@vitest/runner/utils';
|
|
5
5
|
import c from 'picocolors';
|
|
6
|
+
import { g as getStateSymbol, f as formatProjectName, p as pointer, F as F_RIGHT, r as renderSnapshotSummary, a as getStateString, b as formatTimeString, c as countTestErrors, d as divider, s as stripAnsi, e as getCols, h as getHookStateSymbol, i as F_POINTER } from './utils.VYmeMh-u.js';
|
|
6
7
|
import { getSafeTimers, notNullish, inspect, positionToOffset, lineSplitRE, highlight, shuffle } from '@vitest/utils';
|
|
7
|
-
import { performance } from 'node:perf_hooks';
|
|
8
|
-
import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.tUKE_2UJ.js';
|
|
9
|
-
import { a as slash, t as toArray, b as isPrimitive } from './base.Xt0Omgh7.js';
|
|
10
8
|
import { g as getFullName, h as hasFailedSnapshot } from './tasks.IknbGB2n.js';
|
|
9
|
+
import { performance } from 'node:perf_hooks';
|
|
10
|
+
import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.kbFEN7E-.js';
|
|
11
|
+
import { t as toArray, b as isPrimitive } from './base.Xt0Omgh7.js';
|
|
11
12
|
import { isCI } from 'std-env';
|
|
12
13
|
import { TraceMap, generatedPositionFor, parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
13
14
|
import nodeos__default, { hostname } from 'node:os';
|
|
14
15
|
import { createRequire } from 'node:module';
|
|
15
|
-
import { Console } from 'node:console';
|
|
16
16
|
import { Writable } from 'node:stream';
|
|
17
17
|
import { writeFile, rm } from 'node:fs/promises';
|
|
18
18
|
import { execa } from 'execa';
|
|
@@ -22,204 +22,13 @@ import require$$0 from 'fs';
|
|
|
22
22
|
import ge from 'module';
|
|
23
23
|
import { parseAstAsync } from 'vite';
|
|
24
24
|
import { ancestor } from 'acorn-walk';
|
|
25
|
+
import { Console } from 'node:console';
|
|
25
26
|
import process$2 from 'node:process';
|
|
26
27
|
import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './_commonjsHelpers.jjO7Zipk.js';
|
|
27
28
|
import require$$0$2 from 'assert';
|
|
28
29
|
import require$$0$1 from 'events';
|
|
29
30
|
import { createHash } from 'node:crypto';
|
|
30
|
-
import { slash
|
|
31
|
-
|
|
32
|
-
function ansiRegex({onlyFirst = false} = {}) {
|
|
33
|
-
const pattern = [
|
|
34
|
-
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
|
35
|
-
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
|
|
36
|
-
].join('|');
|
|
37
|
-
|
|
38
|
-
return new RegExp(pattern, onlyFirst ? undefined : 'g');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const regex = ansiRegex();
|
|
42
|
-
|
|
43
|
-
function stripAnsi(string) {
|
|
44
|
-
if (typeof string !== 'string') {
|
|
45
|
-
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Even though the regex is global, we don't need to reset the `.lastIndex`
|
|
49
|
-
// because unlike `.exec()` and `.test()`, `.replace()` does it automatically
|
|
50
|
-
// and doing it manually has a performance penalty.
|
|
51
|
-
return string.replace(regex, '');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const F_RIGHT = "\u2192";
|
|
55
|
-
const F_DOWN = "\u2193";
|
|
56
|
-
const F_DOWN_RIGHT = "\u21B3";
|
|
57
|
-
const F_POINTER = "\u276F";
|
|
58
|
-
const F_DOT = "\xB7";
|
|
59
|
-
const F_CHECK = "\u2713";
|
|
60
|
-
const F_CROSS = "\xD7";
|
|
61
|
-
const F_LONG_DASH = "\u23AF";
|
|
62
|
-
|
|
63
|
-
const spinnerMap = /* @__PURE__ */ new WeakMap();
|
|
64
|
-
const hookSpinnerMap = /* @__PURE__ */ new WeakMap();
|
|
65
|
-
const pointer = c.yellow(F_POINTER);
|
|
66
|
-
const skipped = c.dim(c.gray(F_DOWN));
|
|
67
|
-
function getCols(delta = 0) {
|
|
68
|
-
var _a;
|
|
69
|
-
let length = (_a = process.stdout) == null ? void 0 : _a.columns;
|
|
70
|
-
if (!length || Number.isNaN(length))
|
|
71
|
-
length = 30;
|
|
72
|
-
return Math.max(length + delta, 0);
|
|
73
|
-
}
|
|
74
|
-
function divider(text, left, right) {
|
|
75
|
-
const cols = getCols();
|
|
76
|
-
if (text) {
|
|
77
|
-
const textLength = stripAnsi(text).length;
|
|
78
|
-
if (left == null && right != null) {
|
|
79
|
-
left = cols - textLength - right;
|
|
80
|
-
} else {
|
|
81
|
-
left = left ?? Math.floor((cols - textLength) / 2);
|
|
82
|
-
right = cols - textLength - left;
|
|
83
|
-
}
|
|
84
|
-
left = Math.max(0, left);
|
|
85
|
-
right = Math.max(0, right);
|
|
86
|
-
return `${F_LONG_DASH.repeat(left)}${text}${F_LONG_DASH.repeat(right)}`;
|
|
87
|
-
}
|
|
88
|
-
return F_LONG_DASH.repeat(cols);
|
|
89
|
-
}
|
|
90
|
-
function formatTestPath(root, path) {
|
|
91
|
-
var _a;
|
|
92
|
-
if (isAbsolute(path))
|
|
93
|
-
path = relative(root, path);
|
|
94
|
-
const dir = dirname(path);
|
|
95
|
-
const ext = ((_a = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)) == null ? void 0 : _a[0]) || "";
|
|
96
|
-
const base = basename(path, ext);
|
|
97
|
-
return slash(c.dim(`${dir}/`) + c.bold(base)) + c.dim(ext);
|
|
98
|
-
}
|
|
99
|
-
function renderSnapshotSummary(rootDir, snapshots) {
|
|
100
|
-
const summary = [];
|
|
101
|
-
if (snapshots.added)
|
|
102
|
-
summary.push(c.bold(c.green(`${snapshots.added} written`)));
|
|
103
|
-
if (snapshots.unmatched)
|
|
104
|
-
summary.push(c.bold(c.red(`${snapshots.unmatched} failed`)));
|
|
105
|
-
if (snapshots.updated)
|
|
106
|
-
summary.push(c.bold(c.green(`${snapshots.updated} updated `)));
|
|
107
|
-
if (snapshots.filesRemoved) {
|
|
108
|
-
if (snapshots.didUpdate)
|
|
109
|
-
summary.push(c.bold(c.green(`${snapshots.filesRemoved} files removed `)));
|
|
110
|
-
else
|
|
111
|
-
summary.push(c.bold(c.yellow(`${snapshots.filesRemoved} files obsolete `)));
|
|
112
|
-
}
|
|
113
|
-
if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) {
|
|
114
|
-
const [head, ...tail] = snapshots.filesRemovedList;
|
|
115
|
-
summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, head)}`);
|
|
116
|
-
tail.forEach((key) => {
|
|
117
|
-
summary.push(` ${c.gray(F_DOT)} ${formatTestPath(rootDir, key)}`);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
if (snapshots.unchecked) {
|
|
121
|
-
if (snapshots.didUpdate)
|
|
122
|
-
summary.push(c.bold(c.green(`${snapshots.unchecked} removed`)));
|
|
123
|
-
else
|
|
124
|
-
summary.push(c.bold(c.yellow(`${snapshots.unchecked} obsolete`)));
|
|
125
|
-
snapshots.uncheckedKeysByFile.forEach((uncheckedFile) => {
|
|
126
|
-
summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
|
|
127
|
-
uncheckedFile.keys.forEach((key) => summary.push(` ${c.gray(F_DOT)} ${key}`));
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
return summary;
|
|
131
|
-
}
|
|
132
|
-
function countTestErrors(tasks) {
|
|
133
|
-
return tasks.reduce((c2, i) => {
|
|
134
|
-
var _a, _b;
|
|
135
|
-
return c2 + (((_b = (_a = i.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.length) || 0);
|
|
136
|
-
}, 0);
|
|
137
|
-
}
|
|
138
|
-
function getStateString(tasks, name = "tests", showTotal = true) {
|
|
139
|
-
if (tasks.length === 0)
|
|
140
|
-
return c.dim(`no ${name}`);
|
|
141
|
-
const passed = tasks.filter((i) => {
|
|
142
|
-
var _a;
|
|
143
|
-
return ((_a = i.result) == null ? void 0 : _a.state) === "pass";
|
|
144
|
-
});
|
|
145
|
-
const failed = tasks.filter((i) => {
|
|
146
|
-
var _a;
|
|
147
|
-
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
148
|
-
});
|
|
149
|
-
const skipped2 = tasks.filter((i) => i.mode === "skip");
|
|
150
|
-
const todo = tasks.filter((i) => i.mode === "todo");
|
|
151
|
-
return [
|
|
152
|
-
failed.length ? c.bold(c.red(`${failed.length} failed`)) : null,
|
|
153
|
-
passed.length ? c.bold(c.green(`${passed.length} passed`)) : null,
|
|
154
|
-
skipped2.length ? c.yellow(`${skipped2.length} skipped`) : null,
|
|
155
|
-
todo.length ? c.gray(`${todo.length} todo`) : null
|
|
156
|
-
].filter(Boolean).join(c.dim(" | ")) + (showTotal ? c.gray(` (${tasks.length})`) : "");
|
|
157
|
-
}
|
|
158
|
-
function getStateSymbol(task) {
|
|
159
|
-
var _a;
|
|
160
|
-
if (task.mode === "skip" || task.mode === "todo")
|
|
161
|
-
return skipped;
|
|
162
|
-
if (!task.result)
|
|
163
|
-
return c.gray("\xB7");
|
|
164
|
-
if (task.result.state === "run") {
|
|
165
|
-
if (task.type === "suite")
|
|
166
|
-
return pointer;
|
|
167
|
-
let spinner = spinnerMap.get(task);
|
|
168
|
-
if (!spinner) {
|
|
169
|
-
spinner = elegantSpinner();
|
|
170
|
-
spinnerMap.set(task, spinner);
|
|
171
|
-
}
|
|
172
|
-
return c.yellow(spinner());
|
|
173
|
-
}
|
|
174
|
-
if (task.result.state === "pass") {
|
|
175
|
-
return ((_a = task.meta) == null ? void 0 : _a.benchmark) ? c.green(F_DOT) : c.green(F_CHECK);
|
|
176
|
-
}
|
|
177
|
-
if (task.result.state === "fail") {
|
|
178
|
-
return task.type === "suite" ? pointer : c.red(F_CROSS);
|
|
179
|
-
}
|
|
180
|
-
return " ";
|
|
181
|
-
}
|
|
182
|
-
function getHookStateSymbol(task, hookName) {
|
|
183
|
-
var _a, _b;
|
|
184
|
-
const state = (_b = (_a = task.result) == null ? void 0 : _a.hooks) == null ? void 0 : _b[hookName];
|
|
185
|
-
if (state && state === "run") {
|
|
186
|
-
let spinnerMap2 = hookSpinnerMap.get(task);
|
|
187
|
-
if (!spinnerMap2) {
|
|
188
|
-
spinnerMap2 = /* @__PURE__ */ new Map();
|
|
189
|
-
hookSpinnerMap.set(task, spinnerMap2);
|
|
190
|
-
}
|
|
191
|
-
let spinner = spinnerMap2.get(hookName);
|
|
192
|
-
if (!spinner) {
|
|
193
|
-
spinner = elegantSpinner();
|
|
194
|
-
spinnerMap2.set(hookName, spinner);
|
|
195
|
-
}
|
|
196
|
-
return c.yellow(spinner());
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
const spinnerFrames = process.platform === "win32" ? ["-", "\\", "|", "/"] : ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
200
|
-
function elegantSpinner() {
|
|
201
|
-
let index = 0;
|
|
202
|
-
return () => {
|
|
203
|
-
index = ++index % spinnerFrames.length;
|
|
204
|
-
return spinnerFrames[index];
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
function formatTimeString(date) {
|
|
208
|
-
return date.toTimeString().split(" ")[0];
|
|
209
|
-
}
|
|
210
|
-
function formatProjectName(name, suffix = " ") {
|
|
211
|
-
if (!name)
|
|
212
|
-
return "";
|
|
213
|
-
const index = name.split("").reduce((acc, v, idx) => acc + v.charCodeAt(0) + idx, 0);
|
|
214
|
-
const colors = [
|
|
215
|
-
c.blue,
|
|
216
|
-
c.yellow,
|
|
217
|
-
c.cyan,
|
|
218
|
-
c.green,
|
|
219
|
-
c.magenta
|
|
220
|
-
];
|
|
221
|
-
return colors[index % colors.length](`|${name}|`) + suffix;
|
|
222
|
-
}
|
|
31
|
+
import { slash } from 'vite-node/utils';
|
|
223
32
|
|
|
224
33
|
const REGEXP_WRAP_PREFIX = "$$vitest:";
|
|
225
34
|
function getOutputFile(config, reporter) {
|
|
@@ -902,7 +711,8 @@ ${PROJECT_FILTER}${FILENAME_PATTERN}${TESTNAME_PATTERN}`);
|
|
|
902
711
|
return;
|
|
903
712
|
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
|
|
904
713
|
const header = c.gray(log.type + c.dim(` | ${task ? getFullName(task, c.dim(" > ")) : log.taskId !== UNKNOWN_TEST_ID ? log.taskId : "unknown test"}`));
|
|
905
|
-
|
|
714
|
+
const output = log.type === "stdout" ? this.ctx.logger.outputStream : this.ctx.logger.errorStream;
|
|
715
|
+
output.write(`${header}
|
|
906
716
|
${log.content}
|
|
907
717
|
`);
|
|
908
718
|
}
|
|
@@ -1031,8 +841,12 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1031
841
|
logger.log(` ${bench.name}${c.dim(` - ${groupName}`)}`);
|
|
1032
842
|
const siblings = group.tasks.filter((i) => {
|
|
1033
843
|
var _a2;
|
|
1034
|
-
return ((_a2 = i.result) == null ? void 0 : _a2.benchmark) && i !== bench;
|
|
844
|
+
return i.meta.benchmark && ((_a2 = i.result) == null ? void 0 : _a2.benchmark) && i !== bench;
|
|
1035
845
|
}).sort((a, b) => a.result.benchmark.rank - b.result.benchmark.rank);
|
|
846
|
+
if (siblings.length === 0) {
|
|
847
|
+
logger.log("");
|
|
848
|
+
continue;
|
|
849
|
+
}
|
|
1036
850
|
for (const sibling of siblings) {
|
|
1037
851
|
const number = `${(sibling.result.benchmark.mean / bench.result.benchmark.mean).toFixed(2)}x`;
|
|
1038
852
|
logger.log(` ${c.green(number)} ${c.gray("faster than")} ${sibling.name}`);
|
|
@@ -2296,8 +2110,9 @@ function createDotRenderer(_tasks, options) {
|
|
|
2296
2110
|
let tasks = _tasks;
|
|
2297
2111
|
let timer;
|
|
2298
2112
|
const { logUpdate: log, outputStream } = options.logger;
|
|
2113
|
+
const columns = "columns" in outputStream ? outputStream.columns : 80;
|
|
2299
2114
|
function update() {
|
|
2300
|
-
log(render(tasks,
|
|
2115
|
+
log(render(tasks, columns));
|
|
2301
2116
|
}
|
|
2302
2117
|
return {
|
|
2303
2118
|
start() {
|
|
@@ -2316,7 +2131,7 @@ function createDotRenderer(_tasks, options) {
|
|
|
2316
2131
|
timer = void 0;
|
|
2317
2132
|
}
|
|
2318
2133
|
log.clear();
|
|
2319
|
-
options.logger.log(render(tasks,
|
|
2134
|
+
options.logger.log(render(tasks, columns));
|
|
2320
2135
|
return this;
|
|
2321
2136
|
},
|
|
2322
2137
|
clear() {
|
|
@@ -3102,7 +2917,7 @@ function generateCodeFrame(source, indent = 0, loc, range = 2) {
|
|
|
3102
2917
|
if (j < 0 || j >= lines.length)
|
|
3103
2918
|
continue;
|
|
3104
2919
|
const lineLength = lines[j].length;
|
|
3105
|
-
if (
|
|
2920
|
+
if (stripAnsi(lines[j]).length > 200)
|
|
3106
2921
|
return "";
|
|
3107
2922
|
res.push(lineNo(j + 1) + cliTruncate(lines[j].replace(/\t/g, " "), columns - 5 - indent));
|
|
3108
2923
|
if (j === i) {
|
|
@@ -4324,7 +4139,7 @@ createLogUpdate(process$2.stdout);
|
|
|
4324
4139
|
|
|
4325
4140
|
createLogUpdate(process$2.stderr);
|
|
4326
4141
|
|
|
4327
|
-
var version = "1.
|
|
4142
|
+
var version = "1.5.1";
|
|
4328
4143
|
|
|
4329
4144
|
const HIGHLIGHT_SUPPORTED_EXTS = new Set(["js", "ts"].flatMap((lang) => [
|
|
4330
4145
|
`.${lang}`,
|
|
@@ -4355,7 +4170,7 @@ class BaseSequencer {
|
|
|
4355
4170
|
const shardStart = shardSize * (index - 1);
|
|
4356
4171
|
const shardEnd = shardSize * index;
|
|
4357
4172
|
return [...files].map((spec) => {
|
|
4358
|
-
const fullPath = resolve(slash
|
|
4173
|
+
const fullPath = resolve(slash(config.root), slash(spec[1]));
|
|
4359
4174
|
const specPath = fullPath == null ? void 0 : fullPath.slice(config.root.length);
|
|
4360
4175
|
return {
|
|
4361
4176
|
spec,
|
|
@@ -4400,16 +4215,18 @@ const ERASE_SCROLLBACK = `${ESC}3J`;
|
|
|
4400
4215
|
const CURSOR_TO_START = `${ESC}1;1H`;
|
|
4401
4216
|
const CLEAR_SCREEN = "\x1Bc";
|
|
4402
4217
|
class Logger {
|
|
4403
|
-
constructor(ctx,
|
|
4218
|
+
constructor(ctx, outputStream = process.stdout, errorStream = process.stderr) {
|
|
4404
4219
|
this.ctx = ctx;
|
|
4405
|
-
this.
|
|
4220
|
+
this.outputStream = outputStream;
|
|
4221
|
+
this.errorStream = errorStream;
|
|
4222
|
+
this.console = new Console({ stdout: outputStream, stderr: errorStream });
|
|
4223
|
+
this.logUpdate = createLogUpdate(this.outputStream);
|
|
4406
4224
|
this._highlights.clear();
|
|
4407
4225
|
}
|
|
4408
|
-
|
|
4409
|
-
errorStream = process.stderr;
|
|
4410
|
-
logUpdate = createLogUpdate(process.stdout);
|
|
4226
|
+
logUpdate;
|
|
4411
4227
|
_clearScreenPending;
|
|
4412
4228
|
_highlights = /* @__PURE__ */ new Map();
|
|
4229
|
+
console;
|
|
4413
4230
|
log(...args) {
|
|
4414
4231
|
this._clearScreen();
|
|
4415
4232
|
this.console.log(...args);
|
|
@@ -4623,7 +4440,7 @@ async function printErrorWrapper(error, ctx, project) {
|
|
|
4623
4440
|
});
|
|
4624
4441
|
const result = await printError(error, project, {
|
|
4625
4442
|
showCodeFrame: false,
|
|
4626
|
-
logger: new Logger(ctx,
|
|
4443
|
+
logger: new Logger(ctx, writable, writable)
|
|
4627
4444
|
});
|
|
4628
4445
|
return { nearest: result == null ? void 0 : result.nearest, output };
|
|
4629
4446
|
}
|
|
@@ -4790,7 +4607,7 @@ function renderBenchmark(task, tasks) {
|
|
|
4790
4607
|
result.rank === 1 ? c.bold(c.green(" fastest")) : result.rank === benches.length && benches.length > 2 ? c.bold(c.gray(" slowest")) : ""
|
|
4791
4608
|
].join(" ");
|
|
4792
4609
|
}
|
|
4793
|
-
function renderTree(tasks, options, level = 0) {
|
|
4610
|
+
function renderTree(tasks, options, level = 0, shallow = false) {
|
|
4794
4611
|
var _a, _b, _c, _d, _e, _f;
|
|
4795
4612
|
const output = [];
|
|
4796
4613
|
let idx = 0;
|
|
@@ -4829,7 +4646,7 @@ ${padding}`;
|
|
|
4829
4646
|
output.push(` ${c.gray(cliTruncate(out, getCols(-3)))}`);
|
|
4830
4647
|
}
|
|
4831
4648
|
}
|
|
4832
|
-
if (task.type === "suite" && task.tasks.length > 0) {
|
|
4649
|
+
if (!shallow && task.type === "suite" && task.tasks.length > 0) {
|
|
4833
4650
|
if ((_f = task.result) == null ? void 0 : _f.state)
|
|
4834
4651
|
output.push(renderTree(task.tasks, options, level + 1));
|
|
4835
4652
|
}
|
|
@@ -4896,6 +4713,27 @@ class TableReporter extends BaseReporter {
|
|
|
4896
4713
|
this.renderer.update(files);
|
|
4897
4714
|
}
|
|
4898
4715
|
}
|
|
4716
|
+
onTaskUpdate(packs) {
|
|
4717
|
+
var _a, _b;
|
|
4718
|
+
if (this.isTTY)
|
|
4719
|
+
return;
|
|
4720
|
+
for (const pack of packs) {
|
|
4721
|
+
const task = this.ctx.state.idMap.get(pack[0]);
|
|
4722
|
+
if (task && task.type === "suite" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
4723
|
+
const benches = task.tasks.filter((t) => t.meta.benchmark);
|
|
4724
|
+
if (benches.length > 0 && benches.every((t) => {
|
|
4725
|
+
var _a2;
|
|
4726
|
+
return ((_a2 = t.result) == null ? void 0 : _a2.state) !== "run";
|
|
4727
|
+
})) {
|
|
4728
|
+
let title = ` ${getStateSymbol(task)} ${getFullName(task, c.dim(" > "))}`;
|
|
4729
|
+
if (task.result.duration != null && task.result.duration > this.ctx.config.slowTestThreshold)
|
|
4730
|
+
title += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
|
|
4731
|
+
this.ctx.logger.log(title);
|
|
4732
|
+
this.ctx.logger.log(renderTree(benches, this.rendererOptions, 1, true));
|
|
4733
|
+
}
|
|
4734
|
+
}
|
|
4735
|
+
}
|
|
4736
|
+
}
|
|
4899
4737
|
async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
4900
4738
|
await this.stopListRender();
|
|
4901
4739
|
this.ctx.logger.log();
|
|
@@ -4942,4 +4780,4 @@ const ReportersMap = {
|
|
|
4942
4780
|
"github-actions": GithubActionsReporter
|
|
4943
4781
|
};
|
|
4944
4782
|
|
|
4945
|
-
export { BaseSequencer as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter$1 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, generateCodeFrame as h, highlightCode as i,
|
|
4783
|
+
export { BaseSequencer as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter$1 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, generateCodeFrame as h, highlightCode as i, wrapSerializableConfig as w };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
|
|
3
|
+
const __require = createRequire(import.meta.url);
|
|
4
|
+
let inspector;
|
|
5
|
+
let session;
|
|
6
|
+
function setupInspect(ctx) {
|
|
7
|
+
const config = ctx.config;
|
|
8
|
+
const isEnabled = config.inspector.enabled;
|
|
9
|
+
if (isEnabled) {
|
|
10
|
+
inspector = __require("node:inspector");
|
|
11
|
+
const isOpen = inspector.url() !== void 0;
|
|
12
|
+
if (!isOpen) {
|
|
13
|
+
inspector.open(
|
|
14
|
+
config.inspector.port,
|
|
15
|
+
config.inspector.host,
|
|
16
|
+
config.inspector.waitForDebugger
|
|
17
|
+
);
|
|
18
|
+
if (config.inspectBrk) {
|
|
19
|
+
const firstTestFile = ctx.files[0];
|
|
20
|
+
if (firstTestFile) {
|
|
21
|
+
session = new inspector.Session();
|
|
22
|
+
session.connect();
|
|
23
|
+
session.post("Debugger.enable");
|
|
24
|
+
session.post("Debugger.setBreakpointByUrl", {
|
|
25
|
+
lineNumber: 0,
|
|
26
|
+
url: new URL(firstTestFile, import.meta.url).href
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const keepOpen = shouldKeepOpen(config);
|
|
33
|
+
return function cleanup() {
|
|
34
|
+
if (isEnabled && !keepOpen && inspector) {
|
|
35
|
+
inspector.close();
|
|
36
|
+
session == null ? void 0 : session.disconnect();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function closeInspector(config) {
|
|
41
|
+
const keepOpen = shouldKeepOpen(config);
|
|
42
|
+
if (inspector && !keepOpen) {
|
|
43
|
+
inspector.close();
|
|
44
|
+
session == null ? void 0 : session.disconnect();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function shouldKeepOpen(config) {
|
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
49
|
+
const isIsolatedSingleThread = config.pool === "threads" && ((_b = (_a = config.poolOptions) == null ? void 0 : _a.threads) == null ? void 0 : _b.isolate) === false && ((_d = (_c = config.poolOptions) == null ? void 0 : _c.threads) == null ? void 0 : _d.singleThread);
|
|
50
|
+
const isIsolatedSingleFork = config.pool === "forks" && ((_f = (_e = config.poolOptions) == null ? void 0 : _e.forks) == null ? void 0 : _f.isolate) === false && ((_h = (_g = config.poolOptions) == null ? void 0 : _g.forks) == null ? void 0 : _h.singleFork);
|
|
51
|
+
return config.watch && (isIsolatedSingleFork || isIsolatedSingleThread);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { closeInspector as c, setupInspect as s };
|
|
@@ -6,17 +6,27 @@ let globalSetup = false;
|
|
|
6
6
|
async function setupCommonEnv(config) {
|
|
7
7
|
resetRunOnceCounter();
|
|
8
8
|
setupDefines(config.defines);
|
|
9
|
+
setupEnv(config.env);
|
|
9
10
|
if (globalSetup)
|
|
10
11
|
return;
|
|
11
12
|
globalSetup = true;
|
|
12
13
|
setSafeTimers();
|
|
13
14
|
if (config.globals)
|
|
14
|
-
(await import('../chunks/integrations-globals.
|
|
15
|
+
(await import('../chunks/integrations-globals.k0N5-dd1.js')).registerApiGlobally();
|
|
15
16
|
}
|
|
16
17
|
function setupDefines(defines) {
|
|
17
18
|
for (const key in defines)
|
|
18
19
|
globalThis[key] = defines[key];
|
|
19
20
|
}
|
|
21
|
+
function setupEnv(env) {
|
|
22
|
+
if (typeof process === "undefined")
|
|
23
|
+
return;
|
|
24
|
+
const { PROD, DEV, ...restEnvs } = env;
|
|
25
|
+
process.env.PROD = PROD ? "1" : "";
|
|
26
|
+
process.env.DEV = DEV ? "1" : "";
|
|
27
|
+
for (const key in restEnvs)
|
|
28
|
+
process.env[key] = env[key];
|
|
29
|
+
}
|
|
20
30
|
async function loadDiffConfig(config, executor) {
|
|
21
31
|
if (typeof config.diff !== "string")
|
|
22
32
|
return;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { parseRegexp } from '@vitest/utils';
|
|
2
2
|
|
|
3
|
+
var _a, _b;
|
|
3
4
|
const REGEXP_WRAP_PREFIX = "$$vitest:";
|
|
5
|
+
const processSend = (_a = process.send) == null ? void 0 : _a.bind(process);
|
|
6
|
+
const processOn = (_b = process.on) == null ? void 0 : _b.bind(process);
|
|
4
7
|
function createThreadsRpcOptions({ port }) {
|
|
5
8
|
return {
|
|
6
9
|
post: (v) => {
|
|
@@ -16,10 +19,10 @@ function createForksRpcOptions(nodeV8) {
|
|
|
16
19
|
serialize: nodeV8.serialize,
|
|
17
20
|
deserialize: (v) => nodeV8.deserialize(Buffer.from(v)),
|
|
18
21
|
post(v) {
|
|
19
|
-
|
|
22
|
+
processSend(v);
|
|
20
23
|
},
|
|
21
24
|
on(fn) {
|
|
22
|
-
|
|
25
|
+
processOn("message", (message, ...extras) => {
|
|
23
26
|
if (message == null ? void 0 : message.__tinypool_worker_message__)
|
|
24
27
|
return;
|
|
25
28
|
return fn(message, ...extras);
|