vitest 3.2.0-beta.1 → 3.2.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/LICENSE.md +0 -232
- package/dist/browser.d.ts +5 -3
- package/dist/browser.js +3 -4
- package/dist/chunks/{base.SfTiRNZf.js → base.D4119yLM.js} +4 -3
- package/dist/chunks/{benchmark.BoF7jW0Q.js → benchmark.Cf_PACH1.js} +1 -1
- package/dist/chunks/{cac.TfX2-DVH.js → cac.DWaWHIIE.js} +21 -16
- package/dist/chunks/{cli-api.2970Nj9J.js → cli-api.CnmEXkxs.js} +292 -59
- package/dist/chunks/{config.d.UqE-KR0o.d.ts → config.d.D2ROskhv.d.ts} +2 -0
- package/dist/chunks/{console.K1NMVOSc.js → console.Cwr-MFPV.js} +3 -2
- package/dist/chunks/{constants.BZZyIeIE.js → constants.DnKduX2e.js} +1 -0
- package/dist/chunks/{coverage.z0LVMxgb.js → coverage.C73DaDgS.js} +241 -4226
- package/dist/chunks/{creator.CuL7xDWI.js → creator.C8WKy2eW.js} +26 -44
- package/dist/chunks/{date.CDOsz-HY.js → date.ByMsSlOr.js} +25 -0
- package/dist/chunks/{defaults.DSxsTG0h.js → defaults.DpVH7vbg.js} +1 -0
- package/dist/chunks/{environment.d.D8YDy2v5.d.ts → environment.d.cL3nLXbE.d.ts} +1 -0
- package/dist/chunks/{execute.BpmIjFTD.js → execute.B3q-2LPV.js} +28 -5
- package/dist/chunks/{global.d.BCOHQEpR.d.ts → global.d.BNLIi6yo.d.ts} +13 -11
- package/dist/chunks/{globals.Cg4NtV4P.js → globals.CI21aWXF.js} +7 -7
- package/dist/chunks/{index.DFXFpH3w.js → index.2jgTs_Q5.js} +19 -1
- package/dist/chunks/{index.CUacZlWG.js → index.Bter3jj9.js} +954 -954
- package/dist/chunks/{index.DbWBPwtH.js → index.CbT4iuwc.js} +7 -4
- package/dist/chunks/index.D3XRDfWc.js +213 -0
- package/dist/chunks/{index.BPc7M5ni.js → index.DNgLEKsQ.js} +5 -15
- package/dist/chunks/index.JOzufsrU.js +276 -0
- package/dist/chunks/{index.DBIGubLC.js → index.X0nbfr6-.js} +7 -7
- package/dist/chunks/{inspector.DbDkSkFn.js → inspector.BFsh5KO0.js} +3 -0
- package/dist/chunks/{node.3xsWotC9.js → node.Be-ntJnD.js} +1 -1
- package/dist/chunks/{reporters.d.DGm4k1Wx.d.ts → reporters.d.Bt4IGtsa.d.ts} +41 -6
- package/dist/chunks/{rpc.D9_013TY.js → rpc.BKExFSRG.js} +2 -1
- package/dist/chunks/{runBaseTests.CguliJB5.js → runBaseTests.B_M1TTsK.js} +19 -11
- package/dist/chunks/{setup-common.BP6KrF_Z.js → setup-common.CF-O-dZX.js} +2 -3
- package/dist/chunks/typechecker.BgzF-6iO.js +954 -0
- package/dist/chunks/{utils.CgTj3MsC.js → utils.BlI4TC7Y.js} +1 -0
- package/dist/chunks/{utils.BfxieIyZ.js → utils.DPCq3gzW.js} +3 -0
- package/dist/chunks/{vi.BFR5YIgu.js → vi.pkoYCV6A.js} +25 -2
- package/dist/chunks/{vite.d.DjP_ALCZ.d.ts → vite.d.B-Kx3KCF.d.ts} +3 -1
- package/dist/chunks/{vm.CuLHT1BG.js → vm.DPYem2so.js} +72 -4
- package/dist/chunks/{worker.d.CoCI7hzP.d.ts → worker.d.BKbBp2ga.d.ts} +2 -2
- package/dist/chunks/{worker.d.D5Xdi-Zr.d.ts → worker.d.Bl1O4kuf.d.ts} +1 -1
- package/dist/cli.js +21 -2
- package/dist/config.cjs +2 -0
- package/dist/config.d.ts +7 -6
- package/dist/config.js +2 -2
- package/dist/coverage.d.ts +4 -4
- package/dist/coverage.js +7 -10
- package/dist/environments.d.ts +6 -2
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +9 -3
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +25 -35
- package/dist/index.js +5 -6
- package/dist/node.d.ts +18 -10
- package/dist/node.js +22 -22
- package/dist/reporters.d.ts +4 -4
- package/dist/reporters.js +14 -14
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +13 -5
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +9 -5
- package/dist/workers/forks.js +6 -4
- package/dist/workers/runVmTests.js +14 -10
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +6 -6
- package/dist/workers/vmThreads.js +6 -6
- package/dist/workers.d.ts +4 -4
- package/dist/workers.js +10 -10
- package/package.json +22 -26
- package/dist/chunks/index.Bw6JxgX8.js +0 -143
- package/dist/chunks/run-once.Dimr7O9f.js +0 -47
- package/dist/chunks/typechecker.DYQbn8uK.js +0 -956
- package/dist/chunks/utils.8gfOgtry.js +0 -207
- package/dist/utils.d.ts +0 -3
- package/dist/utils.js +0 -2
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { stripVTControlCharacters } from 'node:util';
|
|
2
|
-
import { slash } from '@vitest/utils';
|
|
3
|
-
import { isAbsolute, relative, dirname, basename } from 'pathe';
|
|
4
|
-
import c from 'tinyrainbow';
|
|
5
|
-
|
|
6
|
-
const F_RIGHT = "→";
|
|
7
|
-
const F_DOWN = "↓";
|
|
8
|
-
const F_DOWN_RIGHT = "↳";
|
|
9
|
-
const F_POINTER = "❯";
|
|
10
|
-
const F_DOT = "·";
|
|
11
|
-
const F_CHECK = "✓";
|
|
12
|
-
const F_CROSS = "×";
|
|
13
|
-
const F_LONG_DASH = "⎯";
|
|
14
|
-
const F_TREE_NODE_MIDDLE = "├──";
|
|
15
|
-
const F_TREE_NODE_END = "└──";
|
|
16
|
-
|
|
17
|
-
const pointer = c.yellow(F_POINTER);
|
|
18
|
-
const skipped = c.dim(c.gray(F_DOWN));
|
|
19
|
-
const benchmarkPass = c.green(F_DOT);
|
|
20
|
-
const testPass = c.green(F_CHECK);
|
|
21
|
-
const taskFail = c.red(F_CROSS);
|
|
22
|
-
const suiteFail = c.red(F_POINTER);
|
|
23
|
-
const pending = c.gray("·");
|
|
24
|
-
const labelDefaultColors = [
|
|
25
|
-
c.bgYellow,
|
|
26
|
-
c.bgCyan,
|
|
27
|
-
c.bgGreen,
|
|
28
|
-
c.bgMagenta
|
|
29
|
-
];
|
|
30
|
-
function getCols(delta = 0) {
|
|
31
|
-
let length = process.stdout?.columns;
|
|
32
|
-
if (!length || Number.isNaN(length)) {
|
|
33
|
-
length = 30;
|
|
34
|
-
}
|
|
35
|
-
return Math.max(length + delta, 0);
|
|
36
|
-
}
|
|
37
|
-
function errorBanner(message) {
|
|
38
|
-
return divider(c.bold(c.bgRed(` ${message} `)), null, null, c.red);
|
|
39
|
-
}
|
|
40
|
-
function divider(text, left, right, color) {
|
|
41
|
-
const cols = getCols();
|
|
42
|
-
const c = color || ((text) => text);
|
|
43
|
-
if (text) {
|
|
44
|
-
const textLength = stripVTControlCharacters(text).length;
|
|
45
|
-
if (left == null && right != null) {
|
|
46
|
-
left = cols - textLength - right;
|
|
47
|
-
} else {
|
|
48
|
-
left = left ?? Math.floor((cols - textLength) / 2);
|
|
49
|
-
right = cols - textLength - left;
|
|
50
|
-
}
|
|
51
|
-
left = Math.max(0, left);
|
|
52
|
-
right = Math.max(0, right);
|
|
53
|
-
return `${c(F_LONG_DASH.repeat(left))}${text}${c(F_LONG_DASH.repeat(right))}`;
|
|
54
|
-
}
|
|
55
|
-
return F_LONG_DASH.repeat(cols);
|
|
56
|
-
}
|
|
57
|
-
function formatTestPath(root, path) {
|
|
58
|
-
if (isAbsolute(path)) {
|
|
59
|
-
path = relative(root, path);
|
|
60
|
-
}
|
|
61
|
-
const dir = dirname(path);
|
|
62
|
-
const ext = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)?.[0] || "";
|
|
63
|
-
const base = basename(path, ext);
|
|
64
|
-
return slash(c.dim(`${dir}/`) + c.bold(base)) + c.dim(ext);
|
|
65
|
-
}
|
|
66
|
-
function renderSnapshotSummary(rootDir, snapshots) {
|
|
67
|
-
const summary = [];
|
|
68
|
-
if (snapshots.added) {
|
|
69
|
-
summary.push(c.bold(c.green(`${snapshots.added} written`)));
|
|
70
|
-
}
|
|
71
|
-
if (snapshots.unmatched) {
|
|
72
|
-
summary.push(c.bold(c.red(`${snapshots.unmatched} failed`)));
|
|
73
|
-
}
|
|
74
|
-
if (snapshots.updated) {
|
|
75
|
-
summary.push(c.bold(c.green(`${snapshots.updated} updated `)));
|
|
76
|
-
}
|
|
77
|
-
if (snapshots.filesRemoved) {
|
|
78
|
-
if (snapshots.didUpdate) {
|
|
79
|
-
summary.push(c.bold(c.green(`${snapshots.filesRemoved} files removed `)));
|
|
80
|
-
} else {
|
|
81
|
-
summary.push(c.bold(c.yellow(`${snapshots.filesRemoved} files obsolete `)));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) {
|
|
85
|
-
const [head, ...tail] = snapshots.filesRemovedList;
|
|
86
|
-
summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, head)}`);
|
|
87
|
-
tail.forEach((key) => {
|
|
88
|
-
summary.push(` ${c.gray(F_DOT)} ${formatTestPath(rootDir, key)}`);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
if (snapshots.unchecked) {
|
|
92
|
-
if (snapshots.didUpdate) {
|
|
93
|
-
summary.push(c.bold(c.green(`${snapshots.unchecked} removed`)));
|
|
94
|
-
} else {
|
|
95
|
-
summary.push(c.bold(c.yellow(`${snapshots.unchecked} obsolete`)));
|
|
96
|
-
}
|
|
97
|
-
snapshots.uncheckedKeysByFile.forEach((uncheckedFile) => {
|
|
98
|
-
summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
|
|
99
|
-
uncheckedFile.keys.forEach((key) => summary.push(` ${c.gray(F_DOT)} ${key}`));
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
return summary;
|
|
103
|
-
}
|
|
104
|
-
function countTestErrors(tasks) {
|
|
105
|
-
return tasks.reduce((c, i) => c + (i.result?.errors?.length || 0), 0);
|
|
106
|
-
}
|
|
107
|
-
function getStateString(tasks, name = "tests", showTotal = true) {
|
|
108
|
-
if (tasks.length === 0) {
|
|
109
|
-
return c.dim(`no ${name}`);
|
|
110
|
-
}
|
|
111
|
-
const passed = tasks.filter((i) => i.result?.state === "pass");
|
|
112
|
-
const failed = tasks.filter((i) => i.result?.state === "fail");
|
|
113
|
-
const skipped = tasks.filter((i) => i.mode === "skip");
|
|
114
|
-
const todo = tasks.filter((i) => i.mode === "todo");
|
|
115
|
-
return [
|
|
116
|
-
failed.length ? c.bold(c.red(`${failed.length} failed`)) : null,
|
|
117
|
-
passed.length ? c.bold(c.green(`${passed.length} passed`)) : null,
|
|
118
|
-
skipped.length ? c.yellow(`${skipped.length} skipped`) : null,
|
|
119
|
-
todo.length ? c.gray(`${todo.length} todo`) : null
|
|
120
|
-
].filter(Boolean).join(c.dim(" | ")) + (showTotal ? c.gray(` (${tasks.length})`) : "");
|
|
121
|
-
}
|
|
122
|
-
function getStateSymbol(task) {
|
|
123
|
-
if (task.mode === "skip" || task.mode === "todo") {
|
|
124
|
-
return skipped;
|
|
125
|
-
}
|
|
126
|
-
if (!task.result) {
|
|
127
|
-
return pending;
|
|
128
|
-
}
|
|
129
|
-
if (task.result.state === "run" || task.result.state === "queued") {
|
|
130
|
-
if (task.type === "suite") {
|
|
131
|
-
return pointer;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if (task.result.state === "pass") {
|
|
135
|
-
return task.meta?.benchmark ? benchmarkPass : testPass;
|
|
136
|
-
}
|
|
137
|
-
if (task.result.state === "fail") {
|
|
138
|
-
return task.type === "suite" ? suiteFail : taskFail;
|
|
139
|
-
}
|
|
140
|
-
return " ";
|
|
141
|
-
}
|
|
142
|
-
function formatTimeString(date) {
|
|
143
|
-
return date.toTimeString().split(" ")[0];
|
|
144
|
-
}
|
|
145
|
-
function formatTime(time) {
|
|
146
|
-
if (time > 1e3) {
|
|
147
|
-
return `${(time / 1e3).toFixed(2)}s`;
|
|
148
|
-
}
|
|
149
|
-
return `${Math.round(time)}ms`;
|
|
150
|
-
}
|
|
151
|
-
function formatProjectName(project, suffix = " ") {
|
|
152
|
-
if (!project?.name) {
|
|
153
|
-
return "";
|
|
154
|
-
}
|
|
155
|
-
if (!c.isColorSupported) {
|
|
156
|
-
return `|${project.name}|${suffix}`;
|
|
157
|
-
}
|
|
158
|
-
let background = project.color && c[`bg${capitalize(project.color)}`];
|
|
159
|
-
if (!background) {
|
|
160
|
-
const index = project.name.split("").reduce((acc, v, idx) => acc + v.charCodeAt(0) + idx, 0);
|
|
161
|
-
background = labelDefaultColors[index % labelDefaultColors.length];
|
|
162
|
-
}
|
|
163
|
-
return c.black(background(` ${project.name} `)) + suffix;
|
|
164
|
-
}
|
|
165
|
-
function withLabel(color, label, message) {
|
|
166
|
-
const bgColor = `bg${color.charAt(0).toUpperCase()}${color.slice(1)}`;
|
|
167
|
-
return `${c.bold(c[bgColor](` ${label} `))} ${message ? c[color](message) : ""}`;
|
|
168
|
-
}
|
|
169
|
-
function padSummaryTitle(str) {
|
|
170
|
-
return c.dim(`${str.padStart(11)} `);
|
|
171
|
-
}
|
|
172
|
-
function truncateString(text, maxLength) {
|
|
173
|
-
const plainText = stripVTControlCharacters(text);
|
|
174
|
-
if (plainText.length <= maxLength) {
|
|
175
|
-
return text;
|
|
176
|
-
}
|
|
177
|
-
return `${plainText.slice(0, maxLength - 1)}…`;
|
|
178
|
-
}
|
|
179
|
-
function capitalize(text) {
|
|
180
|
-
return `${text[0].toUpperCase()}${text.slice(1)}`;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
var utils = /*#__PURE__*/Object.freeze({
|
|
184
|
-
__proto__: null,
|
|
185
|
-
benchmarkPass: benchmarkPass,
|
|
186
|
-
countTestErrors: countTestErrors,
|
|
187
|
-
divider: divider,
|
|
188
|
-
errorBanner: errorBanner,
|
|
189
|
-
formatProjectName: formatProjectName,
|
|
190
|
-
formatTestPath: formatTestPath,
|
|
191
|
-
formatTime: formatTime,
|
|
192
|
-
formatTimeString: formatTimeString,
|
|
193
|
-
getStateString: getStateString,
|
|
194
|
-
getStateSymbol: getStateSymbol,
|
|
195
|
-
padSummaryTitle: padSummaryTitle,
|
|
196
|
-
pending: pending,
|
|
197
|
-
pointer: pointer,
|
|
198
|
-
renderSnapshotSummary: renderSnapshotSummary,
|
|
199
|
-
skipped: skipped,
|
|
200
|
-
suiteFail: suiteFail,
|
|
201
|
-
taskFail: taskFail,
|
|
202
|
-
testPass: testPass,
|
|
203
|
-
truncateString: truncateString,
|
|
204
|
-
withLabel: withLabel
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
export { F_POINTER as F, taskFail as a, F_CHECK as b, formatProjectName as c, divider as d, errorBanner as e, formatTimeString as f, getStateSymbol as g, F_RIGHT as h, getStateString as i, formatTime as j, countTestErrors as k, F_TREE_NODE_END as l, F_TREE_NODE_MIDDLE as m, padSummaryTitle as p, renderSnapshotSummary as r, truncateString as t, utils as u, withLabel as w };
|
package/dist/utils.d.ts
DELETED
package/dist/utils.js
DELETED