vitest 4.0.0-beta.10 → 4.0.0-beta.12
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 +85 -101
- package/dist/browser.d.ts +10 -6
- package/dist/browser.js +8 -5
- package/dist/chunks/{benchmark.CJUa-Hsa.js → benchmark.DHKMYAts.js} +2 -2
- package/dist/chunks/{browser.d.yFAklsD1.d.ts → browser.d.D9YV3JvA.d.ts} +1 -1
- package/dist/chunks/{cac.DCxo_nSu.js → cac.r1gel_VZ.js} +18 -11
- package/dist/chunks/{cli-api.BJJXh9BV.js → cli-api.CpywZzJV.js} +153 -176
- package/dist/chunks/{config.d.B_LthbQq.d.ts → config.d.DGazh2r6.d.ts} +3 -1
- package/dist/chunks/{console.7h5kHUIf.js → console.CTJL2nuH.js} +4 -6
- package/dist/chunks/{coverage.BCU-r2QL.js → coverage.CiB0fs_7.js} +57 -79
- package/dist/chunks/{creator.08Gi-vCA.js → creator.DfXDsUyL.js} +6 -8
- package/dist/chunks/{global.d.BK3X7FW1.d.ts → global.d.BcFPD2LN.d.ts} +0 -13
- package/dist/chunks/{globals.DG-S3xFe.js → globals.DC4ntO86.js} +8 -6
- package/dist/chunks/{index.DIWhzsUh.js → index.Bt-upxGS.js} +6 -12
- package/dist/chunks/{index.BIP7prJq.js → index.CHrBLuEH.js} +94 -103
- package/dist/chunks/{index.X0nbfr6-.js → index.Dc3xnDvT.js} +48 -289
- package/dist/chunks/{index.CMfqw92x.js → index.Dnl38iQ_.js} +2 -2
- package/dist/chunks/{index.BjKEiSn0.js → index.uLUz1RDt.js} +3 -3
- package/dist/chunks/{inspector.CvQD-Nie.js → inspector.Br76Q2Mb.js} +1 -4
- package/dist/chunks/{moduleRunner.d.D9nBoC4p.d.ts → moduleRunner.d.CeYc7nZ0.d.ts} +1 -1
- package/dist/chunks/{node.CyipiPvJ.js → node.BwAWWjHZ.js} +3 -4
- package/dist/chunks/{plugin.d.BMVSnsGV.d.ts → plugin.d.XreRXLXS.d.ts} +1 -1
- package/dist/chunks/{reporters.d.BUWjmRYq.d.ts → reporters.d.CJVTaaWb.d.ts} +54 -13
- package/dist/chunks/{resolveSnapshotEnvironment.Bkht6Yor.js → resolveSnapshotEnvironment.BsJpmVZR.js} +7 -8
- package/dist/chunks/{rpc.BKr6mtxz.js → rpc.cD77ENhU.js} +13 -14
- package/dist/chunks/{setup-common.uiMcU3cv.js → setup-common.BewgbkTd.js} +6 -6
- package/dist/chunks/{startModuleRunner.p67gbNo9.js → startModuleRunner.DPBo3mme.js} +65 -56
- package/dist/chunks/{test.BiqSKISg.js → test.CTuWuHYH.js} +7 -7
- package/dist/chunks/{typechecker.DB-fIMaH.js → typechecker.BfOQ86_a.js} +624 -14
- package/dist/chunks/{utils.D2R2NiOH.js → utils.CG9h5ccR.js} +2 -5
- package/dist/chunks/{vi.ZPgvtBao.js → vi.B2--mG9U.js} +38 -145
- package/dist/{worker.js → chunks/worker.DVTUM2IW.js} +71 -42
- package/dist/chunks/{worker.d.BDsXGkwh.d.ts → worker.d.buwuBpBt.d.ts} +2 -77
- package/dist/cli.js +7 -5
- package/dist/config.d.ts +6 -6
- package/dist/coverage.d.ts +5 -5
- package/dist/coverage.js +4 -5
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +8 -6
- package/dist/module-evaluator.d.ts +3 -3
- package/dist/module-evaluator.js +11 -13
- package/dist/module-runner.js +5 -5
- package/dist/node.d.ts +14 -11
- package/dist/node.js +18 -14
- package/dist/reporters.d.ts +5 -5
- package/dist/reporters.js +7 -5
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +9 -7
- package/dist/snapshot.js +3 -3
- package/dist/suite.js +4 -3
- package/dist/{chunks/base.Cjha6usc.js → worker-base.js} +104 -32
- package/dist/{chunks/vm.Ca0Y0W5f.js → worker-vm.js} +81 -31
- package/dist/workers/runVmTests.js +14 -11
- package/package.json +26 -26
- package/browser.d.ts +0 -1
- package/dist/chunks/moduleTransport.I-bgQy0S.js +0 -19
- package/dist/chunks/resolver.Bx6lE0iq.js +0 -119
- package/dist/chunks/utils.C2YI6McM.js +0 -52
- package/dist/chunks/worker.d.BNcX_2mH.d.ts +0 -8
- package/dist/workers/forks.js +0 -67
- package/dist/workers/threads.js +0 -55
- package/dist/workers/vmForks.js +0 -48
- package/dist/workers/vmThreads.js +0 -38
- package/dist/workers.d.ts +0 -38
- package/dist/workers.js +0 -48
- package/execute.d.ts +0 -1
- package/utils.d.ts +0 -1
- package/workers.d.ts +0 -1
|
@@ -1,301 +1,60 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { resolve, isAbsolute, dirname, join } from 'node:path';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import 'node:module';
|
|
4
|
+
import 'node:url';
|
|
5
5
|
import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
|
|
6
6
|
import require$$0 from 'readline';
|
|
7
7
|
import require$$0$1 from 'events';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
get: function () { return e[k]; }
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
return Object.freeze(n);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/*
|
|
25
|
-
How it works:
|
|
26
|
-
`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
|
|
9
|
+
/**
|
|
10
|
+
* Resolve an absolute path from {@link root}, but only
|
|
11
|
+
* if {@link input} isn't already absolute.
|
|
12
|
+
*
|
|
13
|
+
* @param input The path to resolve.
|
|
14
|
+
* @param root The base path; default = process.cwd()
|
|
15
|
+
* @returns The resolved absolute path.
|
|
27
16
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
value;
|
|
31
|
-
next;
|
|
32
|
-
|
|
33
|
-
constructor(value) {
|
|
34
|
-
this.value = value;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
class Queue {
|
|
39
|
-
#head;
|
|
40
|
-
#tail;
|
|
41
|
-
#size;
|
|
42
|
-
|
|
43
|
-
constructor() {
|
|
44
|
-
this.clear();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
enqueue(value) {
|
|
48
|
-
const node = new Node(value);
|
|
49
|
-
|
|
50
|
-
if (this.#head) {
|
|
51
|
-
this.#tail.next = node;
|
|
52
|
-
this.#tail = node;
|
|
53
|
-
} else {
|
|
54
|
-
this.#head = node;
|
|
55
|
-
this.#tail = node;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
this.#size++;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
dequeue() {
|
|
62
|
-
const current = this.#head;
|
|
63
|
-
if (!current) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
this.#head = this.#head.next;
|
|
68
|
-
this.#size--;
|
|
69
|
-
return current.value;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
clear() {
|
|
73
|
-
this.#head = undefined;
|
|
74
|
-
this.#tail = undefined;
|
|
75
|
-
this.#size = 0;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
get size() {
|
|
79
|
-
return this.#size;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
* [Symbol.iterator]() {
|
|
83
|
-
let current = this.#head;
|
|
84
|
-
|
|
85
|
-
while (current) {
|
|
86
|
-
yield current.value;
|
|
87
|
-
current = current.next;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function pLimit(concurrency) {
|
|
93
|
-
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
94
|
-
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const queue = new Queue();
|
|
98
|
-
let activeCount = 0;
|
|
99
|
-
|
|
100
|
-
const next = () => {
|
|
101
|
-
activeCount--;
|
|
102
|
-
|
|
103
|
-
if (queue.size > 0) {
|
|
104
|
-
queue.dequeue()();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const run = async (fn, resolve, args) => {
|
|
109
|
-
activeCount++;
|
|
110
|
-
|
|
111
|
-
const result = (async () => fn(...args))();
|
|
112
|
-
|
|
113
|
-
resolve(result);
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
await result;
|
|
117
|
-
} catch {}
|
|
118
|
-
|
|
119
|
-
next();
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const enqueue = (fn, resolve, args) => {
|
|
123
|
-
queue.enqueue(run.bind(undefined, fn, resolve, args));
|
|
124
|
-
|
|
125
|
-
(async () => {
|
|
126
|
-
// This function needs to wait until the next microtask before comparing
|
|
127
|
-
// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
|
|
128
|
-
// when the run function is dequeued and called. The comparison in the if-statement
|
|
129
|
-
// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
|
|
130
|
-
await Promise.resolve();
|
|
131
|
-
|
|
132
|
-
if (activeCount < concurrency && queue.size > 0) {
|
|
133
|
-
queue.dequeue()();
|
|
134
|
-
}
|
|
135
|
-
})();
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const generator = (fn, ...args) => new Promise(resolve => {
|
|
139
|
-
enqueue(fn, resolve, args);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
Object.defineProperties(generator, {
|
|
143
|
-
activeCount: {
|
|
144
|
-
get: () => activeCount,
|
|
145
|
-
},
|
|
146
|
-
pendingCount: {
|
|
147
|
-
get: () => queue.size,
|
|
148
|
-
},
|
|
149
|
-
clearQueue: {
|
|
150
|
-
value: () => {
|
|
151
|
-
queue.clear();
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
return generator;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
class EndError extends Error {
|
|
160
|
-
constructor(value) {
|
|
161
|
-
super();
|
|
162
|
-
this.value = value;
|
|
163
|
-
}
|
|
17
|
+
function absolute(input, root) {
|
|
18
|
+
return isAbsolute(input) ? input : resolve(root || ".", input);
|
|
164
19
|
}
|
|
165
20
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
tester,
|
|
182
|
-
{
|
|
183
|
-
concurrency = Number.POSITIVE_INFINITY,
|
|
184
|
-
preserveOrder = true,
|
|
185
|
-
} = {},
|
|
186
|
-
) {
|
|
187
|
-
const limit = pLimit(concurrency);
|
|
188
|
-
|
|
189
|
-
// Start all the promises concurrently with optional limit.
|
|
190
|
-
const items = [...iterable].map(element => [element, limit(testElement, element, tester)]);
|
|
191
|
-
|
|
192
|
-
// Check the promises either serially or concurrently.
|
|
193
|
-
const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
|
|
194
|
-
|
|
195
|
-
try {
|
|
196
|
-
await Promise.all(items.map(element => checkLimit(finder, element)));
|
|
197
|
-
} catch (error) {
|
|
198
|
-
if (error instanceof EndError) {
|
|
199
|
-
return error.value;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
throw error;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const typeMappings = {
|
|
207
|
-
directory: 'isDirectory',
|
|
208
|
-
file: 'isFile',
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
function checkType(type) {
|
|
212
|
-
if (Object.hasOwnProperty.call(typeMappings, type)) {
|
|
213
|
-
return;
|
|
21
|
+
/**
|
|
22
|
+
* Get all parent directories of {@link base}.
|
|
23
|
+
* Stops after {@link Options['last']} is processed.
|
|
24
|
+
*
|
|
25
|
+
* @returns An array of absolute paths of all parent directories.
|
|
26
|
+
*/
|
|
27
|
+
function up(base, options) {
|
|
28
|
+
let { last, cwd } = options || {};
|
|
29
|
+
let tmp = absolute(base, cwd);
|
|
30
|
+
let root = absolute(last || "/", cwd);
|
|
31
|
+
let prev, arr = [];
|
|
32
|
+
while (prev !== root) {
|
|
33
|
+
arr.push(tmp);
|
|
34
|
+
tmp = dirname(prev = tmp);
|
|
35
|
+
if (tmp === prev) break;
|
|
214
36
|
}
|
|
215
|
-
|
|
216
|
-
throw new Error(`Invalid type specified: ${type}`);
|
|
37
|
+
return arr;
|
|
217
38
|
}
|
|
218
39
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const statFunction = allowSymlinks ? promises.stat : promises.lstat;
|
|
237
|
-
|
|
238
|
-
return pLocate(paths, async path_ => {
|
|
239
|
-
try {
|
|
240
|
-
const stat = await statFunction(path.resolve(cwd, path_));
|
|
241
|
-
return matchType(type, stat);
|
|
242
|
-
} catch {
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
}, {concurrency, preserveOrder});
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
249
|
-
|
|
250
|
-
const findUpStop = Symbol('findUpStop');
|
|
251
|
-
|
|
252
|
-
async function findUpMultiple(name, options = {}) {
|
|
253
|
-
let directory = path.resolve(toPath(options.cwd) || '');
|
|
254
|
-
const {root} = path.parse(directory);
|
|
255
|
-
const stopAt = path.resolve(directory, options.stopAt || root);
|
|
256
|
-
const limit = options.limit || Number.POSITIVE_INFINITY;
|
|
257
|
-
const paths = [name].flat();
|
|
258
|
-
|
|
259
|
-
const runMatcher = async locateOptions => {
|
|
260
|
-
if (typeof name !== 'function') {
|
|
261
|
-
return locatePath(paths, locateOptions);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const foundPath = await name(locateOptions.cwd);
|
|
265
|
-
if (typeof foundPath === 'string') {
|
|
266
|
-
return locatePath([foundPath], locateOptions);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return foundPath;
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
const matches = [];
|
|
273
|
-
// eslint-disable-next-line no-constant-condition
|
|
274
|
-
while (true) {
|
|
275
|
-
// eslint-disable-next-line no-await-in-loop
|
|
276
|
-
const foundPath = await runMatcher({...options, cwd: directory});
|
|
277
|
-
|
|
278
|
-
if (foundPath === findUpStop) {
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (foundPath) {
|
|
283
|
-
matches.push(path.resolve(directory, foundPath));
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (directory === stopAt || matches.length >= limit) {
|
|
287
|
-
break;
|
|
40
|
+
/**
|
|
41
|
+
* Get the first path that matches any of the names provided.
|
|
42
|
+
*
|
|
43
|
+
* > [NOTE]
|
|
44
|
+
* > The order of {@link names} is respected.
|
|
45
|
+
*
|
|
46
|
+
* @param names The item names to find.
|
|
47
|
+
* @returns The absolute path of the first item found, if any.
|
|
48
|
+
*/
|
|
49
|
+
function any(names, options) {
|
|
50
|
+
let dir, start = options && options.cwd || "";
|
|
51
|
+
let j = 0, len = names.length, tmp;
|
|
52
|
+
for (dir of up(start, options)) {
|
|
53
|
+
for (j = 0; j < len; j++) {
|
|
54
|
+
tmp = join(dir, names[j]);
|
|
55
|
+
if (existsSync(tmp)) return tmp;
|
|
288
56
|
}
|
|
289
|
-
|
|
290
|
-
directory = path.dirname(directory);
|
|
291
57
|
}
|
|
292
|
-
|
|
293
|
-
return matches;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
async function findUp(name, options = {}) {
|
|
297
|
-
const matches = await findUpMultiple(name, {...options, limit: 1});
|
|
298
|
-
return matches[0];
|
|
299
58
|
}
|
|
300
59
|
|
|
301
60
|
var prompts$2 = {};
|
|
@@ -6576,9 +6335,9 @@ function requirePrompts () {
|
|
|
6576
6335
|
var promptsExports = requirePrompts();
|
|
6577
6336
|
var prompt = /*@__PURE__*/getDefaultExportFromCjs(promptsExports);
|
|
6578
6337
|
|
|
6579
|
-
var index = /*#__PURE__*/
|
|
6338
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
6580
6339
|
__proto__: null,
|
|
6581
6340
|
default: prompt
|
|
6582
|
-
}
|
|
6341
|
+
});
|
|
6583
6342
|
|
|
6584
|
-
export {
|
|
6343
|
+
export { any as a, index as i, prompt as p };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as assert, c as createExpect, g as globalExpect, i as inject, s as should, v as vi, d as vitest } from './vi.
|
|
2
|
-
import { b as bench } from './benchmark.
|
|
1
|
+
import { b as assert, c as createExpect, g as globalExpect, i as inject, s as should, v as vi, d as vitest } from './vi.B2--mG9U.js';
|
|
2
|
+
import { b as bench } from './benchmark.DHKMYAts.js';
|
|
3
3
|
import { expectTypeOf } from 'expect-type';
|
|
4
4
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
5
5
|
import { EvaluatedModules } from 'vite/module-runner';
|
|
@@ -2,9 +2,9 @@ import fs from 'node:fs';
|
|
|
2
2
|
import { getTasks, getFullName, getTests } from '@vitest/runner/utils';
|
|
3
3
|
import * as pathe from 'pathe';
|
|
4
4
|
import c from 'tinyrainbow';
|
|
5
|
-
import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName } from './index.
|
|
5
|
+
import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.CHrBLuEH.js';
|
|
6
6
|
import { stripVTControlCharacters } from 'node:util';
|
|
7
|
-
import { notNullish } from '@vitest/utils';
|
|
7
|
+
import { notNullish } from '@vitest/utils/helpers';
|
|
8
8
|
|
|
9
9
|
function createBenchmarkJsonReport(files) {
|
|
10
10
|
const report = { files: [] };
|
|
@@ -183,7 +183,7 @@ class BenchmarkReporter extends DefaultReporter {
|
|
|
183
183
|
if (state === "pending" || state === "queued") return;
|
|
184
184
|
const benches = testTask.task.tasks.filter((t) => t.meta.benchmark), duration = testTask.task.result?.duration || 0;
|
|
185
185
|
if (benches.length > 0 && benches.every((t) => t.result?.state !== "run" && t.result?.state !== "queued")) {
|
|
186
|
-
let title = `\n ${getStateSymbol(testTask.task)} ${formatProjectName(testTask.project)}${getFullName(testTask.task,
|
|
186
|
+
let title = `\n ${getStateSymbol(testTask.task)} ${formatProjectName(testTask.project)}${getFullName(testTask.task, separator)}`;
|
|
187
187
|
if (duration != null && duration > this.ctx.config.slowTestThreshold) title += c.yellow(` ${Math.round(duration)}${c.dim("ms")}`);
|
|
188
188
|
this.log(title), this.log(renderTable({
|
|
189
189
|
tasks: benches,
|
|
@@ -10,10 +10,7 @@ let inspector, session;
|
|
|
10
10
|
function setupInspect(ctx) {
|
|
11
11
|
const config = ctx.config, isEnabled = config.inspector.enabled;
|
|
12
12
|
if (isEnabled) {
|
|
13
|
-
inspector = __require("node:inspector")
|
|
14
|
-
// Inspector may be open already if "isolate: false" is used
|
|
15
|
-
const isOpen = inspector.url() !== void 0;
|
|
16
|
-
if (!isOpen) {
|
|
13
|
+
if (inspector = __require("node:inspector"), !(inspector.url() !== void 0)) {
|
|
17
14
|
if (inspector.open(config.inspector.port, config.inspector.host, config.inspector.waitForDebugger), config.inspectBrk) {
|
|
18
15
|
const firstTestFile = typeof ctx.files[0] === "string" ? ctx.files[0] : ctx.files[0].filepath;
|
|
19
16
|
// Stop at first test file
|
|
@@ -2,7 +2,7 @@ import * as _vitest_spy from '@vitest/spy';
|
|
|
2
2
|
import vm from 'node:vm';
|
|
3
3
|
import * as viteModuleRunner from 'vite/module-runner';
|
|
4
4
|
import { ModuleEvaluator, ModuleRunnerImportMeta, ModuleRunnerContext, EvaluatedModuleNode, FetchFunction, EvaluatedModules } from 'vite/module-runner';
|
|
5
|
-
import {
|
|
5
|
+
import { a as RuntimeRPC, W as WorkerGlobalState } from './worker.d.buwuBpBt.js';
|
|
6
6
|
import { R as ResolveFunctionResult } from './environment.d.BsToaxti.js';
|
|
7
7
|
import { MockedModule, MockedModuleType } from '@vitest/mocker';
|
|
8
8
|
import { P as PendingSuiteMock, b as MockFactory, a as MockOptions } from './mocker.d.BE_2ls6u.js';
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
|
|
2
|
-
import { g as getWorkerState } from './utils.
|
|
3
|
-
import '@vitest/utils';
|
|
2
|
+
import { g as getWorkerState } from './utils.CG9h5ccR.js';
|
|
3
|
+
import '@vitest/utils/timers';
|
|
4
4
|
|
|
5
5
|
class VitestNodeSnapshotEnvironment extends NodeSnapshotEnvironment {
|
|
6
6
|
getHeader() {
|
|
7
7
|
return `// Vitest Snapshot v${this.getVersion()}, https://vitest.dev/guide/snapshot.html`;
|
|
8
8
|
}
|
|
9
9
|
resolvePath(filepath) {
|
|
10
|
-
|
|
11
|
-
return rpc.resolveSnapshotPath(filepath);
|
|
10
|
+
return getWorkerState().rpc.resolveSnapshotPath(filepath);
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
|
|
@@ -5,8 +5,8 @@ import { Writable } from 'node:stream';
|
|
|
5
5
|
import { ViteDevServer, TransformResult as TransformResult$1, UserConfig as UserConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
|
|
6
6
|
import { MockedModule } from '@vitest/mocker';
|
|
7
7
|
import { StackTraceParserOptions } from '@vitest/utils/source-map';
|
|
8
|
-
import { B as
|
|
9
|
-
import {
|
|
8
|
+
import { B as BrowserTraceViewMode, a as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.DGazh2r6.js';
|
|
9
|
+
import { B as BrowserTesterOptions, S as SerializedTestSpecification } from './browser.d.D9YV3JvA.js';
|
|
10
10
|
import { PrettyFormatOptions } from '@vitest/pretty-format';
|
|
11
11
|
import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
|
|
12
12
|
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
|
@@ -178,6 +178,31 @@ interface BrowserConfigOptions {
|
|
|
178
178
|
testIdAttribute?: string;
|
|
179
179
|
};
|
|
180
180
|
/**
|
|
181
|
+
* Generate traces that can be viewed on https://trace.playwright.dev/
|
|
182
|
+
*
|
|
183
|
+
* This option is supported only by **playwright** provider.
|
|
184
|
+
*/
|
|
185
|
+
trace?: BrowserTraceViewMode | {
|
|
186
|
+
mode: BrowserTraceViewMode;
|
|
187
|
+
/**
|
|
188
|
+
* The directory where all traces will be stored. By default, Vitest
|
|
189
|
+
* stores all traces in `__traces__` folder close to the test file.
|
|
190
|
+
*/
|
|
191
|
+
tracesDir?: string;
|
|
192
|
+
/**
|
|
193
|
+
* Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview.
|
|
194
|
+
* @default true
|
|
195
|
+
*/
|
|
196
|
+
screenshots?: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* If this option is true tracing will
|
|
199
|
+
* - capture DOM snapshot on every action
|
|
200
|
+
* - record network activity
|
|
201
|
+
* @default true
|
|
202
|
+
*/
|
|
203
|
+
snapshots?: boolean;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
181
206
|
* Directory where screenshots will be saved when page.screenshot() is called
|
|
182
207
|
* If not set, all screenshots are saved to __screenshots__ directory in the same folder as the test file.
|
|
183
208
|
* If this is set, it will be resolved relative to the project root.
|
|
@@ -261,7 +286,7 @@ interface ProjectBrowser {
|
|
|
261
286
|
parseStacktrace: (stack: string) => ParsedStack[];
|
|
262
287
|
parseErrorStacktrace: (error: TestError, options?: StackTraceParserOptions) => ParsedStack[];
|
|
263
288
|
}
|
|
264
|
-
interface BrowserCommand<Payload extends unknown[]> {
|
|
289
|
+
interface BrowserCommand<Payload extends unknown[] = []> {
|
|
265
290
|
(context: BrowserCommandContext, ...payload: Payload): Awaitable<any>;
|
|
266
291
|
}
|
|
267
292
|
interface BrowserScript {
|
|
@@ -308,6 +333,12 @@ interface ResolvedBrowserOptions extends BrowserConfigOptions {
|
|
|
308
333
|
locators: {
|
|
309
334
|
testIdAttribute: string;
|
|
310
335
|
};
|
|
336
|
+
trace: {
|
|
337
|
+
mode: BrowserTraceViewMode;
|
|
338
|
+
tracesDir?: string;
|
|
339
|
+
screenshots?: boolean;
|
|
340
|
+
snapshots?: boolean;
|
|
341
|
+
};
|
|
311
342
|
}
|
|
312
343
|
type ToMatchScreenshotResolvePath = (data: {
|
|
313
344
|
/**
|
|
@@ -1512,6 +1543,7 @@ declare class StateManager {
|
|
|
1512
1543
|
clearFiles(project: TestProject, paths?: string[]): void;
|
|
1513
1544
|
updateId(task: Task, project: TestProject): void;
|
|
1514
1545
|
getReportedEntity(task: Task): TestModule | TestCase | TestSuite | undefined;
|
|
1546
|
+
getReportedEntityById(taskId: string): TestModule | TestCase | TestSuite | undefined;
|
|
1515
1547
|
updateTasks(packs: TaskResultPack[]): void;
|
|
1516
1548
|
updateUserLog(log: UserConsoleLog): void;
|
|
1517
1549
|
getCountOfFailedTests(): number;
|
|
@@ -1674,6 +1706,10 @@ declare class Vitest {
|
|
|
1674
1706
|
* Merge reports from multiple runs located in the specified directory (value from `--merge-reports` if not specified).
|
|
1675
1707
|
*/
|
|
1676
1708
|
mergeReports(directory?: string): Promise<TestRunResult>;
|
|
1709
|
+
/**
|
|
1710
|
+
* Returns the seed, if tests are running in a random order.
|
|
1711
|
+
*/
|
|
1712
|
+
getSeed(): number | null;
|
|
1677
1713
|
collect(filters?: string[]): Promise<TestRunResult>;
|
|
1678
1714
|
/**
|
|
1679
1715
|
* Returns the list of test files that match the config and filters.
|
|
@@ -1922,13 +1958,15 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
1922
1958
|
protected printTestModule(testModule: TestModule): void;
|
|
1923
1959
|
protected printTestCase(moduleState: TestModuleState, test: TestCase): void;
|
|
1924
1960
|
private getModuleLog;
|
|
1925
|
-
protected printTestSuite(
|
|
1926
|
-
protected getTestName(test: Task,
|
|
1961
|
+
protected printTestSuite(testSuite: TestSuite): void;
|
|
1962
|
+
protected getTestName(test: Task, _separator?: string): string;
|
|
1927
1963
|
protected getFullName(test: Task, separator?: string): string;
|
|
1928
|
-
protected
|
|
1929
|
-
protected getTestIndentation(_test: Task): string;
|
|
1964
|
+
protected getTestIndentation(test: Task): string;
|
|
1930
1965
|
protected printAnnotations(test: TestCase, console: "log" | "error", padding?: number): void;
|
|
1931
|
-
protected
|
|
1966
|
+
protected getEntityPrefix(entity: TestCase | TestModule | TestSuite): string;
|
|
1967
|
+
protected getTestCaseSuffix(testCase: TestCase): string;
|
|
1968
|
+
protected getStateSymbol(test: TestCase | TestModule | TestSuite): string;
|
|
1969
|
+
private getDurationPrefix;
|
|
1932
1970
|
onWatcherStart(files?: File[], errors?: unknown[]): void;
|
|
1933
1971
|
onWatcherRerun(files: string[], trigger?: string): void;
|
|
1934
1972
|
onUserConsoleLog(log: UserConsoleLog, taskState?: TestResult["state"]): void;
|
|
@@ -2111,15 +2149,16 @@ declare class TapFlatReporter extends TapReporter {
|
|
|
2111
2149
|
onTestRunEnd(testModules: ReadonlyArray<TestModule>): void;
|
|
2112
2150
|
}
|
|
2113
2151
|
|
|
2152
|
+
declare class TreeReporter extends DefaultReporter {
|
|
2153
|
+
protected verbose: boolean;
|
|
2154
|
+
renderSucceed: boolean;
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2114
2157
|
declare class VerboseReporter extends DefaultReporter {
|
|
2115
2158
|
protected verbose: boolean;
|
|
2116
2159
|
renderSucceed: boolean;
|
|
2117
|
-
printTestModule(
|
|
2160
|
+
printTestModule(_module: TestModule): void;
|
|
2118
2161
|
onTestCaseResult(test: TestCase): void;
|
|
2119
|
-
protected printTestSuite(testSuite: TestSuite): void;
|
|
2120
|
-
protected getTestName(test: Task): string;
|
|
2121
|
-
protected getTestIndentation(test: Task): string;
|
|
2122
|
-
protected formatShortError(): string;
|
|
2123
2162
|
}
|
|
2124
2163
|
|
|
2125
2164
|
type FormattedBenchmarkResult = BenchmarkResult & {
|
|
@@ -2165,6 +2204,7 @@ declare const ReportersMap: {
|
|
|
2165
2204
|
tap: typeof TapReporter;
|
|
2166
2205
|
"tap-flat": typeof TapFlatReporter;
|
|
2167
2206
|
junit: typeof JUnitReporter;
|
|
2207
|
+
tree: typeof TreeReporter;
|
|
2168
2208
|
"hanging-process": typeof HangingProcessReporter;
|
|
2169
2209
|
"github-actions": typeof GithubActionsReporter;
|
|
2170
2210
|
};
|
|
@@ -2173,6 +2213,7 @@ interface BuiltinReporterOptions {
|
|
|
2173
2213
|
"default": DefaultReporterOptions;
|
|
2174
2214
|
"verbose": DefaultReporterOptions;
|
|
2175
2215
|
"dot": BaseOptions;
|
|
2216
|
+
"tree": BaseOptions;
|
|
2176
2217
|
"json": JsonOptions;
|
|
2177
2218
|
"blob": BlobOptions;
|
|
2178
2219
|
"tap": never;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { chai } from '@vitest/expect';
|
|
2
|
-
import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.
|
|
3
|
-
import { r as rpc } from './rpc.
|
|
4
|
-
import { g as getWorkerState } from './utils.
|
|
5
|
-
import { V as VitestTestRunner, N as NodeBenchmarkRunner } from './test.
|
|
2
|
+
import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.BewgbkTd.js';
|
|
3
|
+
import { r as rpc } from './rpc.cD77ENhU.js';
|
|
4
|
+
import { g as getWorkerState } from './utils.CG9h5ccR.js';
|
|
5
|
+
import { V as VitestTestRunner, N as NodeBenchmarkRunner } from './test.CTuWuHYH.js';
|
|
6
6
|
|
|
7
7
|
function setupChaiConfig(config) {
|
|
8
8
|
Object.assign(chai.config, config);
|
|
@@ -15,7 +15,7 @@ async function getTestRunnerConstructor(config, moduleRunner) {
|
|
|
15
15
|
return mod.default;
|
|
16
16
|
}
|
|
17
17
|
async function resolveTestRunner(config, moduleRunner) {
|
|
18
|
-
const
|
|
18
|
+
const testRunner = new (await (getTestRunnerConstructor(config, moduleRunner)))(config);
|
|
19
19
|
if (Object.defineProperty(testRunner, "moduleRunner", {
|
|
20
20
|
value: moduleRunner,
|
|
21
21
|
enumerable: false,
|
|
@@ -61,8 +61,7 @@ async function resolveTestRunner(config, moduleRunner) {
|
|
|
61
61
|
const originalOnAfterRunTask = testRunner.onAfterRunTask;
|
|
62
62
|
return testRunner.onAfterRunTask = async (test) => {
|
|
63
63
|
if (config.bail && test.result?.state === "fail") {
|
|
64
|
-
|
|
65
|
-
if (currentFailures >= config.bail) rpc().onCancel("test-failure"), testRunner.cancel?.("test-failure");
|
|
64
|
+
if (1 + await rpc().getCountOfFailedTests() >= config.bail) rpc().onCancel("test-failure"), testRunner.cancel?.("test-failure");
|
|
66
65
|
}
|
|
67
66
|
await originalOnAfterRunTask?.call(testRunner, test);
|
|
68
67
|
}, testRunner;
|
|
@@ -70,7 +69,7 @@ async function resolveTestRunner(config, moduleRunner) {
|
|
|
70
69
|
|
|
71
70
|
async function resolveSnapshotEnvironment(config, executor) {
|
|
72
71
|
if (!config.snapshotEnvironment) {
|
|
73
|
-
const { VitestNodeSnapshotEnvironment } = await import('./node.
|
|
72
|
+
const { VitestNodeSnapshotEnvironment } = await import('./node.BwAWWjHZ.js');
|
|
74
73
|
return new VitestNodeSnapshotEnvironment();
|
|
75
74
|
}
|
|
76
75
|
const mod = await executor.import(config.snapshotEnvironment);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getSafeTimers } from '@vitest/utils';
|
|
1
|
+
import { getSafeTimers } from '@vitest/utils/timers';
|
|
2
2
|
import { c as createBirpc } from './index.Bgo3tNWt.js';
|
|
3
|
-
import { g as getWorkerState } from './utils.
|
|
3
|
+
import { g as getWorkerState } from './utils.CG9h5ccR.js';
|
|
4
4
|
|
|
5
5
|
const { get } = Reflect;
|
|
6
6
|
function withSafeTimers(fn) {
|
|
@@ -9,8 +9,7 @@ function withSafeTimers(fn) {
|
|
|
9
9
|
if (globalThis.setTimeout = setTimeout, globalThis.clearTimeout = clearTimeout, setImmediate) globalThis.setImmediate = setImmediate;
|
|
10
10
|
if (clearImmediate) globalThis.clearImmediate = clearImmediate;
|
|
11
11
|
if (globalThis.process && nextTick) globalThis.process.nextTick = nextTick;
|
|
12
|
-
|
|
13
|
-
return result;
|
|
12
|
+
return fn();
|
|
14
13
|
} finally {
|
|
15
14
|
if (globalThis.setTimeout = currentSetTimeout, globalThis.clearTimeout = currentClearTimeout, globalThis.setImmediate = currentSetImmediate, globalThis.clearImmediate = currentClearImmediate, globalThis.process && nextTick) nextTick(() => {
|
|
16
15
|
globalThis.process.nextTick = currentNextTick;
|
|
@@ -27,17 +26,17 @@ function createRuntimeRpc(options) {
|
|
|
27
26
|
let setCancel = (_reason) => {};
|
|
28
27
|
const onCancel = new Promise((resolve) => {
|
|
29
28
|
setCancel = resolve;
|
|
30
|
-
})
|
|
31
|
-
eventNames: [
|
|
32
|
-
"onUserConsoleLog",
|
|
33
|
-
"onCollected",
|
|
34
|
-
"onCancel"
|
|
35
|
-
],
|
|
36
|
-
timeout: -1,
|
|
37
|
-
...options
|
|
38
|
-
}));
|
|
29
|
+
});
|
|
39
30
|
return {
|
|
40
|
-
rpc,
|
|
31
|
+
rpc: createSafeRpc(createBirpc({ onCancel: setCancel }, {
|
|
32
|
+
eventNames: [
|
|
33
|
+
"onUserConsoleLog",
|
|
34
|
+
"onCollected",
|
|
35
|
+
"onCancel"
|
|
36
|
+
],
|
|
37
|
+
timeout: -1,
|
|
38
|
+
...options
|
|
39
|
+
})),
|
|
41
40
|
onCancel
|
|
42
41
|
};
|
|
43
42
|
}
|