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
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { isAbsolute, relative, dirname, basename } from 'pathe';
|
|
2
|
+
import c from 'picocolors';
|
|
3
|
+
import { a as slash } from './base.Xt0Omgh7.js';
|
|
4
|
+
|
|
5
|
+
const F_RIGHT = "\u2192";
|
|
6
|
+
const F_DOWN = "\u2193";
|
|
7
|
+
const F_DOWN_RIGHT = "\u21B3";
|
|
8
|
+
const F_POINTER = "\u276F";
|
|
9
|
+
const F_DOT = "\xB7";
|
|
10
|
+
const F_CHECK = "\u2713";
|
|
11
|
+
const F_CROSS = "\xD7";
|
|
12
|
+
const F_LONG_DASH = "\u23AF";
|
|
13
|
+
|
|
14
|
+
function ansiRegex({onlyFirst = false} = {}) {
|
|
15
|
+
const pattern = [
|
|
16
|
+
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
|
17
|
+
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
|
|
18
|
+
].join('|');
|
|
19
|
+
|
|
20
|
+
return new RegExp(pattern, onlyFirst ? undefined : 'g');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const regex = ansiRegex();
|
|
24
|
+
|
|
25
|
+
function stripAnsi(string) {
|
|
26
|
+
if (typeof string !== 'string') {
|
|
27
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Even though the regex is global, we don't need to reset the `.lastIndex`
|
|
31
|
+
// because unlike `.exec()` and `.test()`, `.replace()` does it automatically
|
|
32
|
+
// and doing it manually has a performance penalty.
|
|
33
|
+
return string.replace(regex, '');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const spinnerMap = /* @__PURE__ */ new WeakMap();
|
|
37
|
+
const hookSpinnerMap = /* @__PURE__ */ new WeakMap();
|
|
38
|
+
const pointer = c.yellow(F_POINTER);
|
|
39
|
+
const skipped = c.dim(c.gray(F_DOWN));
|
|
40
|
+
function getCols(delta = 0) {
|
|
41
|
+
var _a;
|
|
42
|
+
let length = (_a = process.stdout) == null ? void 0 : _a.columns;
|
|
43
|
+
if (!length || Number.isNaN(length))
|
|
44
|
+
length = 30;
|
|
45
|
+
return Math.max(length + delta, 0);
|
|
46
|
+
}
|
|
47
|
+
function divider(text, left, right) {
|
|
48
|
+
const cols = getCols();
|
|
49
|
+
if (text) {
|
|
50
|
+
const textLength = stripAnsi(text).length;
|
|
51
|
+
if (left == null && right != null) {
|
|
52
|
+
left = cols - textLength - right;
|
|
53
|
+
} else {
|
|
54
|
+
left = left ?? Math.floor((cols - textLength) / 2);
|
|
55
|
+
right = cols - textLength - left;
|
|
56
|
+
}
|
|
57
|
+
left = Math.max(0, left);
|
|
58
|
+
right = Math.max(0, right);
|
|
59
|
+
return `${F_LONG_DASH.repeat(left)}${text}${F_LONG_DASH.repeat(right)}`;
|
|
60
|
+
}
|
|
61
|
+
return F_LONG_DASH.repeat(cols);
|
|
62
|
+
}
|
|
63
|
+
function formatTestPath(root, path) {
|
|
64
|
+
var _a;
|
|
65
|
+
if (isAbsolute(path))
|
|
66
|
+
path = relative(root, path);
|
|
67
|
+
const dir = dirname(path);
|
|
68
|
+
const ext = ((_a = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)) == null ? void 0 : _a[0]) || "";
|
|
69
|
+
const base = basename(path, ext);
|
|
70
|
+
return slash(c.dim(`${dir}/`) + c.bold(base)) + c.dim(ext);
|
|
71
|
+
}
|
|
72
|
+
function renderSnapshotSummary(rootDir, snapshots) {
|
|
73
|
+
const summary = [];
|
|
74
|
+
if (snapshots.added)
|
|
75
|
+
summary.push(c.bold(c.green(`${snapshots.added} written`)));
|
|
76
|
+
if (snapshots.unmatched)
|
|
77
|
+
summary.push(c.bold(c.red(`${snapshots.unmatched} failed`)));
|
|
78
|
+
if (snapshots.updated)
|
|
79
|
+
summary.push(c.bold(c.green(`${snapshots.updated} updated `)));
|
|
80
|
+
if (snapshots.filesRemoved) {
|
|
81
|
+
if (snapshots.didUpdate)
|
|
82
|
+
summary.push(c.bold(c.green(`${snapshots.filesRemoved} files removed `)));
|
|
83
|
+
else
|
|
84
|
+
summary.push(c.bold(c.yellow(`${snapshots.filesRemoved} files obsolete `)));
|
|
85
|
+
}
|
|
86
|
+
if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) {
|
|
87
|
+
const [head, ...tail] = snapshots.filesRemovedList;
|
|
88
|
+
summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, head)}`);
|
|
89
|
+
tail.forEach((key) => {
|
|
90
|
+
summary.push(` ${c.gray(F_DOT)} ${formatTestPath(rootDir, key)}`);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (snapshots.unchecked) {
|
|
94
|
+
if (snapshots.didUpdate)
|
|
95
|
+
summary.push(c.bold(c.green(`${snapshots.unchecked} removed`)));
|
|
96
|
+
else
|
|
97
|
+
summary.push(c.bold(c.yellow(`${snapshots.unchecked} obsolete`)));
|
|
98
|
+
snapshots.uncheckedKeysByFile.forEach((uncheckedFile) => {
|
|
99
|
+
summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
|
|
100
|
+
uncheckedFile.keys.forEach((key) => summary.push(` ${c.gray(F_DOT)} ${key}`));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return summary;
|
|
104
|
+
}
|
|
105
|
+
function countTestErrors(tasks) {
|
|
106
|
+
return tasks.reduce((c2, i) => {
|
|
107
|
+
var _a, _b;
|
|
108
|
+
return c2 + (((_b = (_a = i.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.length) || 0);
|
|
109
|
+
}, 0);
|
|
110
|
+
}
|
|
111
|
+
function getStateString(tasks, name = "tests", showTotal = true) {
|
|
112
|
+
if (tasks.length === 0)
|
|
113
|
+
return c.dim(`no ${name}`);
|
|
114
|
+
const passed = tasks.filter((i) => {
|
|
115
|
+
var _a;
|
|
116
|
+
return ((_a = i.result) == null ? void 0 : _a.state) === "pass";
|
|
117
|
+
});
|
|
118
|
+
const failed = tasks.filter((i) => {
|
|
119
|
+
var _a;
|
|
120
|
+
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
121
|
+
});
|
|
122
|
+
const skipped2 = tasks.filter((i) => i.mode === "skip");
|
|
123
|
+
const todo = tasks.filter((i) => i.mode === "todo");
|
|
124
|
+
return [
|
|
125
|
+
failed.length ? c.bold(c.red(`${failed.length} failed`)) : null,
|
|
126
|
+
passed.length ? c.bold(c.green(`${passed.length} passed`)) : null,
|
|
127
|
+
skipped2.length ? c.yellow(`${skipped2.length} skipped`) : null,
|
|
128
|
+
todo.length ? c.gray(`${todo.length} todo`) : null
|
|
129
|
+
].filter(Boolean).join(c.dim(" | ")) + (showTotal ? c.gray(` (${tasks.length})`) : "");
|
|
130
|
+
}
|
|
131
|
+
function getStateSymbol(task) {
|
|
132
|
+
var _a;
|
|
133
|
+
if (task.mode === "skip" || task.mode === "todo")
|
|
134
|
+
return skipped;
|
|
135
|
+
if (!task.result)
|
|
136
|
+
return c.gray("\xB7");
|
|
137
|
+
if (task.result.state === "run") {
|
|
138
|
+
if (task.type === "suite")
|
|
139
|
+
return pointer;
|
|
140
|
+
let spinner = spinnerMap.get(task);
|
|
141
|
+
if (!spinner) {
|
|
142
|
+
spinner = elegantSpinner();
|
|
143
|
+
spinnerMap.set(task, spinner);
|
|
144
|
+
}
|
|
145
|
+
return c.yellow(spinner());
|
|
146
|
+
}
|
|
147
|
+
if (task.result.state === "pass") {
|
|
148
|
+
return ((_a = task.meta) == null ? void 0 : _a.benchmark) ? c.green(F_DOT) : c.green(F_CHECK);
|
|
149
|
+
}
|
|
150
|
+
if (task.result.state === "fail") {
|
|
151
|
+
return task.type === "suite" ? pointer : c.red(F_CROSS);
|
|
152
|
+
}
|
|
153
|
+
return " ";
|
|
154
|
+
}
|
|
155
|
+
function getHookStateSymbol(task, hookName) {
|
|
156
|
+
var _a, _b;
|
|
157
|
+
const state = (_b = (_a = task.result) == null ? void 0 : _a.hooks) == null ? void 0 : _b[hookName];
|
|
158
|
+
if (state && state === "run") {
|
|
159
|
+
let spinnerMap2 = hookSpinnerMap.get(task);
|
|
160
|
+
if (!spinnerMap2) {
|
|
161
|
+
spinnerMap2 = /* @__PURE__ */ new Map();
|
|
162
|
+
hookSpinnerMap.set(task, spinnerMap2);
|
|
163
|
+
}
|
|
164
|
+
let spinner = spinnerMap2.get(hookName);
|
|
165
|
+
if (!spinner) {
|
|
166
|
+
spinner = elegantSpinner();
|
|
167
|
+
spinnerMap2.set(hookName, spinner);
|
|
168
|
+
}
|
|
169
|
+
return c.yellow(spinner());
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const spinnerFrames = process.platform === "win32" ? ["-", "\\", "|", "/"] : ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
173
|
+
function elegantSpinner() {
|
|
174
|
+
let index = 0;
|
|
175
|
+
return () => {
|
|
176
|
+
index = ++index % spinnerFrames.length;
|
|
177
|
+
return spinnerFrames[index];
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function formatTimeString(date) {
|
|
181
|
+
return date.toTimeString().split(" ")[0];
|
|
182
|
+
}
|
|
183
|
+
function formatProjectName(name, suffix = " ") {
|
|
184
|
+
if (!name)
|
|
185
|
+
return "";
|
|
186
|
+
const index = name.split("").reduce((acc, v, idx) => acc + v.charCodeAt(0) + idx, 0);
|
|
187
|
+
const colors = [
|
|
188
|
+
c.blue,
|
|
189
|
+
c.yellow,
|
|
190
|
+
c.cyan,
|
|
191
|
+
c.green,
|
|
192
|
+
c.magenta
|
|
193
|
+
];
|
|
194
|
+
return colors[index % colors.length](`|${name}|`) + suffix;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
var utils = /*#__PURE__*/Object.freeze({
|
|
198
|
+
__proto__: null,
|
|
199
|
+
countTestErrors: countTestErrors,
|
|
200
|
+
divider: divider,
|
|
201
|
+
elegantSpinner: elegantSpinner,
|
|
202
|
+
formatProjectName: formatProjectName,
|
|
203
|
+
formatTestPath: formatTestPath,
|
|
204
|
+
formatTimeString: formatTimeString,
|
|
205
|
+
getCols: getCols,
|
|
206
|
+
getHookStateSymbol: getHookStateSymbol,
|
|
207
|
+
getStateString: getStateString,
|
|
208
|
+
getStateSymbol: getStateSymbol,
|
|
209
|
+
hookSpinnerMap: hookSpinnerMap,
|
|
210
|
+
pointer: pointer,
|
|
211
|
+
renderSnapshotSummary: renderSnapshotSummary,
|
|
212
|
+
skipped: skipped,
|
|
213
|
+
spinnerFrames: spinnerFrames,
|
|
214
|
+
spinnerMap: spinnerMap
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
export { F_RIGHT as F, getStateString as a, formatTimeString as b, countTestErrors as c, divider as d, getCols as e, formatProjectName as f, getStateSymbol as g, getHookStateSymbol as h, F_POINTER as i, pointer as p, renderSnapshotSummary as r, stripAnsi as s, utils as u };
|
|
@@ -3330,12 +3330,14 @@ function createVitest() {
|
|
|
3330
3330
|
let _mockedDate = null;
|
|
3331
3331
|
let _config = null;
|
|
3332
3332
|
const workerState = getWorkerState();
|
|
3333
|
-
|
|
3333
|
+
let _timers;
|
|
3334
|
+
const timers = () => _timers || (_timers = new FakeTimers({
|
|
3334
3335
|
global: globalThis,
|
|
3335
3336
|
config: workerState.config.fakeTimers
|
|
3336
|
-
});
|
|
3337
|
+
}));
|
|
3337
3338
|
const _stubsGlobal = /* @__PURE__ */ new Map();
|
|
3338
3339
|
const _stubsEnv = /* @__PURE__ */ new Map();
|
|
3340
|
+
const _envBooleans = ["PROD", "DEV", "SSR"];
|
|
3339
3341
|
const getImporter = () => {
|
|
3340
3342
|
const stackTrace = createSimpleStackTrace({ stackTraceLimit: 4 });
|
|
3341
3343
|
const importerStack = stackTrace.split("\n")[4];
|
|
@@ -3353,73 +3355,73 @@ function createVitest() {
|
|
|
3353
3355
|
}
|
|
3354
3356
|
}
|
|
3355
3357
|
if (config)
|
|
3356
|
-
|
|
3358
|
+
timers().configure({ ...workerState.config.fakeTimers, ...config });
|
|
3357
3359
|
else
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
+
timers().configure(workerState.config.fakeTimers);
|
|
3361
|
+
timers().useFakeTimers();
|
|
3360
3362
|
return utils;
|
|
3361
3363
|
},
|
|
3362
3364
|
isFakeTimers() {
|
|
3363
|
-
return
|
|
3365
|
+
return timers().isFakeTimers();
|
|
3364
3366
|
},
|
|
3365
3367
|
useRealTimers() {
|
|
3366
|
-
|
|
3368
|
+
timers().useRealTimers();
|
|
3367
3369
|
_mockedDate = null;
|
|
3368
3370
|
return utils;
|
|
3369
3371
|
},
|
|
3370
3372
|
runOnlyPendingTimers() {
|
|
3371
|
-
|
|
3373
|
+
timers().runOnlyPendingTimers();
|
|
3372
3374
|
return utils;
|
|
3373
3375
|
},
|
|
3374
3376
|
async runOnlyPendingTimersAsync() {
|
|
3375
|
-
await
|
|
3377
|
+
await timers().runOnlyPendingTimersAsync();
|
|
3376
3378
|
return utils;
|
|
3377
3379
|
},
|
|
3378
3380
|
runAllTimers() {
|
|
3379
|
-
|
|
3381
|
+
timers().runAllTimers();
|
|
3380
3382
|
return utils;
|
|
3381
3383
|
},
|
|
3382
3384
|
async runAllTimersAsync() {
|
|
3383
|
-
await
|
|
3385
|
+
await timers().runAllTimersAsync();
|
|
3384
3386
|
return utils;
|
|
3385
3387
|
},
|
|
3386
3388
|
runAllTicks() {
|
|
3387
|
-
|
|
3389
|
+
timers().runAllTicks();
|
|
3388
3390
|
return utils;
|
|
3389
3391
|
},
|
|
3390
3392
|
advanceTimersByTime(ms) {
|
|
3391
|
-
|
|
3393
|
+
timers().advanceTimersByTime(ms);
|
|
3392
3394
|
return utils;
|
|
3393
3395
|
},
|
|
3394
3396
|
async advanceTimersByTimeAsync(ms) {
|
|
3395
|
-
await
|
|
3397
|
+
await timers().advanceTimersByTimeAsync(ms);
|
|
3396
3398
|
return utils;
|
|
3397
3399
|
},
|
|
3398
3400
|
advanceTimersToNextTimer() {
|
|
3399
|
-
|
|
3401
|
+
timers().advanceTimersToNextTimer();
|
|
3400
3402
|
return utils;
|
|
3401
3403
|
},
|
|
3402
3404
|
async advanceTimersToNextTimerAsync() {
|
|
3403
|
-
await
|
|
3405
|
+
await timers().advanceTimersToNextTimerAsync();
|
|
3404
3406
|
return utils;
|
|
3405
3407
|
},
|
|
3406
3408
|
getTimerCount() {
|
|
3407
|
-
return
|
|
3409
|
+
return timers().getTimerCount();
|
|
3408
3410
|
},
|
|
3409
3411
|
setSystemTime(time) {
|
|
3410
3412
|
const date = time instanceof Date ? time : new Date(time);
|
|
3411
3413
|
_mockedDate = date;
|
|
3412
|
-
|
|
3414
|
+
timers().setSystemTime(date);
|
|
3413
3415
|
return utils;
|
|
3414
3416
|
},
|
|
3415
3417
|
getMockedSystemTime() {
|
|
3416
3418
|
return _mockedDate;
|
|
3417
3419
|
},
|
|
3418
3420
|
getRealSystemTime() {
|
|
3419
|
-
return
|
|
3421
|
+
return timers().getRealSystemTime();
|
|
3420
3422
|
},
|
|
3421
3423
|
clearAllTimers() {
|
|
3422
|
-
|
|
3424
|
+
timers().clearAllTimers();
|
|
3423
3425
|
return utils;
|
|
3424
3426
|
},
|
|
3425
3427
|
// mocks
|
|
@@ -3498,7 +3500,10 @@ function createVitest() {
|
|
|
3498
3500
|
stubEnv(name, value) {
|
|
3499
3501
|
if (!_stubsEnv.has(name))
|
|
3500
3502
|
_stubsEnv.set(name, process.env[name]);
|
|
3501
|
-
|
|
3503
|
+
if (_envBooleans.includes(name))
|
|
3504
|
+
process.env[name] = value ? "1" : "";
|
|
3505
|
+
else
|
|
3506
|
+
process.env[name] = String(value);
|
|
3502
3507
|
return utils;
|
|
3503
3508
|
},
|
|
3504
3509
|
unstubAllGlobals() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
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
|
-
import { createCustomConsole } from '../chunks/runtime-console.
|
|
4
|
+
import { createCustomConsole } from '../chunks/runtime-console.kbFEN7E-.js';
|
|
5
5
|
import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.2_yoIC01.js';
|
|
6
6
|
import { distDir } from '../path.js';
|
|
7
7
|
import { dirname as dirname$1 } from 'node:path';
|
|
@@ -691,7 +691,7 @@ async function runVmTests(state) {
|
|
|
691
691
|
provideWorkerState(context, state);
|
|
692
692
|
context.process = process;
|
|
693
693
|
context.global = context;
|
|
694
|
-
context.console = state.config.disableConsoleIntercept ? console : createCustomConsole(
|
|
694
|
+
context.console = state.config.disableConsoleIntercept ? console : createCustomConsole();
|
|
695
695
|
context.setImmediate = setImmediate;
|
|
696
696
|
context.clearImmediate = clearImmediate;
|
|
697
697
|
const stubs = getDefaultRequestStubs(context);
|
package/dist/worker.js
CHANGED
|
@@ -4,10 +4,11 @@ import { ViteNodeRunner, ModuleCacheMap } from 'vite-node/client';
|
|
|
4
4
|
import { resolve, normalize } from 'pathe';
|
|
5
5
|
import { e as environments } from './vendor/index.GVFv9dZ0.js';
|
|
6
6
|
import { i as isChildProcess, s as setProcessTitle } from './vendor/base.Xt0Omgh7.js';
|
|
7
|
-
import {
|
|
7
|
+
import { s as setupInspect } from './vendor/inspector.IgLX3ur5.js';
|
|
8
8
|
import { c as createRuntimeRpc, a as rpcDone } from './vendor/rpc.joBhAkyK.js';
|
|
9
9
|
import 'node:console';
|
|
10
10
|
import '@vitest/utils';
|
|
11
|
+
import 'node:module';
|
|
11
12
|
import './vendor/index.8bPxjt7g.js';
|
|
12
13
|
import './vendor/global.CkGT_TMy.js';
|
|
13
14
|
|
|
@@ -50,44 +51,6 @@ async function loadEnvironment(ctx, rpc) {
|
|
|
50
51
|
return environment;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
const __require = createRequire(import.meta.url);
|
|
54
|
-
let inspector;
|
|
55
|
-
let session;
|
|
56
|
-
function setupInspect(ctx) {
|
|
57
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
58
|
-
const config = ctx.config;
|
|
59
|
-
const isEnabled = config.inspect || config.inspectBrk;
|
|
60
|
-
if (isEnabled) {
|
|
61
|
-
inspector = __require("node:inspector");
|
|
62
|
-
const isOpen = inspector.url() !== void 0;
|
|
63
|
-
if (!isOpen) {
|
|
64
|
-
inspector.open();
|
|
65
|
-
if (config.inspectBrk) {
|
|
66
|
-
inspector.waitForDebugger();
|
|
67
|
-
const firstTestFile = ctx.files[0];
|
|
68
|
-
if (firstTestFile) {
|
|
69
|
-
session = new inspector.Session();
|
|
70
|
-
session.connect();
|
|
71
|
-
session.post("Debugger.enable");
|
|
72
|
-
session.post("Debugger.setBreakpointByUrl", {
|
|
73
|
-
lineNumber: 0,
|
|
74
|
-
url: new URL(firstTestFile, import.meta.url).href
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
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);
|
|
81
|
-
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);
|
|
82
|
-
const keepOpen = config.watch && (isIsolatedSingleFork || isIsolatedSingleThread);
|
|
83
|
-
return function cleanup() {
|
|
84
|
-
if (isEnabled && !keepOpen && inspector) {
|
|
85
|
-
inspector.close();
|
|
86
|
-
session == null ? void 0 : session.disconnect();
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
54
|
if (isChildProcess())
|
|
92
55
|
setProcessTitle(`vitest ${workerId}`);
|
|
93
56
|
async function run(ctx) {
|
package/dist/workers/forks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import v8 from 'node:v8';
|
|
2
|
-
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../vendor/utils.
|
|
3
|
-
import { r as runBaseTests } from '../vendor/base.
|
|
2
|
+
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../vendor/utils.0uYuCbzo.js';
|
|
3
|
+
import { r as runBaseTests } from '../vendor/base.gAwDs8Jc.js';
|
|
4
4
|
import '@vitest/utils';
|
|
5
5
|
import 'vite-node/client';
|
|
6
6
|
import '../vendor/global.CkGT_TMy.js';
|
|
@@ -6,11 +6,12 @@ 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 { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '../vendor/index.
|
|
9
|
+
import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '../vendor/index.gHZzsRJQ.js';
|
|
10
10
|
import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from '../vendor/coverage.E7sG1b3r.js';
|
|
11
11
|
import { g as getWorkerState } from '../vendor/global.CkGT_TMy.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.0RrMQKD8.js';
|
|
13
|
+
import { s as setupCommonEnv } from '../vendor/setup-common.7SXMSI--.js';
|
|
14
|
+
import { c as closeInspector } from '../vendor/inspector.IgLX3ur5.js';
|
|
14
15
|
import 'chai';
|
|
15
16
|
import '@vitest/snapshot/environment';
|
|
16
17
|
import 'pathe';
|
|
@@ -23,7 +24,7 @@ import '@vitest/runner/utils';
|
|
|
23
24
|
import '../vendor/index.ir9i0ywP.js';
|
|
24
25
|
import 'std-env';
|
|
25
26
|
import '../vendor/run-once.Olz_Zkd8.js';
|
|
26
|
-
import '../vendor/vi.
|
|
27
|
+
import '../vendor/vi.Y_w82WR8.js';
|
|
27
28
|
import '../vendor/_commonjsHelpers.jjO7Zipk.js';
|
|
28
29
|
import '@vitest/expect';
|
|
29
30
|
import '@vitest/snapshot';
|
|
@@ -61,6 +62,11 @@ async function run(files, config, executor) {
|
|
|
61
62
|
if (config.chaiConfig)
|
|
62
63
|
setupChaiConfig(config.chaiConfig);
|
|
63
64
|
const runner = await resolveTestRunner(config, executor);
|
|
65
|
+
workerState.onCancel.then((reason) => {
|
|
66
|
+
var _a;
|
|
67
|
+
closeInspector(config);
|
|
68
|
+
(_a = runner.onCancel) == null ? void 0 : _a.call(runner, reason);
|
|
69
|
+
});
|
|
64
70
|
workerState.durations.prepare = performance.now() - workerState.durations.prepare;
|
|
65
71
|
const { vi } = VitestIndex;
|
|
66
72
|
for (const file of files) {
|
package/dist/workers/threads.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as runBaseTests } from '../vendor/base.
|
|
2
|
-
import { a as createThreadsRpcOptions } from '../vendor/utils.
|
|
1
|
+
import { r as runBaseTests } from '../vendor/base.gAwDs8Jc.js';
|
|
2
|
+
import { a as createThreadsRpcOptions } from '../vendor/utils.0uYuCbzo.js';
|
|
3
3
|
import 'vite-node/client';
|
|
4
4
|
import '../vendor/global.CkGT_TMy.js';
|
|
5
5
|
import '../vendor/execute.2_yoIC01.js';
|
package/dist/workers/vmForks.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import v8 from 'node:v8';
|
|
2
|
-
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../vendor/utils.
|
|
3
|
-
import { r as runVmTests } from '../vendor/vm.
|
|
2
|
+
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../vendor/utils.0uYuCbzo.js';
|
|
3
|
+
import { r as runVmTests } from '../vendor/vm.I_IsyNig.js';
|
|
4
4
|
import '@vitest/utils';
|
|
5
5
|
import 'node:vm';
|
|
6
6
|
import 'node:url';
|
|
7
7
|
import 'pathe';
|
|
8
|
-
import '../chunks/runtime-console.
|
|
8
|
+
import '../chunks/runtime-console.kbFEN7E-.js';
|
|
9
9
|
import 'node:stream';
|
|
10
10
|
import 'node:console';
|
|
11
11
|
import 'node:path';
|
|
12
12
|
import '../vendor/date.Ns1pGd_X.js';
|
|
13
|
+
import '../vendor/index.ir9i0ywP.js';
|
|
14
|
+
import 'std-env';
|
|
15
|
+
import '@vitest/runner/utils';
|
|
16
|
+
import '../vendor/global.CkGT_TMy.js';
|
|
13
17
|
import '../vendor/execute.2_yoIC01.js';
|
|
14
18
|
import 'vite-node/client';
|
|
15
19
|
import 'vite-node/utils';
|
|
@@ -19,10 +23,6 @@ import 'node:fs';
|
|
|
19
23
|
import '../vendor/base.Xt0Omgh7.js';
|
|
20
24
|
import 'node:module';
|
|
21
25
|
import 'vite-node/constants';
|
|
22
|
-
import '../vendor/index.ir9i0ywP.js';
|
|
23
|
-
import 'std-env';
|
|
24
|
-
import '@vitest/runner/utils';
|
|
25
|
-
import '../vendor/global.CkGT_TMy.js';
|
|
26
26
|
|
|
27
27
|
class ForksVmWorker {
|
|
28
28
|
getRpcOptions() {
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { a as createThreadsRpcOptions } from '../vendor/utils.
|
|
2
|
-
import { r as runVmTests } from '../vendor/vm.
|
|
1
|
+
import { a as createThreadsRpcOptions } from '../vendor/utils.0uYuCbzo.js';
|
|
2
|
+
import { r as runVmTests } from '../vendor/vm.I_IsyNig.js';
|
|
3
3
|
import '@vitest/utils';
|
|
4
4
|
import 'node:vm';
|
|
5
5
|
import 'node:url';
|
|
6
6
|
import 'pathe';
|
|
7
|
-
import '../chunks/runtime-console.
|
|
7
|
+
import '../chunks/runtime-console.kbFEN7E-.js';
|
|
8
8
|
import 'node:stream';
|
|
9
9
|
import 'node:console';
|
|
10
10
|
import 'node:path';
|
|
11
11
|
import '../vendor/date.Ns1pGd_X.js';
|
|
12
|
+
import '../vendor/index.ir9i0ywP.js';
|
|
13
|
+
import 'std-env';
|
|
14
|
+
import '@vitest/runner/utils';
|
|
15
|
+
import '../vendor/global.CkGT_TMy.js';
|
|
12
16
|
import '../vendor/execute.2_yoIC01.js';
|
|
13
17
|
import 'vite-node/client';
|
|
14
18
|
import 'vite-node/utils';
|
|
@@ -18,10 +22,6 @@ import 'node:fs';
|
|
|
18
22
|
import '../vendor/base.Xt0Omgh7.js';
|
|
19
23
|
import 'node:module';
|
|
20
24
|
import 'vite-node/constants';
|
|
21
|
-
import '../vendor/index.ir9i0ywP.js';
|
|
22
|
-
import 'std-env';
|
|
23
|
-
import '@vitest/runner/utils';
|
|
24
|
-
import '../vendor/global.CkGT_TMy.js';
|
|
25
25
|
|
|
26
26
|
class ThreadsVmWorker {
|
|
27
27
|
getRpcOptions(ctx) {
|
package/dist/workers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as v8 from 'v8';
|
|
2
|
-
import { d as BirpcOptions, e as RuntimeRPC, f as ContextRPC, W as WorkerGlobalState, g as WorkerContext, R as ResolvedConfig } from './reporters-
|
|
2
|
+
import { d as BirpcOptions, e as RuntimeRPC, f as ContextRPC, W as WorkerGlobalState, g as WorkerContext, R as ResolvedConfig } from './reporters-xEmem8D4.js';
|
|
3
3
|
import { Awaitable } from '@vitest/utils';
|
|
4
4
|
import 'vite';
|
|
5
5
|
import '@vitest/runner';
|
|
@@ -8,6 +8,7 @@ import '@vitest/snapshot';
|
|
|
8
8
|
import '@vitest/expect';
|
|
9
9
|
import '@vitest/runner/utils';
|
|
10
10
|
import 'tinybench';
|
|
11
|
+
import 'node:stream';
|
|
11
12
|
import 'vite-node/client';
|
|
12
13
|
import '@vitest/snapshot/manager';
|
|
13
14
|
import 'vite-node/server';
|
package/dist/workers.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './vendor/utils.
|
|
1
|
+
export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './vendor/utils.0uYuCbzo.js';
|
|
2
2
|
export { p as provideWorkerState } from './vendor/global.CkGT_TMy.js';
|
|
3
3
|
export { run as runVitestWorker } from './worker.js';
|
|
4
|
-
export { r as runVmTests } from './vendor/vm.
|
|
5
|
-
export { r as runBaseTests } from './vendor/base.
|
|
4
|
+
export { r as runVmTests } from './vendor/vm.I_IsyNig.js';
|
|
5
|
+
export { r as runBaseTests } from './vendor/base.gAwDs8Jc.js';
|
|
6
6
|
import '@vitest/utils';
|
|
7
7
|
import 'node:url';
|
|
8
8
|
import 'tinypool';
|
|
@@ -11,20 +11,21 @@ import 'pathe';
|
|
|
11
11
|
import './vendor/index.GVFv9dZ0.js';
|
|
12
12
|
import 'node:console';
|
|
13
13
|
import './vendor/base.Xt0Omgh7.js';
|
|
14
|
+
import './vendor/inspector.IgLX3ur5.js';
|
|
14
15
|
import 'node:module';
|
|
15
16
|
import './vendor/rpc.joBhAkyK.js';
|
|
16
17
|
import './vendor/index.8bPxjt7g.js';
|
|
17
18
|
import 'node:vm';
|
|
18
|
-
import './chunks/runtime-console.
|
|
19
|
+
import './chunks/runtime-console.kbFEN7E-.js';
|
|
19
20
|
import 'node:stream';
|
|
20
21
|
import 'node:path';
|
|
21
22
|
import './vendor/date.Ns1pGd_X.js';
|
|
23
|
+
import './vendor/index.ir9i0ywP.js';
|
|
24
|
+
import 'std-env';
|
|
25
|
+
import '@vitest/runner/utils';
|
|
22
26
|
import './vendor/execute.2_yoIC01.js';
|
|
23
27
|
import 'vite-node/utils';
|
|
24
28
|
import '@vitest/utils/error';
|
|
25
29
|
import './path.js';
|
|
26
30
|
import 'node:fs';
|
|
27
31
|
import 'vite-node/constants';
|
|
28
|
-
import './vendor/index.ir9i0ywP.js';
|
|
29
|
-
import 'std-env';
|
|
30
|
-
import '@vitest/runner/utils';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.1",
|
|
5
5
|
"description": "Next generation testing framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -115,8 +115,8 @@
|
|
|
115
115
|
"@types/node": "^18.0.0 || >=20.0.0",
|
|
116
116
|
"happy-dom": "*",
|
|
117
117
|
"jsdom": "*",
|
|
118
|
-
"@vitest/browser": "1.
|
|
119
|
-
"@vitest/ui": "1.
|
|
118
|
+
"@vitest/browser": "1.5.1",
|
|
119
|
+
"@vitest/ui": "1.5.1"
|
|
120
120
|
},
|
|
121
121
|
"peerDependenciesMeta": {
|
|
122
122
|
"@edge-runtime/vm": {
|
|
@@ -150,15 +150,15 @@
|
|
|
150
150
|
"std-env": "^3.5.0",
|
|
151
151
|
"strip-literal": "^2.0.0",
|
|
152
152
|
"tinybench": "^2.5.1",
|
|
153
|
-
"tinypool": "^0.8.
|
|
153
|
+
"tinypool": "^0.8.3",
|
|
154
154
|
"vite": "^5.0.0",
|
|
155
155
|
"why-is-node-running": "^2.2.2",
|
|
156
|
-
"@vitest/expect": "1.
|
|
157
|
-
"@vitest/runner": "1.
|
|
158
|
-
"@vitest/spy": "1.
|
|
159
|
-
"@vitest/
|
|
160
|
-
"@vitest/
|
|
161
|
-
"vite-node": "1.
|
|
156
|
+
"@vitest/expect": "1.5.1",
|
|
157
|
+
"@vitest/runner": "1.5.1",
|
|
158
|
+
"@vitest/spy": "1.5.1",
|
|
159
|
+
"@vitest/utils": "1.5.1",
|
|
160
|
+
"@vitest/snapshot": "1.5.1",
|
|
161
|
+
"vite-node": "1.5.1"
|
|
162
162
|
},
|
|
163
163
|
"devDependencies": {
|
|
164
164
|
"@ampproject/remapping": "^2.2.1",
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
"find-up": "^6.3.0",
|
|
183
183
|
"flatted": "^3.2.9",
|
|
184
184
|
"get-tsconfig": "^4.7.3",
|
|
185
|
-
"happy-dom": "^
|
|
185
|
+
"happy-dom": "^14.3.10",
|
|
186
186
|
"jsdom": "^24.0.0",
|
|
187
187
|
"log-update": "^5.0.1",
|
|
188
188
|
"micromatch": "^4.0.5",
|