vitest 5.0.5 → 5.1.0

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.
Files changed (62) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/browser.d.ts +6 -5
  3. package/dist/browser.js +6 -6
  4. package/dist/chunks/{base.CzXt2BO_.js → base.Cof-UHJf.js} +17 -21
  5. package/dist/chunks/{browser.d.FGQ9_rK6.d.ts → browser.d.C7tWgUvw.d.ts} +4 -3
  6. package/dist/chunks/{cac.CLrZKo1g.js → cac.BYbt0aJp.js} +30 -16
  7. package/dist/chunks/{cli-api.De07GUeT.js → cli-api.COfZo8lK.js} +5226 -4385
  8. package/dist/chunks/{config.d.QBNYCgFU.d.ts → config.d.B3YV4t0O.d.ts} +169 -93
  9. package/dist/chunks/{console.DtI4yxfN.js → console.CQZ877Hi.js} +6 -3
  10. package/dist/chunks/{constants.-juJ8b_4.js → constants.DLYM6cZY.js} +1 -1
  11. package/dist/chunks/{coverage.-bm5IxnW.js → coverage.9iqXE2gN.js} +1 -1
  12. package/dist/chunks/{coverage.cTDc4uSS.js → coverage.jGCktcGP.js} +1 -1
  13. package/dist/chunks/{creator.C5g4egeG.js → creator.DHWmytIK.js} +11 -11
  14. package/dist/chunks/{doctor.BK86Cncq.js → doctor.B-oPbwps.js} +2 -2
  15. package/dist/chunks/{environment.d.BY56MoGs.d.ts → environment.d.BFQtFKdZ.d.ts} +1 -1
  16. package/dist/chunks/{globals.CXEE6_2C.js → globals.ZKtKSkEf.js} +7 -6
  17. package/dist/chunks/{index.CK-t0WMg.js → index.Bi0NXYPf.js} +165 -62
  18. package/dist/chunks/{index.aTZaPVhf.js → index.CZzC1gGg.js} +299 -440
  19. package/dist/chunks/{index.1TqnEahn.js → index.Di8au7q4.js} +104 -72
  20. package/dist/chunks/{index.CoUIxZd4.js → index.w_oBZ9N8.js} +5 -5
  21. package/dist/chunks/{init-forks.CRxIPOJR.js → init-forks.BaDXQSD8.js} +1 -1
  22. package/dist/chunks/{init-threads.Dv3kwST_.js → init-threads.ZX_Vov0z.js} +1 -1
  23. package/dist/chunks/{init.PvxYpuCm.js → init.CO4AB7HZ.js} +4 -4
  24. package/dist/chunks/{module-dependencies.CwNPkcV4.js → module-dependencies._2Eei3FO.js} +1 -1
  25. package/dist/chunks/{native.cdzHIdmv.js → native.upB-V0CK.js} +1 -1
  26. package/dist/chunks/{nativeModuleMocker.BxrHJNAF.js → nativeModuleMocker.Dh5azSB4.js} +4 -3
  27. package/dist/chunks/{nativeModuleRunner.xi64Afb2.js → nativeModuleRunner.9xPIMzi7.js} +1 -1
  28. package/dist/chunks/{node.uQulW0ei.js → node.B9mkVmLH.js} +1 -1
  29. package/dist/chunks/{pathe.M-eThtNZ.Ba-7h1rE.js → pathe.M-eThtNZ.zq3TM4NT.js} +1 -1
  30. package/dist/chunks/{plugin.d.C8mmycim.d.ts → plugin.d.LRFSN46m.d.ts} +191 -32
  31. package/dist/chunks/rawSnapshot.DqSiqIEx.js +356 -0
  32. package/dist/chunks/{resolver.CtCcxIy1.js → resolver.BzpmeQeT.js} +1 -1
  33. package/dist/chunks/{rpc.DpkUyY1N.js → rpc.Uhkwr2NM.js} +2 -2
  34. package/dist/chunks/{rpc.d.Cft1biqy.d.ts → rpc.d.3FOhdFx8.d.ts} +1 -1
  35. package/dist/chunks/{run.BPv-BBRv.js → run.CjdgFZiW.js} +28 -7
  36. package/dist/chunks/{setup-common.HGAqWOnX.js → setup-common.CqAQCXzx.js} +2 -2
  37. package/dist/chunks/{source-map.DdKI5IHB.js → source-map.DakdQc29.js} +43 -37
  38. package/dist/chunks/{source-map.d.kzFtk_dj.d.ts → source-map.d.BkG8YK_3.d.ts} +2 -1
  39. package/dist/chunks/{task-utils.d.PFh2BV6Q.d.ts → task-utils.d.D-gFPNFi.d.ts} +2 -1
  40. package/dist/chunks/{utils.DSfl_w8V.js → utils.BBk_icFG.js} +6 -3
  41. package/dist/chunks/{vm.FGl2rw_t.js → vm.b4MbCAJQ.js} +27 -14
  42. package/dist/chunks/{worker.d.BH-r1bPu.d.ts → worker.d.CyJRpyfZ.d.ts} +3 -3
  43. package/dist/cli.js +3 -3
  44. package/dist/config.cjs +1 -1
  45. package/dist/config.d.ts +11 -11
  46. package/dist/config.js +1 -1
  47. package/dist/index.d.ts +21 -15
  48. package/dist/index.js +6 -5
  49. package/dist/module-evaluator.d.ts +3 -2
  50. package/dist/node.d.ts +30 -12
  51. package/dist/node.js +16 -14
  52. package/dist/runtime.d.ts +4 -4
  53. package/dist/runtime.js +5 -4
  54. package/dist/task-utils.js +10 -4
  55. package/dist/worker.d.ts +4 -4
  56. package/dist/worker.js +14 -13
  57. package/dist/workers/forks.js +15 -14
  58. package/dist/workers/runVmTests.js +16 -12
  59. package/dist/workers/threads.js +15 -14
  60. package/dist/workers/vmForks.js +11 -10
  61. package/dist/workers/vmThreads.js +11 -10
  62. package/package.json +17 -17
@@ -0,0 +1,356 @@
1
+ import { f as isObject, h as getCallLastIndex } from './pathe.M-eThtNZ.zq3TM4NT.js';
2
+ import { p as positionToOffset, o as offsetToLineNumber, l as lineSplitRE } from './offset.Dy-5Fdfn.js';
3
+ import { g as getDefaultExportFromCjs, f as format } from './index.D0heQG4v.js';
4
+ import { g as getSerializers } from './plugins.DPQHVT0p.js';
5
+
6
+ var naturalCompare$1 = {exports: {}};
7
+
8
+ var hasRequiredNaturalCompare;
9
+
10
+ function requireNaturalCompare () {
11
+ if (hasRequiredNaturalCompare) return naturalCompare$1.exports;
12
+ hasRequiredNaturalCompare = 1;
13
+ /*
14
+ * @version 1.4.0
15
+ * @date 2015-10-26
16
+ * @stability 3 - Stable
17
+ * @author Lauri Rooden (https://github.com/litejs/natural-compare-lite)
18
+ * @license MIT License
19
+ */
20
+
21
+
22
+ var naturalCompare = function(a, b) {
23
+ var i, codeA
24
+ , codeB = 1
25
+ , posA = 0
26
+ , posB = 0
27
+ , alphabet = String.alphabet;
28
+
29
+ function getCode(str, pos, code) {
30
+ if (code) {
31
+ for (i = pos; code = getCode(str, i), code < 76 && code > 65;) ++i;
32
+ return +str.slice(pos - 1, i)
33
+ }
34
+ code = alphabet && alphabet.indexOf(str.charAt(pos));
35
+ return code > -1 ? code + 76 : ((code = str.charCodeAt(pos) || 0), code < 45 || code > 127) ? code
36
+ : code < 46 ? 65 // -
37
+ : code < 48 ? code - 1
38
+ : code < 58 ? code + 18 // 0-9
39
+ : code < 65 ? code - 11
40
+ : code < 91 ? code + 11 // A-Z
41
+ : code < 97 ? code - 37
42
+ : code < 123 ? code + 5 // a-z
43
+ : code - 63
44
+ }
45
+
46
+
47
+ if ((a+="") != (b+="")) for (;codeB;) {
48
+ codeA = getCode(a, posA++);
49
+ codeB = getCode(b, posB++);
50
+
51
+ if (codeA < 76 && codeB < 76 && codeA > 66 && codeB > 66) {
52
+ codeA = getCode(a, posA, posA);
53
+ codeB = getCode(b, posB, posA = i);
54
+ posB = i;
55
+ }
56
+
57
+ if (codeA != codeB) return (codeA < codeB) ? -1 : 1
58
+ }
59
+ return 0
60
+ };
61
+
62
+ try {
63
+ naturalCompare$1.exports = naturalCompare;
64
+ } catch (e) {
65
+ String.naturalCompare = naturalCompare;
66
+ }
67
+ return naturalCompare$1.exports;
68
+ }
69
+
70
+ var naturalCompareExports = requireNaturalCompare();
71
+ var naturalCompare = /*@__PURE__*/getDefaultExportFromCjs(naturalCompareExports);
72
+
73
+ // TODO: rewrite and clean up
74
+ function testNameToKey(testName, count) {
75
+ return `${testName} ${count}`;
76
+ }
77
+ function keyToTestName(key) {
78
+ if (!/ \d+$/.test(key)) throw new Error("Snapshot keys must end with a number.");
79
+ return key.replace(/ \d+$/, "");
80
+ }
81
+ // Evaluate a snapshot file's content into its snapshot key/value pairs.
82
+ function evaluateSnapshotFile(filepath, content) {
83
+ const data = Object.create(null);
84
+ try {
85
+ new Function("exports", content)(data);
86
+ } catch (cause) {
87
+ throw new Error(`Invalid snapshot file, please manually fix or delete it: ${filepath}`, { cause });
88
+ }
89
+ return data;
90
+ }
91
+ // Add extra line breaks at beginning and end of multiline snapshot
92
+ // to make the content easier to read.
93
+ function addExtraLineBreaks(string) {
94
+ return string.includes("\n") ? `\n${string}\n` : string;
95
+ }
96
+ // Remove extra line breaks at beginning and end of multiline snapshot.
97
+ // Instead of trim, which can remove additional newlines or spaces
98
+ // at beginning or end of the content from a custom serializer.
99
+ function removeExtraLineBreaks(string) {
100
+ return string.length > 2 && string[0] === "\n" && string.endsWith("\n") ? string.slice(1, -1) : string;
101
+ }
102
+ // export const removeLinesBeforeExternalMatcherTrap = (stack: string): string => {
103
+ // const lines = stack.split('\n')
104
+ // for (let i = 0; i < lines.length; i += 1) {
105
+ // // It's a function name specified in `packages/expect/src/index.ts`
106
+ // // for external custom matchers.
107
+ // if (lines[i].includes('__EXTERNAL_MATCHER_TRAP__'))
108
+ // return lines.slice(i + 1).join('\n')
109
+ // }
110
+ // return stack
111
+ // }
112
+ const escapeRegex = true;
113
+ const printFunctionName = false;
114
+ function serialize(val, indent = 2, formatOverrides = {}) {
115
+ return normalizeNewlines(format(val, {
116
+ escapeRegex,
117
+ indent,
118
+ plugins: getSerializers(),
119
+ printFunctionName,
120
+ ...formatOverrides
121
+ }));
122
+ }
123
+ function escapeBacktickString(str) {
124
+ // a raw CR inside a template literal is read back as LF
125
+ return str.replace(/`|\\|\$\{/g, "\\$&").replace(/\r/g, "\\r");
126
+ }
127
+ function printBacktickString(str) {
128
+ return `\`${escapeBacktickString(str)}\``;
129
+ }
130
+ function normalizeNewlines(string) {
131
+ return string.replace(/\r\n|\r/g, "\n");
132
+ }
133
+ async function saveSnapshotFile(environment, snapshotData, snapshotPath) {
134
+ const snapshots = Object.keys(snapshotData).sort(naturalCompare).map((key) => `exports[${printBacktickString(key)}] = ${printBacktickString(normalizeNewlines(snapshotData[key]))};`);
135
+ const content = `${environment.getHeader()}\n\n${snapshots.join("\n\n")}\n`;
136
+ const oldContent = await environment.readSnapshotFile(snapshotPath);
137
+ if (oldContent != null && oldContent === content) return;
138
+ await environment.saveSnapshotFile(snapshotPath, content);
139
+ }
140
+ function deepMergeArray(target = [], source = []) {
141
+ const mergedOutput = Array.from(target);
142
+ source.forEach((sourceElement, index) => {
143
+ const targetElement = mergedOutput[index];
144
+ if (Array.isArray(target[index])) mergedOutput[index] = deepMergeArray(target[index], sourceElement);
145
+ else if (isObject(targetElement)) mergedOutput[index] = deepMergeSnapshot(target[index], sourceElement);
146
+ else
147
+ // Source does not exist in target or target is primitive and cannot be deep merged
148
+ mergedOutput[index] = sourceElement;
149
+ });
150
+ return mergedOutput;
151
+ }
152
+ /**
153
+ * Deep merge, but considers asymmetric matchers. Unlike base util's deep merge,
154
+ * will merge any object-like instance.
155
+ * Compatible with Jest's snapshot matcher. Should not be used outside of snapshot.
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * toMatchSnapshot({
160
+ * name: expect.stringContaining('text')
161
+ * })
162
+ * ```
163
+ */
164
+ function deepMergeSnapshot(target, source) {
165
+ if (isObject(target) && isObject(source)) {
166
+ const mergedOutput = { ...target };
167
+ Object.keys(source).forEach((key) => {
168
+ if (isObject(source[key]) && !source[key].$$typeof) {
169
+ if (!(key in target)) Object.assign(mergedOutput, { [key]: source[key] });
170
+ else mergedOutput[key] = deepMergeSnapshot(target[key], source[key]);
171
+ } else if (Array.isArray(source[key])) mergedOutput[key] = deepMergeArray(target[key], source[key]);
172
+ else Object.assign(mergedOutput, { [key]: source[key] });
173
+ });
174
+ return mergedOutput;
175
+ } else if (Array.isArray(target) && Array.isArray(source)) return deepMergeArray(target, source);
176
+ return target;
177
+ }
178
+ class DefaultMap extends Map {
179
+ defaultFn;
180
+ constructor(defaultFn, entries) {
181
+ super(entries);
182
+ this.defaultFn = defaultFn;
183
+ }
184
+ get(key) {
185
+ if (!this.has(key)) this.set(key, this.defaultFn(key));
186
+ return super.get(key);
187
+ }
188
+ }
189
+ class CounterMap extends DefaultMap {
190
+ constructor() {
191
+ super(() => 0);
192
+ }
193
+ // compat for jest-image-snapshot https://github.com/vitest-dev/vitest/issues/7322
194
+ // `valueOf` and `Snapshot.added` setter allows
195
+ // snapshotState.added = snapshotState.added + 1
196
+ // to function as
197
+ // snapshotState.added.total_ = snapshotState.added.total() + 1
198
+ _total;
199
+ valueOf() {
200
+ return this._total = this.total();
201
+ }
202
+ increment(key) {
203
+ if (typeof this._total !== "undefined") this._total++;
204
+ this.set(key, this.get(key) + 1);
205
+ }
206
+ total() {
207
+ if (typeof this._total !== "undefined") return this._total;
208
+ let total = 0;
209
+ for (const x of this.values()) total += x;
210
+ return total;
211
+ }
212
+ }
213
+ /* @__NO_SIDE_EFFECTS__ */
214
+ function memo(fn) {
215
+ const cache = /* @__PURE__ */ new Map();
216
+ return (arg) => {
217
+ if (!cache.has(arg)) cache.set(arg, fn(arg));
218
+ return cache.get(arg);
219
+ };
220
+ }
221
+
222
+ async function saveInlineSnapshots(environment, snapshots) {
223
+ const MagicString = (await import('magic-string')).default;
224
+ const files = new Set(snapshots.map((i) => i.file));
225
+ await Promise.all(Array.from(files).map(async (file) => {
226
+ const snaps = snapshots.filter((i) => i.file === file);
227
+ const code = await environment.readSnapshotFile(file);
228
+ if (code == null) throw new Error(`cannot read ${file} when saving inline snapshot`);
229
+ const s = new MagicString(code);
230
+ for (const snap of snaps) replaceInlineSnap(code, s, positionToOffset(code, snap.line, snap.column), snap.snapshot, snap.assertionName);
231
+ const transformed = s.toString();
232
+ if (transformed !== code) await environment.saveSnapshotFile(file, transformed);
233
+ }));
234
+ }
235
+ const defaultStartObjectRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\s\S]*\*\/\s*|\/\/.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))*\{/;
236
+ function escapeRegExp(s) {
237
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
238
+ }
239
+ const buildStartObjectRegex = memo((assertionName) => {
240
+ const replaced = defaultStartObjectRegex.source.replace("toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot", escapeRegExp(assertionName));
241
+ return new RegExp(replaced);
242
+ });
243
+ function replaceObjectSnap(code, s, index, newSnap, assertionName) {
244
+ let _code = code.slice(index);
245
+ const startMatch = (assertionName ? buildStartObjectRegex(assertionName) : defaultStartObjectRegex).exec(_code);
246
+ if (!startMatch) return false;
247
+ _code = _code.slice(startMatch.index);
248
+ let callEnd = getCallLastIndex(_code);
249
+ if (callEnd === null) return false;
250
+ callEnd += index + startMatch.index;
251
+ const shapeEnd = getObjectShapeEndIndex(code, index + startMatch.index + startMatch[0].length);
252
+ const snap = `, ${prepareSnapString(newSnap, code, index)}`;
253
+ if (shapeEnd === callEnd)
254
+ // toMatchInlineSnapshot({ foo: expect.any(String) })
255
+ s.appendLeft(callEnd, snap);
256
+ else
257
+ // toMatchInlineSnapshot({ foo: expect.any(String) }, ``)
258
+ s.overwrite(shapeEnd, callEnd, snap);
259
+ return true;
260
+ }
261
+ function getObjectShapeEndIndex(code, index) {
262
+ let startBraces = 1;
263
+ let endBraces = 0;
264
+ while (startBraces !== endBraces && index < code.length) {
265
+ const s = code[index++];
266
+ if (s === "{") startBraces++;
267
+ else if (s === "}") endBraces++;
268
+ }
269
+ return index;
270
+ }
271
+ function prepareSnapString(snap, source, index) {
272
+ const lineNumber = offsetToLineNumber(source, index);
273
+ const indent = source.split(lineSplitRE)[lineNumber - 1].match(/^\s*/)[0] || "";
274
+ const indentNext = indent.includes(" ") ? `${indent}\t` : `${indent} `;
275
+ const lines = snap.trim().replace(/\\/g, "\\\\").split(/\n/g);
276
+ const isOneline = lines.length <= 1;
277
+ const quote = "`";
278
+ if (isOneline) return `${quote}${lines.join("\n").replace(/`/g, "\\`").replace(/\$\{/g, "\\${")}${quote}`;
279
+ return `${quote}\n${lines.map((i) => i ? indentNext + i : "").join("\n").replace(/`/g, "\\`").replace(/\$\{/g, "\\${")}\n${indent}${quote}`;
280
+ }
281
+ const defaultMethodNames = ["toMatchInlineSnapshot", "toThrowErrorMatchingInlineSnapshot"];
282
+ // on webkit, the line number is at the end of the method, not at the start
283
+ function getCodeStartingAtIndex(code, index, methodNames) {
284
+ for (const name of methodNames) {
285
+ const adjusted = index - name.length;
286
+ if (adjusted >= 0 && code.slice(adjusted, index) === name) return {
287
+ code: code.slice(adjusted),
288
+ index: adjusted
289
+ };
290
+ }
291
+ return {
292
+ code: code.slice(index),
293
+ index
294
+ };
295
+ }
296
+ const defaultStartRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\s\S]*\*\/\s*|\/\/.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))*[\w$]*(['"`)])/;
297
+ const buildStartRegex = memo((assertionName) => {
298
+ const replaced = defaultStartRegex.source.replace("toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot", escapeRegExp(assertionName));
299
+ return new RegExp(replaced);
300
+ });
301
+ function replaceInlineSnap(code, s, currentIndex, newSnap, assertionName) {
302
+ const { code: codeStartingAtIndex, index } = getCodeStartingAtIndex(code, currentIndex, assertionName ? [assertionName] : defaultMethodNames);
303
+ const startMatch = (assertionName ? buildStartRegex(assertionName) : defaultStartRegex).exec(codeStartingAtIndex);
304
+ const firstKeywordMatch = (assertionName ? new RegExp(escapeRegExp(assertionName)) : /toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot/).exec(codeStartingAtIndex);
305
+ if (!startMatch || startMatch.index !== firstKeywordMatch?.index) return replaceObjectSnap(code, s, index, newSnap, assertionName);
306
+ const quote = startMatch[1];
307
+ const startIndex = index + startMatch.index + startMatch[0].length;
308
+ const snapString = prepareSnapString(newSnap, code, index);
309
+ if (quote === ")") {
310
+ s.appendRight(startIndex - 1, snapString);
311
+ return true;
312
+ }
313
+ const endMatch = new RegExp(`(?:^|[^\\\\])${quote}`).exec(code.slice(startIndex));
314
+ if (!endMatch) return false;
315
+ const endIndex = startIndex + endMatch.index + endMatch[0].length;
316
+ s.overwrite(startIndex - 1, endIndex, snapString);
317
+ return true;
318
+ }
319
+ const INDENTATION_REGEX = /^([^\S\n]*)\S/m;
320
+ function stripSnapshotIndentation(inlineSnapshot) {
321
+ // Find indentation if exists.
322
+ const match = inlineSnapshot.match(INDENTATION_REGEX);
323
+ if (!match || !match[1])
324
+ // No indentation.
325
+ return inlineSnapshot;
326
+ const indentation = match[1];
327
+ const lines = inlineSnapshot.split(/\n/g);
328
+ if (lines.length <= 2)
329
+ // Must be at least 3 lines.
330
+ return inlineSnapshot;
331
+ if (lines[0].trim() !== "" || lines.at(-1)?.trim() !== "")
332
+ // If not blank first and last lines, abort.
333
+ return inlineSnapshot;
334
+ for (let i = 1; i < lines.length - 1; i++) if (lines[i] !== "") {
335
+ if (lines[i].indexOf(indentation) !== 0)
336
+ // All lines except first and last should either be blank or have the same
337
+ // indent as the first line (or more). If this isn't the case we don't
338
+ // want to touch the snapshot at all.
339
+ return inlineSnapshot;
340
+ lines[i] = lines[i].substring(indentation.length);
341
+ }
342
+ // Last line is a special case because it won't have the same indent as others
343
+ // but may still have been given some indent to line up.
344
+ lines[lines.length - 1] = "";
345
+ // Return inline snapshot, now at indent 0.
346
+ inlineSnapshot = lines.join("\n");
347
+ return inlineSnapshot;
348
+ }
349
+
350
+ async function saveRawSnapshots(environment, snapshots) {
351
+ await Promise.all(snapshots.map(async (snap) => {
352
+ if (!snap.readonly) await environment.saveSnapshotFile(snap.file, snap.snapshot);
353
+ }));
354
+ }
355
+
356
+ export { CounterMap as C, DefaultMap as D, saveInlineSnapshots as a, saveRawSnapshots as b, serialize as c, addExtraLineBreaks as d, evaluateSnapshotFile as e, deepMergeSnapshot as f, stripSnapshotIndentation as g, keyToTestName as k, normalizeNewlines as n, removeExtraLineBreaks as r, saveSnapshotFile as s, testNameToKey as t };
@@ -1,5 +1,5 @@
1
1
  import fs__default from 'node:fs';
2
- import { b as basename, j as join, d as dirname } from './pathe.M-eThtNZ.Ba-7h1rE.js';
2
+ import { b as basename, j as join, d as dirname } from './pathe.M-eThtNZ.zq3TM4NT.js';
3
3
 
4
4
  const packageScopeTypeCache = /* @__PURE__ */ new Map();
5
5
  // mirrors LOOKUP_PACKAGE_SCOPE from the ESM resolution algorithm:
@@ -1,6 +1,6 @@
1
1
  import { EvaluatedModules } from 'vite/module-runner';
2
- import { d as dirname, r as resolve } from './pathe.M-eThtNZ.Ba-7h1rE.js';
3
- import { a as getSafeTimers } from './source-map.DdKI5IHB.js';
2
+ import { d as dirname, r as resolve } from './pathe.M-eThtNZ.zq3TM4NT.js';
3
+ import { a as getSafeTimers } from './source-map.DakdQc29.js';
4
4
  import { c as createBirpc } from './index.DmDMHCg8.js';
5
5
  import { g as getWorkerState } from './utils.DYj33du9.js';
6
6
 
@@ -1,4 +1,4 @@
1
- import { bt as FetchCachedFileSystemResult, bu as ResolveFunctionResult, U as UserConsoleLog, bl as AsyncLeak, a as File, a2 as AfterSuiteRunMeta, b0 as TestBenchmark, h as TestArtifact, j as TaskResultPack, k as TaskEventPack, Y as CancelReason, aM as SnapshotResult, a5 as BaselineData } from './config.d.QBNYCgFU.js';
1
+ import { bw as FetchCachedFileSystemResult, bx as ResolveFunctionResult, U as UserConsoleLog, bo as AsyncLeak, a as File, a3 as AfterSuiteRunMeta, b2 as TestBenchmark, j as TestArtifact, k as TaskResultPack, l as TaskEventPack, Z as CancelReason, aO as SnapshotResult, a6 as BaselineData } from './config.d.B3YV4t0O.js';
2
2
  import { FetchFunctionOptions, FetchResult } from 'vite/module-runner';
3
3
 
4
4
  interface OTELCarrier {
@@ -1,8 +1,8 @@
1
1
  import { f as format, p as plugins } from './index.D0heQG4v.js';
2
2
  import { $ } from './tinyrainbow.Do8I1XRG.js';
3
3
  import { s as stringify, f as format$1, a as formatRegExp, t as truncateString, i as inspect } from './display.BlTmubjj.js';
4
- import { p as deepClone, q as getOwnProperties, g as getType$1, u as isObject, v as filterOutComments, w as ordinal, e as createDefer, x as assertTypes, t as toArray, y as isNegativeNaN, z as unique, A as objectAttr } from './pathe.M-eThtNZ.Ba-7h1rE.js';
5
- import { d as diffSequences, b as serializeValue, p as parseStacktrace, a as getSafeTimers } from './source-map.DdKI5IHB.js';
4
+ import { u as deepClone, v as getOwnProperties, g as getType$1, f as isObject, w as filterOutComments, x as ordinal, e as createDefer, y as assertTypes, t as toArray, z as isNegativeNaN, A as unique, B as objectAttr } from './pathe.M-eThtNZ.zq3TM4NT.js';
5
+ import { d as diffSequences, b as serializeValue, p as parseStacktrace, a as getSafeTimers } from './source-map.DakdQc29.js';
6
6
  import { createTaskName, createFileTask, calculateSuiteHash, interpretTaskModes, hasFailed } from '../task-utils.js';
7
7
 
8
8
  const RealDate = Date;
@@ -3443,6 +3443,7 @@ async function collectTests(specs, runner) {
3443
3443
  const testLocations = typeof spec === "string" ? void 0 : spec.testLocations;
3444
3444
  const testNamePattern = typeof spec === "string" ? void 0 : spec.testNamePattern;
3445
3445
  const testIds = typeof spec === "string" ? void 0 : spec.testIds;
3446
+ const testNames = typeof spec === "string" ? void 0 : spec.testNames;
3446
3447
  const testTagsFilter = typeof spec === "object" && spec.testTagsFilter ? createTagsFilter(spec.testTagsFilter, config.tags) : void 0;
3447
3448
  const fileTags = typeof spec === "string" ? [] : spec.fileTags || [];
3448
3449
  const file = createFileTask(filepath, config.root, config.name, runner.pool, runner.viteEnvironment, { __vitest_label__: config.mergeReportsLabel });
@@ -3495,7 +3496,7 @@ async function collectTests(specs, runner) {
3495
3496
  file.containsTest = file.tasks.some((t) => t.type === "test" || t.type === "suite" && t.containsTest);
3496
3497
  const hasOnlyTasks = file.containsOnly;
3497
3498
  if (!testTagsFilter && !defaultTagsFilter && config.tagsFilter) defaultTagsFilter = createTagsFilter(config.tagsFilter, config.tags);
3498
- interpretTaskModes(file, testNamePattern ?? config.testNamePattern, testLocations, testIds, testTagsFilter ?? defaultTagsFilter, hasOnlyTasks, false, config.allowOnly);
3499
+ interpretTaskModes(file, testNamePattern ?? config.testNamePattern, testLocations, testIds, testNames, testTagsFilter ?? defaultTagsFilter, hasOnlyTasks, false, config.allowOnly);
3499
3500
  if (file.mode === "queued") file.mode = "run";
3500
3501
  files.push(file);
3501
3502
  });
@@ -3813,7 +3814,10 @@ function throttle(fn, ms) {
3813
3814
  return fn.apply(this, args);
3814
3815
  }
3815
3816
  // Make sure fn is still called even if there are no further calls
3816
- pendingCall ??= setTimeout(call.bind(this), ms, ...args);
3817
+ pendingCall ??= setTimeout(() => {
3818
+ pendingCall = void 0;
3819
+ call.apply(this, args);
3820
+ }, ms);
3817
3821
  };
3818
3822
  }
3819
3823
  // throttle based on summary reporter's DURATION_UPDATE_INTERVAL_MS
@@ -3869,7 +3873,8 @@ async function runTest(test, runner) {
3869
3873
  test.result = {
3870
3874
  state: "run",
3871
3875
  startTime: unixNow(),
3872
- retryCount: 0
3876
+ retryCount: 0,
3877
+ attempts: []
3873
3878
  };
3874
3879
  updateTask("test-prepare", test, runner);
3875
3880
  const cleanupRunningTest = addRunningTest(test);
@@ -3883,7 +3888,20 @@ async function runTest(test, runner) {
3883
3888
  test.result.state = "run";
3884
3889
  const retry = getRetryCount(test.retry);
3885
3890
  for (let retryCount = 0; retryCount <= retry; retryCount++) {
3891
+ const attemptStart = now();
3892
+ const attemptStartTime = unixNow();
3886
3893
  const attemptErrorsStart = test.result.errors?.length ?? 0;
3894
+ const recordAttempt = (state) => {
3895
+ const errors = test.result.errors?.slice(attemptErrorsStart);
3896
+ test.result.attempts.push({
3897
+ state,
3898
+ errors: errors?.length ? errors : void 0,
3899
+ duration: now() - attemptStart,
3900
+ startTime: attemptStartTime,
3901
+ retryIndex: retryCount,
3902
+ repeatIndex: repeatCount
3903
+ });
3904
+ };
3887
3905
  const beforeEachCleanups = [];
3888
3906
  // fixtureCheckpoint is passed by callAroundEachHooks - it represents the count
3889
3907
  // of fixture cleanup functions AFTER all aroundEach fixtures have been resolved
@@ -3945,12 +3963,14 @@ async function runTest(test, runner) {
3945
3963
  }
3946
3964
  // skipped with new PendingError
3947
3965
  if (test.result?.pending || test.result?.state === "skip") {
3966
+ recordAttempt("skip");
3948
3967
  test.mode = "skip";
3949
3968
  test.result = {
3950
3969
  state: "skip",
3951
3970
  note: test.result?.note,
3952
3971
  pending: true,
3953
- duration: now() - start
3972
+ duration: now() - start,
3973
+ attempts: test.result.attempts
3954
3974
  };
3955
3975
  updateTask("test-finished", test, runner);
3956
3976
  setCurrentTest(void 0);
@@ -3970,6 +3990,7 @@ async function runTest(test, runner) {
3970
3990
  if (!test.result.errors?.length) test.result.errors = void 0;
3971
3991
  }
3972
3992
  }
3993
+ recordAttempt(test.result.state === "pass" ? "pass" : "fail");
3973
3994
  if (test.result.state === "pass") break;
3974
3995
  if (retryCount < retry) {
3975
3996
  if (!passesRetryCondition(test, test.result.errors)) break;
@@ -4207,4 +4228,4 @@ async function publicCollect(specs, runner) {
4207
4228
  return files;
4208
4229
  }
4209
4230
 
4210
- export { createTagsFilter as A, validateTags as B, shuffle as C, TestSyntaxError as T, processError as a, printDiffOrStringify as b, createTaskCollector as c, diff as d, getCurrentSuite as e, createChainable as f, getCurrentTest as g, getHooks as h, getFn as i, afterAll as j, afterEach as k, aroundAll as l, matchesTags as m, aroundEach as n, beforeAll as o, publicCollect as p, beforeEach as q, describe as r, startTests as s, it as t, onTestFailed as u, onTestFinished as v, recordArtifact as w, suite as x, test as y, limitConcurrency as z };
4231
+ export { limitConcurrency as A, createTagsFilter as B, validateTags as C, shuffle as D, TestSyntaxError as T, processError as a, printDiffOrStringify as b, getCurrentTest as c, diff as d, createTaskCollector as e, getCurrentSuite as f, getRunningTests as g, createChainable as h, getHooks as i, getFn as j, afterAll as k, afterEach as l, matchesTags as m, aroundAll as n, aroundEach as o, publicCollect as p, beforeAll as q, recordArtifact as r, startTests as s, beforeEach as t, describe as u, it as v, onTestFailed as w, onTestFinished as x, suite as y, test as z };
@@ -1,4 +1,4 @@
1
- import { s as setSafeTimers } from './source-map.DdKI5IHB.js';
1
+ import { s as setSafeTimers } from './source-map.DakdQc29.js';
2
2
  import { a as addSerializer } from './plugins.DPQHVT0p.js';
3
3
 
4
4
  let globalSetup = false;
@@ -7,7 +7,7 @@ async function setupCommonEnv(config) {
7
7
  if (globalSetup) return;
8
8
  globalSetup = true;
9
9
  setSafeTimers();
10
- if (config.globals) (await import('./globals.CXEE6_2C.js')).registerApiGlobally();
10
+ if (config.globals) (await import('./globals.ZKtKSkEf.js')).registerApiGlobally();
11
11
  }
12
12
  function setupDefines(config) {
13
13
  for (const key in config.defines) globalThis[key] = config.defines[key];
@@ -1,5 +1,5 @@
1
1
  import { g as getDefaultExportFromCjs } from './index.D0heQG4v.js';
2
- import { m as isPrimitive, o as notNullish, r as resolve$1 } from './pathe.M-eThtNZ.Ba-7h1rE.js';
2
+ import { p as isPrimitive, q as notNullish, r as resolve$1 } from './pathe.M-eThtNZ.zq3TM4NT.js';
3
3
 
4
4
  var build = {};
5
5
 
@@ -947,7 +947,7 @@ for (let i = 0; i < chars.length; i++) {
947
947
  intToChar[i] = c;
948
948
  charToInt[c] = i;
949
949
  }
950
- function decodeInteger(reader, relative) {
950
+ function decodeInteger(reader) {
951
951
  let value = 0;
952
952
  let shift = 0;
953
953
  let integer = 0;
@@ -957,12 +957,10 @@ function decodeInteger(reader, relative) {
957
957
  value |= (integer & 31) << shift;
958
958
  shift += 5;
959
959
  } while (integer & 32);
960
- const shouldNegate = value & 1;
961
- value >>>= 1;
962
- if (shouldNegate) {
963
- value = -2147483648 | -value;
964
- }
965
- return relative + value;
960
+ return value;
961
+ }
962
+ function decodeSign(num) {
963
+ return num & 1 ? -2147483648 | -(num >>> 1) : num >>> 1;
966
964
  }
967
965
  function hasMoreVlq(reader, max) {
968
966
  if (reader.pos >= max) return false;
@@ -1004,15 +1002,15 @@ function decode(mappings) {
1004
1002
  genColumn = 0;
1005
1003
  while (reader.pos < semi) {
1006
1004
  let seg;
1007
- genColumn = decodeInteger(reader, genColumn);
1005
+ genColumn += decodeSign(decodeInteger(reader));
1008
1006
  if (genColumn < lastCol) sorted = false;
1009
1007
  lastCol = genColumn;
1010
1008
  if (hasMoreVlq(reader, semi)) {
1011
- sourcesIndex = decodeInteger(reader, sourcesIndex);
1012
- sourceLine = decodeInteger(reader, sourceLine);
1013
- sourceColumn = decodeInteger(reader, sourceColumn);
1009
+ sourcesIndex += decodeSign(decodeInteger(reader));
1010
+ sourceLine += decodeSign(decodeInteger(reader));
1011
+ sourceColumn += decodeSign(decodeInteger(reader));
1014
1012
  if (hasMoreVlq(reader, semi)) {
1015
- namesIndex = decodeInteger(reader, namesIndex);
1013
+ namesIndex += decodeSign(decodeInteger(reader));
1016
1014
  seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
1017
1015
  } else {
1018
1016
  seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
@@ -1696,30 +1694,38 @@ function parseStacktrace(stack, options = {}) {
1696
1694
  // remove vi.defineHelper's internal stacks
1697
1695
  const helperIndex = stacks.findLastIndex((s) => s.method.includes("__VITEST_HELPER__"));
1698
1696
  if (helperIndex >= 0) stacks = stacks.slice(helperIndex + 1);
1699
- return stacks.map((stack) => {
1700
- if (options.getUrlId) stack.file = options.getUrlId(stack.file);
1701
- const map = options.getSourceMap?.(stack.file);
1702
- if (!map || typeof map !== "object" || !map.version) return shouldFilter(ignoreStackEntries, stack.file) ? null : stack;
1703
- const traceMap = new DecodedMap(map, stack.file);
1704
- if (stack.line <= 0 || stack.column <= 0) return stack;
1705
- const position = getOriginalPosition(traceMap, {
1706
- line: stack.line,
1707
- // stacktrace's column is 1-indexed, but sourcemap's one is 0-indexed
1708
- column: stack.column - 1
1709
- });
1710
- if (!position) return stack;
1711
- const { line, column, source, name } = position;
1712
- let file = source || stack.file;
1713
- if (/\/\w:\//.test(file)) file = file.slice(1);
1714
- if (shouldFilter(ignoreStackEntries, file)) return null;
1715
- if (line != null && column != null) return {
1716
- line,
1717
- column: column + 1,
1718
- file,
1719
- method: name || stack.method
1720
- };
1721
- return stack;
1722
- }).filter((s) => s != null);
1697
+ if (options.firstOnly) {
1698
+ for (const stack of stacks) {
1699
+ const mapped = mapStackFrame(stack, options, ignoreStackEntries);
1700
+ if (mapped) return [mapped];
1701
+ }
1702
+ return [];
1703
+ }
1704
+ return stacks.map((stack) => mapStackFrame(stack, options, ignoreStackEntries)).filter((s) => s != null);
1705
+ }
1706
+ function mapStackFrame(stack, options, ignoreStackEntries) {
1707
+ if (options.getUrlId) stack.file = options.getUrlId(stack.file);
1708
+ const map = options.getSourceMap?.(stack.file);
1709
+ if (!map || typeof map !== "object" || !map.version) return shouldFilter(ignoreStackEntries, stack.file) ? null : stack;
1710
+ const traceMap = new DecodedMap(map, stack.file);
1711
+ if (stack.line <= 0 || stack.column <= 0) return stack;
1712
+ const position = getOriginalPosition(traceMap, {
1713
+ line: stack.line,
1714
+ // stacktrace's column is 1-indexed, but sourcemap's one is 0-indexed
1715
+ column: stack.column - 1
1716
+ });
1717
+ if (!position) return stack;
1718
+ const { line, column, source, name } = position;
1719
+ let file = source || stack.file;
1720
+ if (/\/\w:\//.test(file)) file = file.slice(1);
1721
+ if (shouldFilter(ignoreStackEntries, file)) return null;
1722
+ if (line != null && column != null) return {
1723
+ line,
1724
+ column: column + 1,
1725
+ file,
1726
+ method: name || stack.method
1727
+ };
1728
+ return stack;
1723
1729
  }
1724
1730
  function shouldFilter(ignoreStackEntries, file) {
1725
1731
  return ignoreStackEntries.some((p) => file.match(p));
@@ -1,4 +1,4 @@
1
- import { T as TestError, P as ParsedStack } from './config.d.QBNYCgFU.js';
1
+ import { T as TestError, P as ParsedStack } from './config.d.B3YV4t0O.js';
2
2
 
3
3
  interface RuntimeCoverageModuleLoader {
4
4
  import: (id: string) => Promise<{
@@ -53,6 +53,7 @@ interface StackTraceParserOptions {
53
53
  getSourceMap?: (file: string) => unknown;
54
54
  getUrlId?: (id: string) => string;
55
55
  frameFilter?: (error: TestError, frame: ParsedStack) => boolean | void;
56
+ firstOnly?: boolean;
56
57
  }
57
58
  interface SourceMapLike {
58
59
  version: number;
@@ -1,4 +1,5 @@
1
- import { bn as SnapshotState, m as Test, bo as PromisifyAssertion, bp as Tester, bq as Plugin, ad as BenchResult, a as File } from './config.d.QBNYCgFU.js';
1
+ /// <reference types="chai" />
2
+ import { bq as SnapshotState, n as Test, br as PromisifyAssertion, bs as Tester, bt as Plugin, ae as BenchResult, a as File } from './config.d.B3YV4t0O.js';
2
3
 
3
4
  interface SnapshotMatcher<
4
5
  R extends void | Promise<void>,