@vitest/browser 5.0.0-beta.1 → 5.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/context.d.ts +40 -1
  2. package/dist/client/.vite/manifest.json +8 -8
  3. package/dist/client/__vitest__/assets/index-BlLo6Q_D.css +1 -0
  4. package/dist/client/__vitest__/assets/index-O8gheoYf.js +89 -0
  5. package/dist/client/__vitest__/index.html +2 -2
  6. package/dist/client/__vitest_browser__/defineProperty-C3k2g8Sk.js +267 -0
  7. package/dist/client/__vitest_browser__/orchestrator-B44yH1M4.js +343 -0
  8. package/dist/client/__vitest_browser__/rrweb-snapshot-iZCFA2to.js +4388 -0
  9. package/dist/client/__vitest_browser__/tester-Byk-s_d6.js +5088 -0
  10. package/dist/client/orchestrator.html +2 -2
  11. package/dist/client/tester/locators.d.ts +69 -0
  12. package/dist/client/tester/tester.html +2 -2
  13. package/dist/client/tester/trace.d.ts +11 -7
  14. package/dist/client.js +10 -1
  15. package/dist/context.js +73 -44
  16. package/dist/expect-element.js +30 -30
  17. package/dist/index.d.ts +6 -22
  18. package/dist/index.js +99 -4573
  19. package/dist/locators-DUkyvRhY.js +5 -0
  20. package/dist/locators.d.ts +9 -1
  21. package/dist/locators.js +1 -1
  22. package/dist/shared/screenshotMatcher/types.d.ts +4 -3
  23. package/dist/state.js +64 -14
  24. package/dist/types.d.ts +2 -0
  25. package/jest-dom.d.ts +1 -0
  26. package/matchers.d.ts +2 -1
  27. package/package.json +10 -7
  28. package/dist/client/__vitest__/assets/index-BmuVn2L3.js +0 -136
  29. package/dist/client/__vitest__/assets/index-CxYquQyv.css +0 -1
  30. package/dist/client/__vitest__/bg.png +0 -0
  31. package/dist/client/__vitest_browser__/orchestrator-pTEf6o0n.js +0 -383
  32. package/dist/client/__vitest_browser__/rrweb-snapshot-xhvrgOHx.js +0 -5476
  33. package/dist/client/__vitest_browser__/tester-CIKiUsoz.js +0 -2431
  34. package/dist/client/__vitest_browser__/utils-BYUpz6v6.js +0 -3379
  35. package/dist/index-BlWsE3ij.js +0 -5
@@ -1,3379 +0,0 @@
1
- (function polyfill() {
2
- const relList = document.createElement("link").relList;
3
- if (relList && relList.supports && relList.supports("modulepreload")) return;
4
- for (const link of document.querySelectorAll('link[rel="modulepreload"]')) processPreload(link);
5
- new MutationObserver((mutations) => {
6
- for (const mutation of mutations) {
7
- if (mutation.type !== "childList") continue;
8
- for (const node of mutation.addedNodes) if (node.tagName === "LINK" && node.rel === "modulepreload") processPreload(node);
9
- }
10
- }).observe(document, {
11
- childList: true,
12
- subtree: true
13
- });
14
- function getFetchOpts(link) {
15
- const fetchOpts = {};
16
- if (link.integrity) fetchOpts.integrity = link.integrity;
17
- if (link.referrerPolicy) fetchOpts.referrerPolicy = link.referrerPolicy;
18
- if (link.crossOrigin === "use-credentials") fetchOpts.credentials = "include";
19
- else if (link.crossOrigin === "anonymous") fetchOpts.credentials = "omit";
20
- else fetchOpts.credentials = "same-origin";
21
- return fetchOpts;
22
- }
23
- function processPreload(link) {
24
- if (link.ep) return;
25
- link.ep = true;
26
- const fetchOpts = getFetchOpts(link);
27
- fetch(link.href, fetchOpts);
28
- }
29
- })();
30
- var b = {
31
- reset: [0, 0],
32
- bold: [1, 22, "\x1B[22m\x1B[1m"],
33
- dim: [2, 22, "\x1B[22m\x1B[2m"],
34
- italic: [3, 23],
35
- underline: [4, 24],
36
- inverse: [7, 27],
37
- hidden: [8, 28],
38
- strikethrough: [9, 29],
39
- black: [30, 39],
40
- red: [31, 39],
41
- green: [32, 39],
42
- yellow: [33, 39],
43
- blue: [34, 39],
44
- magenta: [35, 39],
45
- cyan: [36, 39],
46
- white: [37, 39],
47
- gray: [90, 39],
48
- bgBlack: [40, 49],
49
- bgRed: [41, 49],
50
- bgGreen: [42, 49],
51
- bgYellow: [43, 49],
52
- bgBlue: [44, 49],
53
- bgMagenta: [45, 49],
54
- bgCyan: [46, 49],
55
- bgWhite: [47, 49],
56
- blackBright: [90, 39],
57
- redBright: [91, 39],
58
- greenBright: [92, 39],
59
- yellowBright: [93, 39],
60
- blueBright: [94, 39],
61
- magentaBright: [95, 39],
62
- cyanBright: [96, 39],
63
- whiteBright: [97, 39],
64
- bgBlackBright: [100, 49],
65
- bgRedBright: [101, 49],
66
- bgGreenBright: [102, 49],
67
- bgYellowBright: [103, 49],
68
- bgBlueBright: [104, 49],
69
- bgMagentaBright: [105, 49],
70
- bgCyanBright: [106, 49],
71
- bgWhiteBright: [107, 49]
72
- };
73
- function i(e) {
74
- return String(e);
75
- }
76
- i.open = "";
77
- i.close = "";
78
- function B() {
79
- let e = typeof process != "undefined" ? process : void 0, r = (e == null ? void 0 : e.env) || {}, a = r.FORCE_TTY !== "false", l = (e == null ? void 0 : e.argv) || [];
80
- return !("NO_COLOR" in r || l.includes("--no-color")) && ("FORCE_COLOR" in r || l.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || a && r.TERM !== "dumb" || "CI" in r) || typeof window != "undefined" && !!window.chrome;
81
- }
82
- function C({ force: e } = {}) {
83
- let r = e || B(), a = (t, o, u, n) => {
84
- let g = "", s = 0;
85
- do
86
- g += t.substring(s, n) + u, s = n + o.length, n = t.indexOf(o, s);
87
- while (~n);
88
- return g + t.substring(s);
89
- }, l = (t, o, u = t) => {
90
- let n = (g) => {
91
- let s = String(g), h = s.indexOf(o, t.length);
92
- return ~h ? t + a(s, o, u, h) + o : t + s + o;
93
- };
94
- return n.open = t, n.close = o, n;
95
- }, c = {
96
- isColorSupported: r
97
- }, f = (t) => `\x1B[${t}m`;
98
- for (let t in b) {
99
- let o = b[t];
100
- c[t] = r ? l(
101
- f(o[0]),
102
- f(o[1]),
103
- o[2]
104
- ) : i;
105
- }
106
- return c;
107
- }
108
- var d = C();
109
- var y = d;
110
- function _mergeNamespaces$1(n, m) {
111
- m.forEach(function(e) {
112
- e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
113
- if (k !== "default" && !(k in n)) {
114
- var d2 = Object.getOwnPropertyDescriptor(e, k);
115
- Object.defineProperty(n, k, d2.get ? d2 : {
116
- enumerable: true,
117
- get: function() {
118
- return e[k];
119
- }
120
- });
121
- }
122
- });
123
- });
124
- return Object.freeze(n);
125
- }
126
- function getKeysOfEnumerableProperties(object, compareKeys) {
127
- const rawKeys = Object.keys(object);
128
- const keys = compareKeys === null ? rawKeys : rawKeys.sort(compareKeys);
129
- if (Object.getOwnPropertySymbols) {
130
- for (const symbol of Object.getOwnPropertySymbols(object)) {
131
- if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) {
132
- keys.push(symbol);
133
- }
134
- }
135
- }
136
- return keys;
137
- }
138
- function printIteratorEntries(iterator, config, indentation, depth, refs, printer2, separator = ": ", length) {
139
- let result = "";
140
- let width = 0;
141
- let current = iterator.next();
142
- if (!current.done) {
143
- result += config.spacingOuter;
144
- const indentationNext = indentation + config.indent;
145
- while (!current.done) {
146
- result += indentationNext;
147
- if (width++ === config.maxWidth) {
148
- result += typeof length === "number" ? `…(${length - width + 1})` : "…";
149
- break;
150
- }
151
- const name = printer2(current.value[0], config, indentationNext, depth, refs);
152
- const value = printer2(current.value[1], config, indentationNext, depth, refs);
153
- result += name + separator + value;
154
- current = iterator.next();
155
- if (!current.done) {
156
- result += `,${config.spacingInner}`;
157
- } else if (!config.min) {
158
- result += ",";
159
- }
160
- }
161
- result += config.spacingOuter + indentation;
162
- }
163
- return result;
164
- }
165
- function printIteratorValues(iterator, config, indentation, depth, refs, printer2, length) {
166
- let result = "";
167
- let width = 0;
168
- let current = iterator.next();
169
- if (!current.done) {
170
- result += config.spacingOuter;
171
- const indentationNext = indentation + config.indent;
172
- while (!current.done) {
173
- result += indentationNext;
174
- if (width++ === config.maxWidth) {
175
- result += typeof length === "number" ? `…(${length - width + 1})` : "…";
176
- break;
177
- }
178
- result += printer2(current.value, config, indentationNext, depth, refs);
179
- current = iterator.next();
180
- if (!current.done) {
181
- result += `,${config.spacingInner}`;
182
- } else if (!config.min) {
183
- result += ",";
184
- }
185
- }
186
- result += config.spacingOuter + indentation;
187
- }
188
- return result;
189
- }
190
- function printListItems(list, config, indentation, depth, refs, printer2) {
191
- let result = "";
192
- list = list instanceof ArrayBuffer ? new DataView(list) : list;
193
- const isDataView = (l) => l instanceof DataView;
194
- const length = isDataView(list) ? list.byteLength : list.length;
195
- if (length > 0) {
196
- result += config.spacingOuter;
197
- const indentationNext = indentation + config.indent;
198
- for (let i2 = 0; i2 < length; i2++) {
199
- result += indentationNext;
200
- if (i2 === config.maxWidth) {
201
- result += `…(${length - i2})`;
202
- break;
203
- }
204
- if (isDataView(list) || i2 in list) {
205
- result += printer2(isDataView(list) ? list.getInt8(i2) : list[i2], config, indentationNext, depth, refs);
206
- }
207
- if (i2 < length - 1) {
208
- result += `,${config.spacingInner}`;
209
- } else if (!config.min) {
210
- result += ",";
211
- }
212
- }
213
- result += config.spacingOuter + indentation;
214
- }
215
- return result;
216
- }
217
- function printObjectProperties(val, config, indentation, depth, refs, printer2, compareKeysOverride = config.compareKeys) {
218
- let result = "";
219
- const keys = getKeysOfEnumerableProperties(val, compareKeysOverride);
220
- if (keys.length > 0) {
221
- result += config.spacingOuter;
222
- const indentationNext = indentation + config.indent;
223
- for (let i2 = 0; i2 < keys.length; i2++) {
224
- result += indentationNext;
225
- if (i2 === config.maxWidth) {
226
- result += `…(${keys.length - i2})`;
227
- break;
228
- }
229
- const key = keys[i2];
230
- const name = !config.quoteKeys && isUnquotableKey(key) ? key : printer2(key, config, indentationNext, depth, refs);
231
- const value = printer2(val[key], config, indentationNext, depth, refs);
232
- result += `${name}: ${value}`;
233
- if (i2 < keys.length - 1) {
234
- result += `,${config.spacingInner}`;
235
- } else if (!config.min) {
236
- result += ",";
237
- }
238
- }
239
- result += config.spacingOuter + indentation;
240
- }
241
- return result;
242
- }
243
- const keyStrRegExp = /^[a-z_]\w*$/i;
244
- function isUnquotableKey(key) {
245
- return typeof key === "string" && key !== "__proto__" && keyStrRegExp.test(key);
246
- }
247
- const asymmetricMatcher = typeof Symbol === "function" && Symbol.for ? Symbol.for("jest.asymmetricMatcher") : 1267621;
248
- const SPACE$2 = " ";
249
- const serialize$5 = (val, config, indentation, depth, refs, printer2) => {
250
- const stringedValue = val.toString();
251
- if (stringedValue === "ArrayContaining" || stringedValue === "ArrayNotContaining") {
252
- if (++depth > config.maxDepth) {
253
- return `[${stringedValue}]`;
254
- }
255
- return `${stringedValue + SPACE$2}[${printListItems(val.sample, config, indentation, depth, refs, printer2)}]`;
256
- }
257
- if (stringedValue === "ObjectContaining" || stringedValue === "ObjectNotContaining") {
258
- if (++depth > config.maxDepth) {
259
- return `[${stringedValue}]`;
260
- }
261
- return `${stringedValue + SPACE$2}{${printObjectProperties(val.sample, config, indentation, depth, refs, printer2)}}`;
262
- }
263
- if (stringedValue === "StringMatching" || stringedValue === "StringNotMatching") {
264
- return stringedValue + SPACE$2 + printer2(val.sample, config, indentation, depth, refs);
265
- }
266
- if (stringedValue === "StringContaining" || stringedValue === "StringNotContaining") {
267
- return stringedValue + SPACE$2 + printer2(val.sample, config, indentation, depth, refs);
268
- }
269
- if (typeof val.toAsymmetricMatcher !== "function") {
270
- throw new TypeError(`Asymmetric matcher ${val.constructor.name} does not implement toAsymmetricMatcher()`);
271
- }
272
- return val.toAsymmetricMatcher();
273
- };
274
- const test$5 = (val) => val && val.$$typeof === asymmetricMatcher;
275
- const plugin$5 = {
276
- serialize: serialize$5,
277
- test: test$5
278
- };
279
- const SPACE$1 = " ";
280
- const OBJECT_NAMES = /* @__PURE__ */ new Set(["DOMStringMap", "NamedNodeMap"]);
281
- const ARRAY_REGEXP = /^(?:HTML\w*Collection|NodeList)$/;
282
- function testName(name) {
283
- return OBJECT_NAMES.has(name) || ARRAY_REGEXP.test(name);
284
- }
285
- const test$4 = (val) => val && val.constructor && !!val.constructor.name && testName(val.constructor.name);
286
- function isNamedNodeMap(collection) {
287
- return collection.constructor.name === "NamedNodeMap";
288
- }
289
- const serialize$4 = (collection, config, indentation, depth, refs, printer2) => {
290
- const name = collection.constructor.name;
291
- if (++depth > config.maxDepth) {
292
- return `[${name}]`;
293
- }
294
- return (config.min ? "" : name + SPACE$1) + (OBJECT_NAMES.has(name) ? `{${printObjectProperties(isNamedNodeMap(collection) ? [...collection].reduce((props, attribute) => {
295
- props[attribute.name] = attribute.value;
296
- return props;
297
- }, {}) : { ...collection }, config, indentation, depth, refs, printer2)}}` : `[${printListItems([...collection], config, indentation, depth, refs, printer2)}]`);
298
- };
299
- const plugin$4 = {
300
- serialize: serialize$4,
301
- test: test$4
302
- };
303
- function escapeHTML(str) {
304
- return str.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
305
- }
306
- function printProps(keys, props, config, indentation, depth, refs, printer2) {
307
- const indentationNext = indentation + config.indent;
308
- const colors = config.colors;
309
- return keys.map((key) => {
310
- const value = props[key];
311
- if (typeof value === "string" && value[0] === "_" && value.startsWith("__vitest_") && value.match(/__vitest_\d+__/)) {
312
- return "";
313
- }
314
- let printed = printer2(value, config, indentationNext, depth, refs);
315
- if (typeof value !== "string") {
316
- if (printed.includes("\n")) {
317
- printed = config.spacingOuter + indentationNext + printed + config.spacingOuter + indentation;
318
- }
319
- printed = `{${printed}}`;
320
- }
321
- return `${config.spacingInner + indentation + colors.prop.open + key + colors.prop.close}=${colors.value.open}${printed}${colors.value.close}`;
322
- }).join("");
323
- }
324
- function printChildren(children, config, indentation, depth, refs, printer2) {
325
- return children.map((child) => config.spacingOuter + indentation + (typeof child === "string" ? printText(child, config) : printer2(child, config, indentation, depth, refs))).join("");
326
- }
327
- function printShadowRoot(children, config, indentation, depth, refs, printer2) {
328
- if (config.printShadowRoot === false) {
329
- return "";
330
- }
331
- return [`${config.spacingOuter + indentation}#shadow-root`, printChildren(children, config, indentation + config.indent, depth, refs, printer2)].join("");
332
- }
333
- function printText(text, config) {
334
- const contentColor = config.colors.content;
335
- return contentColor.open + escapeHTML(text) + contentColor.close;
336
- }
337
- function printComment(comment, config) {
338
- const commentColor = config.colors.comment;
339
- return `${commentColor.open}<!--${escapeHTML(comment)}-->${commentColor.close}`;
340
- }
341
- function printElement(type, printedProps, printedChildren, config, indentation) {
342
- const tagColor = config.colors.tag;
343
- return `${tagColor.open}<${type}${printedProps && tagColor.close + printedProps + config.spacingOuter + indentation + tagColor.open}${printedChildren ? `>${tagColor.close}${printedChildren}${config.spacingOuter}${indentation}${tagColor.open}</${type}` : `${printedProps && !config.min ? "" : " "}/`}>${tagColor.close}`;
344
- }
345
- function printElementAsLeaf(type, config) {
346
- const tagColor = config.colors.tag;
347
- return `${tagColor.open}<${type}${tagColor.close} …${tagColor.open} />${tagColor.close}`;
348
- }
349
- const ELEMENT_NODE = 1;
350
- const TEXT_NODE = 3;
351
- const COMMENT_NODE = 8;
352
- const FRAGMENT_NODE = 11;
353
- const ELEMENT_REGEXP = /^(?:(?:HTML|SVG)\w*)?Element$/;
354
- function testHasAttribute(val) {
355
- try {
356
- return typeof val.hasAttribute === "function" && val.hasAttribute("is");
357
- } catch {
358
- return false;
359
- }
360
- }
361
- function testNode(val) {
362
- const constructorName = val.constructor.name;
363
- const { nodeType, tagName } = val;
364
- const isCustomElement = typeof tagName === "string" && tagName.includes("-") || testHasAttribute(val);
365
- return nodeType === ELEMENT_NODE && (ELEMENT_REGEXP.test(constructorName) || isCustomElement) || nodeType === TEXT_NODE && constructorName === "Text" || nodeType === COMMENT_NODE && constructorName === "Comment" || nodeType === FRAGMENT_NODE && constructorName === "DocumentFragment";
366
- }
367
- const test$3 = (val) => {
368
- var _a;
369
- return ((_a = val == null ? void 0 : val.constructor) == null ? void 0 : _a.name) && testNode(val);
370
- };
371
- function nodeIsText(node) {
372
- return node.nodeType === TEXT_NODE;
373
- }
374
- function nodeIsComment(node) {
375
- return node.nodeType === COMMENT_NODE;
376
- }
377
- function nodeIsFragment(node) {
378
- return node.nodeType === FRAGMENT_NODE;
379
- }
380
- function filterChildren(children, filterNode) {
381
- let filtered = children.filter((node) => {
382
- if (node.nodeType === TEXT_NODE) {
383
- const text = node.data || "";
384
- return text.trim().length > 0;
385
- }
386
- return true;
387
- });
388
- if (filterNode) {
389
- filtered = filtered.filter(filterNode);
390
- }
391
- return filtered;
392
- }
393
- function serializeDOM(node, config, indentation, depth, refs, printer2, filterNode) {
394
- if (nodeIsText(node)) {
395
- return printText(node.data, config);
396
- }
397
- if (nodeIsComment(node)) {
398
- return printComment(node.data, config);
399
- }
400
- const type = nodeIsFragment(node) ? "DocumentFragment" : node.tagName.toLowerCase();
401
- if (++depth > config.maxDepth) {
402
- return printElementAsLeaf(type, config);
403
- }
404
- const children = Array.prototype.slice.call(node.childNodes || node.children);
405
- const shadowChildren = nodeIsFragment(node) || !node.shadowRoot ? [] : Array.prototype.slice.call(node.shadowRoot.children);
406
- const resolvedChildren = filterNode ? filterChildren(children, filterNode) : children;
407
- const resolvedShadowChildren = filterNode ? filterChildren(shadowChildren, filterNode) : shadowChildren;
408
- return printElement(type, printProps(nodeIsFragment(node) ? [] : Array.from(node.attributes, (attr) => attr.name).sort(), nodeIsFragment(node) ? {} : [...node.attributes].reduce((props, attribute) => {
409
- props[attribute.name] = attribute.value;
410
- return props;
411
- }, {}), config, indentation + config.indent, depth, refs, printer2), (resolvedShadowChildren.length > 0 ? printShadowRoot(resolvedShadowChildren, config, indentation + config.indent, depth, refs, printer2) : "") + printChildren(resolvedChildren, config, indentation + config.indent, depth, refs, printer2), config, indentation);
412
- }
413
- const serialize$3 = (node, config, indentation, depth, refs, printer2) => serializeDOM(node, config, indentation, depth, refs, printer2);
414
- function createDOMElementFilter(filterNode) {
415
- return {
416
- test: test$3,
417
- serialize: (node, config, indentation, depth, refs, printer2) => serializeDOM(node, config, indentation, depth, refs, printer2, filterNode)
418
- };
419
- }
420
- const plugin$3 = {
421
- serialize: serialize$3,
422
- test: test$3
423
- };
424
- const IS_ITERABLE_SENTINEL = "@@__IMMUTABLE_ITERABLE__@@";
425
- const IS_LIST_SENTINEL = "@@__IMMUTABLE_LIST__@@";
426
- const IS_KEYED_SENTINEL = "@@__IMMUTABLE_KEYED__@@";
427
- const IS_MAP_SENTINEL = "@@__IMMUTABLE_MAP__@@";
428
- const IS_ORDERED_SENTINEL = "@@__IMMUTABLE_ORDERED__@@";
429
- const IS_RECORD_SENTINEL = "@@__IMMUTABLE_RECORD__@@";
430
- const IS_SEQ_SENTINEL = "@@__IMMUTABLE_SEQ__@@";
431
- const IS_SET_SENTINEL = "@@__IMMUTABLE_SET__@@";
432
- const IS_STACK_SENTINEL = "@@__IMMUTABLE_STACK__@@";
433
- const getImmutableName = (name) => `Immutable.${name}`;
434
- const printAsLeaf = (name) => `[${name}]`;
435
- const SPACE = " ";
436
- const LAZY = "…";
437
- function printImmutableEntries(val, config, indentation, depth, refs, printer2, type) {
438
- return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : `${getImmutableName(type) + SPACE}{${printIteratorEntries(val.entries(), config, indentation, depth, refs, printer2)}}`;
439
- }
440
- function getRecordEntries(val) {
441
- let i2 = 0;
442
- return { next() {
443
- if (i2 < val._keys.length) {
444
- const key = val._keys[i2++];
445
- return {
446
- done: false,
447
- value: [key, val.get(key)]
448
- };
449
- }
450
- return {
451
- done: true,
452
- value: void 0
453
- };
454
- } };
455
- }
456
- function printImmutableRecord(val, config, indentation, depth, refs, printer2) {
457
- const name = getImmutableName(val._name || "Record");
458
- return ++depth > config.maxDepth ? printAsLeaf(name) : `${name + SPACE}{${printIteratorEntries(getRecordEntries(val), config, indentation, depth, refs, printer2)}}`;
459
- }
460
- function printImmutableSeq(val, config, indentation, depth, refs, printer2) {
461
- const name = getImmutableName("Seq");
462
- if (++depth > config.maxDepth) {
463
- return printAsLeaf(name);
464
- }
465
- if (val[IS_KEYED_SENTINEL]) {
466
- return `${name + SPACE}{${val._iter || val._object ? printIteratorEntries(val.entries(), config, indentation, depth, refs, printer2) : LAZY}}`;
467
- }
468
- return `${name + SPACE}[${val._iter || val._array || val._collection || val._iterable ? printIteratorValues(val.values(), config, indentation, depth, refs, printer2) : LAZY}]`;
469
- }
470
- function printImmutableValues(val, config, indentation, depth, refs, printer2, type) {
471
- return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : `${getImmutableName(type) + SPACE}[${printIteratorValues(val.values(), config, indentation, depth, refs, printer2)}]`;
472
- }
473
- const serialize$2 = (val, config, indentation, depth, refs, printer2) => {
474
- if (val[IS_MAP_SENTINEL]) {
475
- return printImmutableEntries(val, config, indentation, depth, refs, printer2, val[IS_ORDERED_SENTINEL] ? "OrderedMap" : "Map");
476
- }
477
- if (val[IS_LIST_SENTINEL]) {
478
- return printImmutableValues(val, config, indentation, depth, refs, printer2, "List");
479
- }
480
- if (val[IS_SET_SENTINEL]) {
481
- return printImmutableValues(val, config, indentation, depth, refs, printer2, val[IS_ORDERED_SENTINEL] ? "OrderedSet" : "Set");
482
- }
483
- if (val[IS_STACK_SENTINEL]) {
484
- return printImmutableValues(val, config, indentation, depth, refs, printer2, "Stack");
485
- }
486
- if (val[IS_SEQ_SENTINEL]) {
487
- return printImmutableSeq(val, config, indentation, depth, refs, printer2);
488
- }
489
- return printImmutableRecord(val, config, indentation, depth, refs, printer2);
490
- };
491
- const test$2 = (val) => val && (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
492
- const plugin$2 = {
493
- serialize: serialize$2,
494
- test: test$2
495
- };
496
- function getDefaultExportFromCjs(x) {
497
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
498
- }
499
- var reactIs$1 = { exports: {} };
500
- var reactIs_production = {};
501
- /**
502
- * @license React
503
- * react-is.production.js
504
- *
505
- * Copyright (c) Meta Platforms, Inc. and affiliates.
506
- *
507
- * This source code is licensed under the MIT license found in the
508
- * LICENSE file in the root directory of this source tree.
509
- */
510
- var hasRequiredReactIs_production;
511
- function requireReactIs_production() {
512
- if (hasRequiredReactIs_production) return reactIs_production;
513
- hasRequiredReactIs_production = 1;
514
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference");
515
- function typeOf(object) {
516
- if ("object" === typeof object && null !== object) {
517
- var $$typeof = object.$$typeof;
518
- switch ($$typeof) {
519
- case REACT_ELEMENT_TYPE:
520
- switch (object = object.type, object) {
521
- case REACT_FRAGMENT_TYPE:
522
- case REACT_PROFILER_TYPE:
523
- case REACT_STRICT_MODE_TYPE:
524
- case REACT_SUSPENSE_TYPE:
525
- case REACT_SUSPENSE_LIST_TYPE:
526
- case REACT_VIEW_TRANSITION_TYPE:
527
- return object;
528
- default:
529
- switch (object = object && object.$$typeof, object) {
530
- case REACT_CONTEXT_TYPE:
531
- case REACT_FORWARD_REF_TYPE:
532
- case REACT_LAZY_TYPE:
533
- case REACT_MEMO_TYPE:
534
- return object;
535
- case REACT_CONSUMER_TYPE:
536
- return object;
537
- default:
538
- return $$typeof;
539
- }
540
- }
541
- case REACT_PORTAL_TYPE:
542
- return $$typeof;
543
- }
544
- }
545
- }
546
- reactIs_production.ContextConsumer = REACT_CONSUMER_TYPE;
547
- reactIs_production.ContextProvider = REACT_CONTEXT_TYPE;
548
- reactIs_production.Element = REACT_ELEMENT_TYPE;
549
- reactIs_production.ForwardRef = REACT_FORWARD_REF_TYPE;
550
- reactIs_production.Fragment = REACT_FRAGMENT_TYPE;
551
- reactIs_production.Lazy = REACT_LAZY_TYPE;
552
- reactIs_production.Memo = REACT_MEMO_TYPE;
553
- reactIs_production.Portal = REACT_PORTAL_TYPE;
554
- reactIs_production.Profiler = REACT_PROFILER_TYPE;
555
- reactIs_production.StrictMode = REACT_STRICT_MODE_TYPE;
556
- reactIs_production.Suspense = REACT_SUSPENSE_TYPE;
557
- reactIs_production.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
558
- reactIs_production.isContextConsumer = function(object) {
559
- return typeOf(object) === REACT_CONSUMER_TYPE;
560
- };
561
- reactIs_production.isContextProvider = function(object) {
562
- return typeOf(object) === REACT_CONTEXT_TYPE;
563
- };
564
- reactIs_production.isElement = function(object) {
565
- return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
566
- };
567
- reactIs_production.isForwardRef = function(object) {
568
- return typeOf(object) === REACT_FORWARD_REF_TYPE;
569
- };
570
- reactIs_production.isFragment = function(object) {
571
- return typeOf(object) === REACT_FRAGMENT_TYPE;
572
- };
573
- reactIs_production.isLazy = function(object) {
574
- return typeOf(object) === REACT_LAZY_TYPE;
575
- };
576
- reactIs_production.isMemo = function(object) {
577
- return typeOf(object) === REACT_MEMO_TYPE;
578
- };
579
- reactIs_production.isPortal = function(object) {
580
- return typeOf(object) === REACT_PORTAL_TYPE;
581
- };
582
- reactIs_production.isProfiler = function(object) {
583
- return typeOf(object) === REACT_PROFILER_TYPE;
584
- };
585
- reactIs_production.isStrictMode = function(object) {
586
- return typeOf(object) === REACT_STRICT_MODE_TYPE;
587
- };
588
- reactIs_production.isSuspense = function(object) {
589
- return typeOf(object) === REACT_SUSPENSE_TYPE;
590
- };
591
- reactIs_production.isSuspenseList = function(object) {
592
- return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
593
- };
594
- reactIs_production.isValidElementType = function(type) {
595
- return "string" === typeof type || "function" === typeof type || type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || "object" === typeof type && null !== type && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_CONSUMER_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_CLIENT_REFERENCE || void 0 !== type.getModuleId) ? true : false;
596
- };
597
- reactIs_production.typeOf = typeOf;
598
- return reactIs_production;
599
- }
600
- var hasRequiredReactIs$1;
601
- function requireReactIs$1() {
602
- if (hasRequiredReactIs$1) return reactIs$1.exports;
603
- hasRequiredReactIs$1 = 1;
604
- {
605
- reactIs$1.exports = requireReactIs_production();
606
- }
607
- return reactIs$1.exports;
608
- }
609
- var reactIsExports$1 = requireReactIs$1();
610
- var index$1 = /* @__PURE__ */ getDefaultExportFromCjs(reactIsExports$1);
611
- var ReactIs19 = /* @__PURE__ */ _mergeNamespaces$1({
612
- __proto__: null,
613
- default: index$1
614
- }, [reactIsExports$1]);
615
- var reactIs = { exports: {} };
616
- var reactIs_production_min = {};
617
- /**
618
- * @license React
619
- * react-is.production.min.js
620
- *
621
- * Copyright (c) Facebook, Inc. and its affiliates.
622
- *
623
- * This source code is licensed under the MIT license found in the
624
- * LICENSE file in the root directory of this source tree.
625
- */
626
- var hasRequiredReactIs_production_min;
627
- function requireReactIs_production_min() {
628
- if (hasRequiredReactIs_production_min) return reactIs_production_min;
629
- hasRequiredReactIs_production_min = 1;
630
- var b2 = Symbol.for("react.element"), c = Symbol.for("react.portal"), d2 = Symbol.for("react.fragment"), e = Symbol.for("react.strict_mode"), f = Symbol.for("react.profiler"), g = Symbol.for("react.provider"), h = Symbol.for("react.context"), k = Symbol.for("react.server_context"), l = Symbol.for("react.forward_ref"), m = Symbol.for("react.suspense"), n = Symbol.for("react.suspense_list"), p = Symbol.for("react.memo"), q = Symbol.for("react.lazy"), t = Symbol.for("react.offscreen"), u;
631
- u = Symbol.for("react.module.reference");
632
- function v(a) {
633
- if ("object" === typeof a && null !== a) {
634
- var r = a.$$typeof;
635
- switch (r) {
636
- case b2:
637
- switch (a = a.type, a) {
638
- case d2:
639
- case f:
640
- case e:
641
- case m:
642
- case n:
643
- return a;
644
- default:
645
- switch (a = a && a.$$typeof, a) {
646
- case k:
647
- case h:
648
- case l:
649
- case q:
650
- case p:
651
- case g:
652
- return a;
653
- default:
654
- return r;
655
- }
656
- }
657
- case c:
658
- return r;
659
- }
660
- }
661
- }
662
- reactIs_production_min.ContextConsumer = h;
663
- reactIs_production_min.ContextProvider = g;
664
- reactIs_production_min.Element = b2;
665
- reactIs_production_min.ForwardRef = l;
666
- reactIs_production_min.Fragment = d2;
667
- reactIs_production_min.Lazy = q;
668
- reactIs_production_min.Memo = p;
669
- reactIs_production_min.Portal = c;
670
- reactIs_production_min.Profiler = f;
671
- reactIs_production_min.StrictMode = e;
672
- reactIs_production_min.Suspense = m;
673
- reactIs_production_min.SuspenseList = n;
674
- reactIs_production_min.isAsyncMode = function() {
675
- return false;
676
- };
677
- reactIs_production_min.isConcurrentMode = function() {
678
- return false;
679
- };
680
- reactIs_production_min.isContextConsumer = function(a) {
681
- return v(a) === h;
682
- };
683
- reactIs_production_min.isContextProvider = function(a) {
684
- return v(a) === g;
685
- };
686
- reactIs_production_min.isElement = function(a) {
687
- return "object" === typeof a && null !== a && a.$$typeof === b2;
688
- };
689
- reactIs_production_min.isForwardRef = function(a) {
690
- return v(a) === l;
691
- };
692
- reactIs_production_min.isFragment = function(a) {
693
- return v(a) === d2;
694
- };
695
- reactIs_production_min.isLazy = function(a) {
696
- return v(a) === q;
697
- };
698
- reactIs_production_min.isMemo = function(a) {
699
- return v(a) === p;
700
- };
701
- reactIs_production_min.isPortal = function(a) {
702
- return v(a) === c;
703
- };
704
- reactIs_production_min.isProfiler = function(a) {
705
- return v(a) === f;
706
- };
707
- reactIs_production_min.isStrictMode = function(a) {
708
- return v(a) === e;
709
- };
710
- reactIs_production_min.isSuspense = function(a) {
711
- return v(a) === m;
712
- };
713
- reactIs_production_min.isSuspenseList = function(a) {
714
- return v(a) === n;
715
- };
716
- reactIs_production_min.isValidElementType = function(a) {
717
- return "string" === typeof a || "function" === typeof a || a === d2 || a === f || a === e || a === m || a === n || a === t || "object" === typeof a && null !== a && (a.$$typeof === q || a.$$typeof === p || a.$$typeof === g || a.$$typeof === h || a.$$typeof === l || a.$$typeof === u || void 0 !== a.getModuleId) ? true : false;
718
- };
719
- reactIs_production_min.typeOf = v;
720
- return reactIs_production_min;
721
- }
722
- var hasRequiredReactIs;
723
- function requireReactIs() {
724
- if (hasRequiredReactIs) return reactIs.exports;
725
- hasRequiredReactIs = 1;
726
- {
727
- reactIs.exports = requireReactIs_production_min();
728
- }
729
- return reactIs.exports;
730
- }
731
- var reactIsExports = requireReactIs();
732
- var index = /* @__PURE__ */ getDefaultExportFromCjs(reactIsExports);
733
- var ReactIs18 = /* @__PURE__ */ _mergeNamespaces$1({
734
- __proto__: null,
735
- default: index
736
- }, [reactIsExports]);
737
- const reactIsMethods = [
738
- "isAsyncMode",
739
- "isConcurrentMode",
740
- "isContextConsumer",
741
- "isContextProvider",
742
- "isElement",
743
- "isForwardRef",
744
- "isFragment",
745
- "isLazy",
746
- "isMemo",
747
- "isPortal",
748
- "isProfiler",
749
- "isStrictMode",
750
- "isSuspense",
751
- "isSuspenseList",
752
- "isValidElementType"
753
- ];
754
- const ReactIs = Object.fromEntries(reactIsMethods.map((m) => [m, (v) => ReactIs18[m](v) || ReactIs19[m](v)]));
755
- function getChildren(arg, children = []) {
756
- if (Array.isArray(arg)) {
757
- for (const item of arg) {
758
- getChildren(item, children);
759
- }
760
- } else if (arg != null && arg !== false && arg !== "") {
761
- children.push(arg);
762
- }
763
- return children;
764
- }
765
- function getType(element) {
766
- const type = element.type;
767
- if (typeof type === "string") {
768
- return type;
769
- }
770
- if (typeof type === "function") {
771
- return type.displayName || type.name || "Unknown";
772
- }
773
- if (ReactIs.isFragment(element)) {
774
- return "React.Fragment";
775
- }
776
- if (ReactIs.isSuspense(element)) {
777
- return "React.Suspense";
778
- }
779
- if (typeof type === "object" && type !== null) {
780
- if (ReactIs.isContextProvider(element)) {
781
- return "Context.Provider";
782
- }
783
- if (ReactIs.isContextConsumer(element)) {
784
- return "Context.Consumer";
785
- }
786
- if (ReactIs.isForwardRef(element)) {
787
- if (type.displayName) {
788
- return type.displayName;
789
- }
790
- const functionName = type.render.displayName || type.render.name || "";
791
- return functionName === "" ? "ForwardRef" : `ForwardRef(${functionName})`;
792
- }
793
- if (ReactIs.isMemo(element)) {
794
- const functionName = type.displayName || type.type.displayName || type.type.name || "";
795
- return functionName === "" ? "Memo" : `Memo(${functionName})`;
796
- }
797
- }
798
- return "UNDEFINED";
799
- }
800
- function getPropKeys$1(element) {
801
- const { props } = element;
802
- return Object.keys(props).filter((key) => key !== "children" && props[key] !== void 0).sort();
803
- }
804
- const serialize$1 = (element, config, indentation, depth, refs, printer2) => ++depth > config.maxDepth ? printElementAsLeaf(getType(element), config) : printElement(getType(element), printProps(getPropKeys$1(element), element.props, config, indentation + config.indent, depth, refs, printer2), printChildren(getChildren(element.props.children), config, indentation + config.indent, depth, refs, printer2), config, indentation);
805
- const test$1 = (val) => val != null && ReactIs.isElement(val);
806
- const plugin$1 = {
807
- serialize: serialize$1,
808
- test: test$1
809
- };
810
- const testSymbol = typeof Symbol === "function" && Symbol.for ? Symbol.for("react.test.json") : 245830487;
811
- function getPropKeys(object) {
812
- const { props } = object;
813
- return props ? Object.keys(props).filter((key) => props[key] !== void 0).sort() : [];
814
- }
815
- const serialize = (object, config, indentation, depth, refs, printer2) => ++depth > config.maxDepth ? printElementAsLeaf(object.type, config) : printElement(object.type, object.props ? printProps(getPropKeys(object), object.props, config, indentation + config.indent, depth, refs, printer2) : "", object.children ? printChildren(object.children, config, indentation + config.indent, depth, refs, printer2) : "", config, indentation);
816
- const test = (val) => val && val.$$typeof === testSymbol;
817
- const plugin = {
818
- serialize,
819
- test
820
- };
821
- const toString = Object.prototype.toString;
822
- const toISOString = Date.prototype.toISOString;
823
- const errorToString = Error.prototype.toString;
824
- const regExpToString = RegExp.prototype.toString;
825
- function getConstructorName(val) {
826
- return typeof val.constructor === "function" && val.constructor.name || "Object";
827
- }
828
- function isWindow(val) {
829
- return typeof window !== "undefined" && val === window;
830
- }
831
- const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
832
- const NEWLINE_REGEXP = /\n/g;
833
- class PrettyFormatPluginError extends Error {
834
- constructor(message, stack) {
835
- super(message);
836
- this.stack = stack;
837
- this.name = this.constructor.name;
838
- }
839
- }
840
- function isToStringedArrayType(toStringed) {
841
- return toStringed === "[object Array]" || toStringed === "[object ArrayBuffer]" || toStringed === "[object DataView]" || toStringed === "[object Float32Array]" || toStringed === "[object Float64Array]" || toStringed === "[object Int8Array]" || toStringed === "[object Int16Array]" || toStringed === "[object Int32Array]" || toStringed === "[object Uint8Array]" || toStringed === "[object Uint8ClampedArray]" || toStringed === "[object Uint16Array]" || toStringed === "[object Uint32Array]";
842
- }
843
- function printNumber(val) {
844
- return Object.is(val, -0) ? "-0" : String(val);
845
- }
846
- function printBigInt(val) {
847
- return String(`${val}n`);
848
- }
849
- function printFunction(val, printFunctionName) {
850
- if (!printFunctionName) {
851
- return "[Function]";
852
- }
853
- return `[Function ${val.name || "anonymous"}]`;
854
- }
855
- function printSymbol(val) {
856
- return String(val).replace(SYMBOL_REGEXP, "Symbol($1)");
857
- }
858
- function printError(val) {
859
- return `[${errorToString.call(val)}]`;
860
- }
861
- function printBasicValue(val, printFunctionName, escapeRegex, escapeString, singleQuote) {
862
- if (val === true || val === false) {
863
- return `${val}`;
864
- }
865
- if (val === void 0) {
866
- return "undefined";
867
- }
868
- if (val === null) {
869
- return "null";
870
- }
871
- const typeOf = typeof val;
872
- if (typeOf === "number") {
873
- return printNumber(val);
874
- }
875
- if (typeOf === "bigint") {
876
- return printBigInt(val);
877
- }
878
- if (typeOf === "string") {
879
- const q = singleQuote ? "'" : '"';
880
- if (escapeString) {
881
- const escapePattern = singleQuote ? /['\\]/g : /["\\]/g;
882
- return `${q}${val.replaceAll(escapePattern, "\\$&")}${q}`;
883
- }
884
- return `${q}${val}${q}`;
885
- }
886
- if (typeOf === "function") {
887
- return printFunction(val, printFunctionName);
888
- }
889
- if (typeOf === "symbol") {
890
- return printSymbol(val);
891
- }
892
- const toStringed = toString.call(val);
893
- if (toStringed === "[object WeakMap]") {
894
- return "WeakMap {}";
895
- }
896
- if (toStringed === "[object WeakSet]") {
897
- return "WeakSet {}";
898
- }
899
- if (toStringed === "[object Function]" || toStringed === "[object GeneratorFunction]") {
900
- return printFunction(val, printFunctionName);
901
- }
902
- if (toStringed === "[object Symbol]") {
903
- return printSymbol(val);
904
- }
905
- if (toStringed === "[object Date]") {
906
- return Number.isNaN(+val) ? "Date { NaN }" : toISOString.call(val);
907
- }
908
- if (toStringed === "[object Error]") {
909
- return printError(val);
910
- }
911
- if (toStringed === "[object RegExp]") {
912
- if (escapeRegex) {
913
- return regExpToString.call(val).replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&");
914
- }
915
- return regExpToString.call(val);
916
- }
917
- if (val instanceof Error) {
918
- return printError(val);
919
- }
920
- return null;
921
- }
922
- function printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON) {
923
- if (refs.includes(val)) {
924
- return "[Circular]";
925
- }
926
- refs = [...refs];
927
- refs.push(val);
928
- const hitMaxDepth = ++depth > config.maxDepth;
929
- const min = config.min;
930
- if (config.callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === "function" && !hasCalledToJSON) {
931
- return printer(val.toJSON(), config, indentation, depth, refs, true);
932
- }
933
- const toStringed = toString.call(val);
934
- if (toStringed === "[object Arguments]") {
935
- return hitMaxDepth ? "[Arguments]" : `${min ? "" : "Arguments "}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
936
- }
937
- if (isToStringedArrayType(toStringed)) {
938
- return hitMaxDepth ? `[${val.constructor.name}]` : `${!config.printBasicPrototype && val.constructor.name === "Array" ? "" : `${val.constructor.name} `}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
939
- }
940
- if (toStringed === "[object Map]") {
941
- return hitMaxDepth ? "[Map]" : `Map {${printIteratorEntries(val.entries(), config, indentation, depth, refs, printer, " => ", val.size)}}`;
942
- }
943
- if (toStringed === "[object Set]") {
944
- return hitMaxDepth ? "[Set]" : `Set {${printIteratorValues(val.values(), config, indentation, depth, refs, printer, val.size)}}`;
945
- }
946
- return hitMaxDepth || isWindow(val) ? `[${getConstructorName(val)}]` : `${!config.printBasicPrototype && getConstructorName(val) === "Object" ? "" : `${getConstructorName(val)} `}{${printObjectProperties(val, config, indentation, depth, refs, printer)}}`;
947
- }
948
- function isNewPlugin(plugin2) {
949
- return plugin2.serialize != null;
950
- }
951
- function printPlugin(plugin2, val, config, indentation, depth, refs) {
952
- let printed;
953
- try {
954
- printed = isNewPlugin(plugin2) ? plugin2.serialize(val, config, indentation, depth, refs, printer) : plugin2.print(val, (valChild) => printer(valChild, config, indentation, depth, refs), (str) => {
955
- const indentationNext = indentation + config.indent;
956
- return indentationNext + str.replaceAll(NEWLINE_REGEXP, `
957
- ${indentationNext}`);
958
- }, {
959
- edgeSpacing: config.spacingOuter,
960
- min: config.min,
961
- spacing: config.spacingInner
962
- }, config.colors);
963
- } catch (error) {
964
- throw new PrettyFormatPluginError(error.message, error.stack);
965
- }
966
- if (typeof printed !== "string") {
967
- throw new TypeError(`pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`);
968
- }
969
- return printed;
970
- }
971
- function findPlugin(plugins2, val) {
972
- for (const plugin2 of plugins2) {
973
- try {
974
- if (plugin2.test(val)) {
975
- return plugin2;
976
- }
977
- } catch (error) {
978
- throw new PrettyFormatPluginError(error.message, error.stack);
979
- }
980
- }
981
- return null;
982
- }
983
- function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
984
- var _a;
985
- let result;
986
- const plugin2 = findPlugin(config.plugins, val);
987
- if (plugin2 !== null) {
988
- result = printPlugin(plugin2, val, config, indentation, depth, refs);
989
- } else {
990
- const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString, config.singleQuote);
991
- if (basicResult !== null) {
992
- result = basicResult;
993
- } else {
994
- result = printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON);
995
- }
996
- }
997
- (_a = config._outputLengthPerDepth)[depth] ?? (_a[depth] = 0);
998
- config._outputLengthPerDepth[depth] += result.length;
999
- if (config._outputLengthPerDepth[depth] > config.maxOutputLength) {
1000
- config.maxDepth = 0;
1001
- }
1002
- return result;
1003
- }
1004
- const DEFAULT_THEME = {
1005
- comment: "gray",
1006
- content: "reset",
1007
- prop: "yellow",
1008
- tag: "cyan",
1009
- value: "green"
1010
- };
1011
- const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
1012
- const DEFAULT_OPTIONS = {
1013
- callToJSON: true,
1014
- compareKeys: void 0,
1015
- escapeRegex: false,
1016
- escapeString: true,
1017
- highlight: false,
1018
- indent: 2,
1019
- maxDepth: Number.POSITIVE_INFINITY,
1020
- maxOutputLength: 1e6,
1021
- maxWidth: Number.POSITIVE_INFINITY,
1022
- min: false,
1023
- plugins: [],
1024
- printBasicPrototype: true,
1025
- printFunctionName: true,
1026
- printShadowRoot: true,
1027
- theme: DEFAULT_THEME,
1028
- singleQuote: false,
1029
- quoteKeys: true,
1030
- spacingInner: "\n",
1031
- spacingOuter: "\n"
1032
- };
1033
- function validateOptions(options) {
1034
- for (const key of Object.keys(options)) {
1035
- if (!Object.hasOwn(DEFAULT_OPTIONS, key)) {
1036
- throw new Error(`pretty-format: Unknown option "${key}".`);
1037
- }
1038
- }
1039
- if (options.min && options.indent !== void 0 && options.indent !== 0) {
1040
- throw new Error('pretty-format: Options "min" and "indent" cannot be used together.');
1041
- }
1042
- }
1043
- function getColorsHighlight() {
1044
- return DEFAULT_THEME_KEYS.reduce((colors, key) => {
1045
- const value = DEFAULT_THEME[key];
1046
- const color = value && y[value];
1047
- if (color && typeof color.close === "string" && typeof color.open === "string") {
1048
- colors[key] = color;
1049
- } else {
1050
- throw new Error(`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`);
1051
- }
1052
- return colors;
1053
- }, /* @__PURE__ */ Object.create(null));
1054
- }
1055
- function getColorsEmpty() {
1056
- return DEFAULT_THEME_KEYS.reduce((colors, key) => {
1057
- colors[key] = {
1058
- close: "",
1059
- open: ""
1060
- };
1061
- return colors;
1062
- }, /* @__PURE__ */ Object.create(null));
1063
- }
1064
- function getPrintFunctionName(options) {
1065
- return (options == null ? void 0 : options.printFunctionName) ?? DEFAULT_OPTIONS.printFunctionName;
1066
- }
1067
- function getEscapeRegex(options) {
1068
- return (options == null ? void 0 : options.escapeRegex) ?? DEFAULT_OPTIONS.escapeRegex;
1069
- }
1070
- function getEscapeString(options) {
1071
- return (options == null ? void 0 : options.escapeString) ?? DEFAULT_OPTIONS.escapeString;
1072
- }
1073
- function getConfig$1(options) {
1074
- return {
1075
- callToJSON: (options == null ? void 0 : options.callToJSON) ?? DEFAULT_OPTIONS.callToJSON,
1076
- colors: (options == null ? void 0 : options.highlight) ? getColorsHighlight() : getColorsEmpty(),
1077
- compareKeys: typeof (options == null ? void 0 : options.compareKeys) === "function" || (options == null ? void 0 : options.compareKeys) === null ? options.compareKeys : DEFAULT_OPTIONS.compareKeys,
1078
- escapeRegex: getEscapeRegex(options),
1079
- escapeString: getEscapeString(options),
1080
- indent: (options == null ? void 0 : options.min) ? "" : createIndent((options == null ? void 0 : options.indent) ?? DEFAULT_OPTIONS.indent),
1081
- maxDepth: (options == null ? void 0 : options.maxDepth) ?? DEFAULT_OPTIONS.maxDepth,
1082
- maxWidth: (options == null ? void 0 : options.maxWidth) ?? DEFAULT_OPTIONS.maxWidth,
1083
- min: (options == null ? void 0 : options.min) ?? DEFAULT_OPTIONS.min,
1084
- plugins: (options == null ? void 0 : options.plugins) ?? DEFAULT_OPTIONS.plugins,
1085
- printBasicPrototype: (options == null ? void 0 : options.printBasicPrototype) ?? !(options == null ? void 0 : options.min),
1086
- printFunctionName: getPrintFunctionName(options),
1087
- printShadowRoot: (options == null ? void 0 : options.printShadowRoot) ?? true,
1088
- spacingInner: (options == null ? void 0 : options.spacingInner) ?? ((options == null ? void 0 : options.min) ? " " : "\n"),
1089
- spacingOuter: (options == null ? void 0 : options.spacingOuter) ?? ((options == null ? void 0 : options.min) ? "" : "\n"),
1090
- singleQuote: (options == null ? void 0 : options.singleQuote) ?? DEFAULT_OPTIONS.singleQuote,
1091
- quoteKeys: (options == null ? void 0 : options.quoteKeys) ?? DEFAULT_OPTIONS.quoteKeys,
1092
- maxOutputLength: (options == null ? void 0 : options.maxOutputLength) ?? DEFAULT_OPTIONS.maxOutputLength,
1093
- _outputLengthPerDepth: []
1094
- };
1095
- }
1096
- function createIndent(indent) {
1097
- return Array.from({ length: indent + 1 }).join(" ");
1098
- }
1099
- function format$1(val, options) {
1100
- if (options) {
1101
- validateOptions(options);
1102
- }
1103
- const config = getConfig$1(options);
1104
- const plugin2 = findPlugin(config.plugins, val);
1105
- if (plugin2 !== null) {
1106
- return printPlugin(plugin2, val, config, "", 0, []);
1107
- }
1108
- const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString, config.singleQuote);
1109
- if (basicResult !== null) {
1110
- return basicResult;
1111
- }
1112
- return printComplexValue(val, config, "", 0, []);
1113
- }
1114
- const plugins = {
1115
- AsymmetricMatcher: plugin$5,
1116
- DOMCollection: plugin$4,
1117
- DOMElement: plugin$3,
1118
- Immutable: plugin$2,
1119
- ReactElement: plugin$1,
1120
- ReactTestComponent: plugin
1121
- };
1122
- const { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent } = plugins;
1123
- const PLUGINS = [
1124
- ReactTestComponent,
1125
- ReactElement,
1126
- DOMElement,
1127
- DOMCollection,
1128
- Immutable,
1129
- AsymmetricMatcher
1130
- ];
1131
- function stringify(object, maxDepth = 10, { maxLength, filterNode, ...options } = {}) {
1132
- const MAX_LENGTH = maxLength ?? 1e4;
1133
- let result;
1134
- const filterFn = typeof filterNode === "string" ? createNodeFilterFromSelector(filterNode) : filterNode;
1135
- const plugins2 = filterFn ? [
1136
- ReactTestComponent,
1137
- ReactElement,
1138
- createDOMElementFilter(filterFn),
1139
- DOMCollection,
1140
- Immutable,
1141
- AsymmetricMatcher
1142
- ] : PLUGINS;
1143
- try {
1144
- result = format$1(object, {
1145
- maxDepth,
1146
- escapeString: false,
1147
- plugins: plugins2,
1148
- ...options
1149
- });
1150
- } catch {
1151
- result = format$1(object, {
1152
- callToJSON: false,
1153
- maxDepth,
1154
- escapeString: false,
1155
- plugins: plugins2,
1156
- ...options
1157
- });
1158
- }
1159
- return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(Math.min(maxDepth, Number.MAX_SAFE_INTEGER) / 2), {
1160
- maxLength,
1161
- filterNode,
1162
- ...options
1163
- }) : result;
1164
- }
1165
- function createNodeFilterFromSelector(selector) {
1166
- const ELEMENT_NODE2 = 1;
1167
- const COMMENT_NODE2 = 8;
1168
- return (node) => {
1169
- if (node.nodeType === COMMENT_NODE2) {
1170
- return false;
1171
- }
1172
- if (node.nodeType === ELEMENT_NODE2 && node.matches) {
1173
- try {
1174
- return !node.matches(selector);
1175
- } catch {
1176
- return true;
1177
- }
1178
- }
1179
- return true;
1180
- };
1181
- }
1182
- const formatRegExp = /%[sdjifoOc%]/g;
1183
- function format(args, options = {}) {
1184
- const formatArg = (item) => inspect(item, options);
1185
- if (typeof args[0] !== "string") {
1186
- const objects = [];
1187
- for (let i3 = 0; i3 < args.length; i3++) {
1188
- objects.push(formatArg(args[i3]));
1189
- }
1190
- return objects.join(" ");
1191
- }
1192
- const len = args.length;
1193
- let i2 = 1;
1194
- const template = args[0];
1195
- let str = String(template).replace(formatRegExp, (x) => {
1196
- if (x === "%%") {
1197
- return "%";
1198
- }
1199
- if (i2 >= len) {
1200
- return x;
1201
- }
1202
- switch (x) {
1203
- case "%s": {
1204
- const value = args[i2++];
1205
- if (typeof value === "bigint") {
1206
- return `${value.toString()}n`;
1207
- }
1208
- if (typeof value === "number" && value === 0 && 1 / value < 0) {
1209
- return "-0";
1210
- }
1211
- if (typeof value === "object" && value !== null) {
1212
- if (typeof value.toString === "function" && value.toString !== Object.prototype.toString) {
1213
- return value.toString();
1214
- }
1215
- return formatArg(value);
1216
- }
1217
- return String(value);
1218
- }
1219
- case "%d": {
1220
- const value = args[i2++];
1221
- if (typeof value === "bigint") {
1222
- return `${value.toString()}n`;
1223
- }
1224
- if (typeof value === "symbol") {
1225
- return "NaN";
1226
- }
1227
- return Number(value).toString();
1228
- }
1229
- case "%i": {
1230
- const value = args[i2++];
1231
- if (typeof value === "bigint") {
1232
- return `${value.toString()}n`;
1233
- }
1234
- return Number.parseInt(String(value)).toString();
1235
- }
1236
- case "%f":
1237
- return Number.parseFloat(String(args[i2++])).toString();
1238
- case "%o":
1239
- case "%O":
1240
- return formatArg(args[i2++]);
1241
- case "%c": {
1242
- i2++;
1243
- return "";
1244
- }
1245
- case "%j":
1246
- try {
1247
- return JSON.stringify(args[i2++]);
1248
- } catch (err) {
1249
- const m = err.message;
1250
- if (m.includes("circular structure") || m.includes("cyclic structures") || m.includes("cyclic object")) {
1251
- return "[Circular]";
1252
- }
1253
- throw err;
1254
- }
1255
- default:
1256
- return x;
1257
- }
1258
- });
1259
- for (let x = args[i2]; i2 < len; x = args[++i2]) {
1260
- if (x === null || typeof x !== "object") {
1261
- str += ` ${typeof x === "symbol" ? x.toString() : x}`;
1262
- } else {
1263
- str += ` ${formatArg(x)}`;
1264
- }
1265
- }
1266
- return str;
1267
- }
1268
- function inspect(obj, options) {
1269
- const { truncate, multiline, ...stringifyOptions } = options ?? {};
1270
- const prettyFormatOptions = {
1271
- singleQuote: true,
1272
- quoteKeys: false,
1273
- min: true,
1274
- spacingInner: " ",
1275
- spacingOuter: " ",
1276
- printBasicPrototype: false,
1277
- compareKeys: null,
1278
- ...multiline ? {
1279
- min: false,
1280
- spacingInner: void 0,
1281
- spacingOuter: void 0
1282
- } : {}
1283
- };
1284
- const threshold = truncate ?? 0;
1285
- const formatted = stringify(obj, void 0, {
1286
- ...prettyFormatOptions,
1287
- ...stringifyOptions,
1288
- maxLength: threshold || void 0
1289
- });
1290
- if (threshold === 0 || formatted.length <= threshold) {
1291
- return formatted;
1292
- }
1293
- const type = Object.prototype.toString.call(obj);
1294
- if (typeof obj === "string") {
1295
- let end = threshold - 1;
1296
- if (end > 0 && isHighSurrogate(formatted[end - 1])) {
1297
- end = end - 1;
1298
- }
1299
- return `'${formatted.slice(1, end)}…'`;
1300
- }
1301
- if (type === "[object Array]" || type === "[object Object]" || type === "[object Set]" || type === "[object Map]") {
1302
- return stringifyByMaxWidth(obj, threshold, {
1303
- ...prettyFormatOptions,
1304
- ...stringifyOptions,
1305
- maxDepth: 1
1306
- });
1307
- }
1308
- return stringify(obj, void 0, {
1309
- ...prettyFormatOptions,
1310
- ...stringifyOptions,
1311
- maxDepth: 0
1312
- });
1313
- }
1314
- function truncateString(string, maxLength) {
1315
- if (string.length <= maxLength) {
1316
- return string;
1317
- }
1318
- let end = maxLength - 1;
1319
- if (isHighSurrogate(string[end - 1])) {
1320
- end = end - 1;
1321
- }
1322
- return `${string.slice(0, end)}…`;
1323
- }
1324
- function stringifyByMaxWidth(object, threshold, options) {
1325
- function evaluate(x) {
1326
- return stringify(object, void 0, {
1327
- ...options,
1328
- maxWidth: x
1329
- });
1330
- }
1331
- const opt = binarySearch(0, threshold, (x) => evaluate(x).length <= threshold);
1332
- return evaluate(opt);
1333
- }
1334
- function binarySearch(x0, x1, f) {
1335
- while (x0 + 1 < x1) {
1336
- const x = Math.floor((x0 + x1) / 2);
1337
- if (f(x)) {
1338
- x0 = x;
1339
- } else {
1340
- x1 = x;
1341
- }
1342
- }
1343
- return x0;
1344
- }
1345
- function isHighSurrogate(char) {
1346
- return char >= "\uD800" && char <= "\uDBFF";
1347
- }
1348
- function assertTypes(value, name, types) {
1349
- const receivedType = typeof value;
1350
- const pass = types.includes(receivedType);
1351
- if (!pass) {
1352
- throw new TypeError(`${name} value must be ${types.join(" or ")}, received "${receivedType}"`);
1353
- }
1354
- }
1355
- function filterOutComments(s) {
1356
- const result = [];
1357
- let commentState = "none";
1358
- for (let i2 = 0; i2 < s.length; ++i2) {
1359
- if (commentState === "singleline") {
1360
- if (s[i2] === "\n") {
1361
- commentState = "none";
1362
- }
1363
- } else if (commentState === "multiline") {
1364
- if (s[i2 - 1] === "*" && s[i2] === "/") {
1365
- commentState = "none";
1366
- }
1367
- } else if (commentState === "none") {
1368
- if (s[i2] === "/" && s[i2 + 1] === "/") {
1369
- commentState = "singleline";
1370
- } else if (s[i2] === "/" && s[i2 + 1] === "*") {
1371
- commentState = "multiline";
1372
- i2 += 2;
1373
- } else {
1374
- result.push(s[i2]);
1375
- }
1376
- }
1377
- }
1378
- return result.join("");
1379
- }
1380
- function toArray(array) {
1381
- if (array === null || array === void 0) {
1382
- array = [];
1383
- }
1384
- if (Array.isArray(array)) {
1385
- return array;
1386
- }
1387
- return [array];
1388
- }
1389
- function isObject(item) {
1390
- return item != null && typeof item === "object" && !Array.isArray(item);
1391
- }
1392
- function objectAttr(source, path, defaultValue = void 0) {
1393
- const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
1394
- let result = source;
1395
- for (const p of paths) {
1396
- result = new Object(result)[p];
1397
- if (result === void 0) {
1398
- return defaultValue;
1399
- }
1400
- }
1401
- return result;
1402
- }
1403
- function createDefer() {
1404
- let resolve2 = null;
1405
- let reject = null;
1406
- const p = new Promise((_resolve, _reject) => {
1407
- resolve2 = _resolve;
1408
- reject = _reject;
1409
- });
1410
- p.resolve = resolve2;
1411
- p.reject = reject;
1412
- return p;
1413
- }
1414
- function isNegativeNaN(val) {
1415
- if (!Number.isNaN(val)) {
1416
- return false;
1417
- }
1418
- const f64 = new Float64Array(1);
1419
- f64[0] = val;
1420
- const u32 = new Uint32Array(f64.buffer);
1421
- const isNegative = u32[1] >>> 31 === 1;
1422
- return isNegative;
1423
- }
1424
- function ordinal(i2) {
1425
- const j = i2 % 10;
1426
- const k = i2 % 100;
1427
- if (j === 1 && k !== 11) {
1428
- return `${i2}st`;
1429
- }
1430
- if (j === 2 && k !== 12) {
1431
- return `${i2}nd`;
1432
- }
1433
- if (j === 3 && k !== 13) {
1434
- return `${i2}rd`;
1435
- }
1436
- return `${i2}th`;
1437
- }
1438
- function unique(array) {
1439
- return Array.from(new Set(array));
1440
- }
1441
- const SAFE_TIMERS_SYMBOL = Symbol("vitest:SAFE_TIMERS");
1442
- function getSafeTimers() {
1443
- const { setTimeout: safeSetTimeout, setInterval: safeSetInterval, clearInterval: safeClearInterval, clearTimeout: safeClearTimeout, setImmediate: safeSetImmediate, clearImmediate: safeClearImmediate, queueMicrotask: safeQueueMicrotask } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis;
1444
- const { nextTick: safeNextTick } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis.process || {};
1445
- return {
1446
- nextTick: safeNextTick,
1447
- setTimeout: safeSetTimeout,
1448
- setInterval: safeSetInterval,
1449
- clearInterval: safeClearInterval,
1450
- clearTimeout: safeClearTimeout,
1451
- setImmediate: safeSetImmediate,
1452
- clearImmediate: safeClearImmediate,
1453
- queueMicrotask: safeQueueMicrotask
1454
- };
1455
- }
1456
- const _DRIVE_LETTER_START_RE$1 = /^[A-Za-z]:\//;
1457
- function normalizeWindowsPath$1(input = "") {
1458
- if (!input) {
1459
- return input;
1460
- }
1461
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE$1, (r) => r.toUpperCase());
1462
- }
1463
- const _IS_ABSOLUTE_RE$1 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
1464
- function cwd$1() {
1465
- if (typeof process !== "undefined" && typeof process.cwd === "function") {
1466
- return process.cwd().replace(/\\/g, "/");
1467
- }
1468
- return "/";
1469
- }
1470
- const resolve$1 = function(...arguments_) {
1471
- arguments_ = arguments_.map((argument) => normalizeWindowsPath$1(argument));
1472
- let resolvedPath = "";
1473
- let resolvedAbsolute = false;
1474
- for (let index2 = arguments_.length - 1; index2 >= -1 && !resolvedAbsolute; index2--) {
1475
- const path = index2 >= 0 ? arguments_[index2] : cwd$1();
1476
- if (!path || path.length === 0) {
1477
- continue;
1478
- }
1479
- resolvedPath = `${path}/${resolvedPath}`;
1480
- resolvedAbsolute = isAbsolute$1(path);
1481
- }
1482
- resolvedPath = normalizeString$1(resolvedPath, !resolvedAbsolute);
1483
- if (resolvedAbsolute && !isAbsolute$1(resolvedPath)) {
1484
- return `/${resolvedPath}`;
1485
- }
1486
- return resolvedPath.length > 0 ? resolvedPath : ".";
1487
- };
1488
- function normalizeString$1(path, allowAboveRoot) {
1489
- let res = "";
1490
- let lastSegmentLength = 0;
1491
- let lastSlash = -1;
1492
- let dots = 0;
1493
- let char = null;
1494
- for (let index2 = 0; index2 <= path.length; ++index2) {
1495
- if (index2 < path.length) {
1496
- char = path[index2];
1497
- } else if (char === "/") {
1498
- break;
1499
- } else {
1500
- char = "/";
1501
- }
1502
- if (char === "/") {
1503
- if (lastSlash === index2 - 1 || dots === 1) ;
1504
- else if (dots === 2) {
1505
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
1506
- if (res.length > 2) {
1507
- const lastSlashIndex = res.lastIndexOf("/");
1508
- if (lastSlashIndex === -1) {
1509
- res = "";
1510
- lastSegmentLength = 0;
1511
- } else {
1512
- res = res.slice(0, lastSlashIndex);
1513
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
1514
- }
1515
- lastSlash = index2;
1516
- dots = 0;
1517
- continue;
1518
- } else if (res.length > 0) {
1519
- res = "";
1520
- lastSegmentLength = 0;
1521
- lastSlash = index2;
1522
- dots = 0;
1523
- continue;
1524
- }
1525
- }
1526
- if (allowAboveRoot) {
1527
- res += res.length > 0 ? "/.." : "..";
1528
- lastSegmentLength = 2;
1529
- }
1530
- } else {
1531
- if (res.length > 0) {
1532
- res += `/${path.slice(lastSlash + 1, index2)}`;
1533
- } else {
1534
- res = path.slice(lastSlash + 1, index2);
1535
- }
1536
- lastSegmentLength = index2 - lastSlash - 1;
1537
- }
1538
- lastSlash = index2;
1539
- dots = 0;
1540
- } else if (char === "." && dots !== -1) {
1541
- ++dots;
1542
- } else {
1543
- dots = -1;
1544
- }
1545
- }
1546
- return res;
1547
- }
1548
- const isAbsolute$1 = function(p) {
1549
- return _IS_ABSOLUTE_RE$1.test(p);
1550
- };
1551
- var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1552
- var intToChar = new Uint8Array(64);
1553
- var charToInt = new Uint8Array(128);
1554
- for (let i2 = 0; i2 < chars.length; i2++) {
1555
- const c = chars.charCodeAt(i2);
1556
- intToChar[i2] = c;
1557
- charToInt[c] = i2;
1558
- }
1559
- const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
1560
- const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
1561
- const NOW_LENGTH = Date.now().toString().length;
1562
- const REGEXP_VITEST = new RegExp(`vitest=\\d{${NOW_LENGTH}}`);
1563
- function extractLocation(urlLike) {
1564
- if (!urlLike.includes(":")) {
1565
- return [urlLike];
1566
- }
1567
- const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
1568
- const parts = regExp.exec(urlLike.replace(/^\(|\)$/g, ""));
1569
- if (!parts) {
1570
- return [urlLike];
1571
- }
1572
- let url = parts[1];
1573
- if (url.startsWith("async ")) {
1574
- url = url.slice(6);
1575
- }
1576
- if (url.startsWith("http:") || url.startsWith("https:")) {
1577
- const urlObj = new URL(url);
1578
- urlObj.searchParams.delete("import");
1579
- urlObj.searchParams.delete("browserv");
1580
- url = urlObj.pathname + urlObj.hash + urlObj.search;
1581
- }
1582
- if (url.startsWith("/@fs/")) {
1583
- const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
1584
- url = url.slice(isWindows ? 5 : 4);
1585
- }
1586
- if (url.includes("vitest=")) {
1587
- url = url.replace(REGEXP_VITEST, "").replace(/[?&]$/, "");
1588
- }
1589
- return [
1590
- url,
1591
- parts[2] || void 0,
1592
- parts[3] || void 0
1593
- ];
1594
- }
1595
- function parseSingleFFOrSafariStack(raw) {
1596
- let line = raw.trim();
1597
- if (SAFARI_NATIVE_CODE_REGEXP.test(line)) {
1598
- return null;
1599
- }
1600
- if (line.includes(" > eval")) {
1601
- line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
1602
- }
1603
- if (!line.includes("@")) {
1604
- return null;
1605
- }
1606
- let atIndex = -1;
1607
- let locationPart = "";
1608
- let functionName;
1609
- for (let i2 = 0; i2 < line.length; i2++) {
1610
- if (line[i2] === "@") {
1611
- const candidateLocation = line.slice(i2 + 1);
1612
- if (candidateLocation.includes(":") && candidateLocation.length >= 3) {
1613
- atIndex = i2;
1614
- locationPart = candidateLocation;
1615
- functionName = i2 > 0 ? line.slice(0, i2) : void 0;
1616
- break;
1617
- }
1618
- }
1619
- }
1620
- if (atIndex === -1 || !locationPart.includes(":") || locationPart.length < 3) {
1621
- return null;
1622
- }
1623
- const [url, lineNumber, columnNumber] = extractLocation(locationPart);
1624
- if (!url || !lineNumber || !columnNumber) {
1625
- return null;
1626
- }
1627
- return {
1628
- file: url,
1629
- method: functionName || "",
1630
- line: Number.parseInt(lineNumber),
1631
- column: Number.parseInt(columnNumber)
1632
- };
1633
- }
1634
- function parseSingleStack(raw) {
1635
- const line = raw.trim();
1636
- if (!CHROME_IE_STACK_REGEXP.test(line)) {
1637
- return parseSingleFFOrSafariStack(line);
1638
- }
1639
- return parseSingleV8Stack(line);
1640
- }
1641
- function parseSingleV8Stack(raw) {
1642
- let line = raw.trim();
1643
- if (!CHROME_IE_STACK_REGEXP.test(line)) {
1644
- return null;
1645
- }
1646
- if (line.includes("(eval ")) {
1647
- line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
1648
- }
1649
- let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
1650
- const location = sanitizedLine.match(/ (\(.+\)$)/);
1651
- sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
1652
- const [url, lineNumber, columnNumber] = extractLocation(location ? location[1] : sanitizedLine);
1653
- let method = location && sanitizedLine || "";
1654
- let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
1655
- if (!file || !lineNumber || !columnNumber) {
1656
- return null;
1657
- }
1658
- if (method.startsWith("async ")) {
1659
- method = method.slice(6);
1660
- }
1661
- if (file.startsWith("file://")) {
1662
- file = file.slice(7);
1663
- }
1664
- file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve$1(file);
1665
- if (method) {
1666
- method = method.replace(/\(0\s?,\s?__vite_ssr_import_\d+__.(\w+)\)/g, "$1").replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "").replace(/(Object\.)?__vite_ssr_export_default__\s?/g, "");
1667
- }
1668
- return {
1669
- method,
1670
- file,
1671
- line: Number.parseInt(lineNumber),
1672
- column: Number.parseInt(columnNumber)
1673
- };
1674
- }
1675
- const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
1676
- function normalizeWindowsPath(input = "") {
1677
- if (!input) {
1678
- return input;
1679
- }
1680
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
1681
- }
1682
- const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
1683
- const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
1684
- function cwd() {
1685
- if (typeof process !== "undefined" && typeof process.cwd === "function") {
1686
- return process.cwd().replace(/\\/g, "/");
1687
- }
1688
- return "/";
1689
- }
1690
- const resolve = function(...arguments_) {
1691
- arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
1692
- let resolvedPath = "";
1693
- let resolvedAbsolute = false;
1694
- for (let index2 = arguments_.length - 1; index2 >= -1 && !resolvedAbsolute; index2--) {
1695
- const path = index2 >= 0 ? arguments_[index2] : cwd();
1696
- if (!path || path.length === 0) {
1697
- continue;
1698
- }
1699
- resolvedPath = `${path}/${resolvedPath}`;
1700
- resolvedAbsolute = isAbsolute(path);
1701
- }
1702
- resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
1703
- if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
1704
- return `/${resolvedPath}`;
1705
- }
1706
- return resolvedPath.length > 0 ? resolvedPath : ".";
1707
- };
1708
- function normalizeString(path, allowAboveRoot) {
1709
- let res = "";
1710
- let lastSegmentLength = 0;
1711
- let lastSlash = -1;
1712
- let dots = 0;
1713
- let char = null;
1714
- for (let index2 = 0; index2 <= path.length; ++index2) {
1715
- if (index2 < path.length) {
1716
- char = path[index2];
1717
- } else if (char === "/") {
1718
- break;
1719
- } else {
1720
- char = "/";
1721
- }
1722
- if (char === "/") {
1723
- if (lastSlash === index2 - 1 || dots === 1) ;
1724
- else if (dots === 2) {
1725
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
1726
- if (res.length > 2) {
1727
- const lastSlashIndex = res.lastIndexOf("/");
1728
- if (lastSlashIndex === -1) {
1729
- res = "";
1730
- lastSegmentLength = 0;
1731
- } else {
1732
- res = res.slice(0, lastSlashIndex);
1733
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
1734
- }
1735
- lastSlash = index2;
1736
- dots = 0;
1737
- continue;
1738
- } else if (res.length > 0) {
1739
- res = "";
1740
- lastSegmentLength = 0;
1741
- lastSlash = index2;
1742
- dots = 0;
1743
- continue;
1744
- }
1745
- }
1746
- if (allowAboveRoot) {
1747
- res += res.length > 0 ? "/.." : "..";
1748
- lastSegmentLength = 2;
1749
- }
1750
- } else {
1751
- if (res.length > 0) {
1752
- res += `/${path.slice(lastSlash + 1, index2)}`;
1753
- } else {
1754
- res = path.slice(lastSlash + 1, index2);
1755
- }
1756
- lastSegmentLength = index2 - lastSlash - 1;
1757
- }
1758
- lastSlash = index2;
1759
- dots = 0;
1760
- } else if (char === "." && dots !== -1) {
1761
- ++dots;
1762
- } else {
1763
- dots = -1;
1764
- }
1765
- }
1766
- return res;
1767
- }
1768
- const isAbsolute = function(p) {
1769
- return _IS_ABSOLUTE_RE.test(p);
1770
- };
1771
- const relative = function(from, to) {
1772
- const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
1773
- const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
1774
- if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
1775
- return _to.join("/");
1776
- }
1777
- const _fromCopy = [..._from];
1778
- for (const segment of _fromCopy) {
1779
- if (_to[0] !== segment) {
1780
- break;
1781
- }
1782
- _from.shift();
1783
- _to.shift();
1784
- }
1785
- return [..._from.map(() => ".."), ..._to].join("/");
1786
- };
1787
- class PendingError extends Error {
1788
- code = "VITEST_PENDING";
1789
- taskId;
1790
- constructor(message, task, note) {
1791
- super(message);
1792
- this.message = message;
1793
- this.note = note;
1794
- this.taskId = task.id;
1795
- }
1796
- }
1797
- class FixtureDependencyError extends Error {
1798
- name = "FixtureDependencyError";
1799
- }
1800
- class FixtureAccessError extends Error {
1801
- name = "FixtureAccessError";
1802
- }
1803
- class FixtureParseError extends Error {
1804
- name = "FixtureParseError";
1805
- }
1806
- const fnMap = /* @__PURE__ */ new WeakMap();
1807
- const testFixtureMap = /* @__PURE__ */ new WeakMap();
1808
- const hooksMap = /* @__PURE__ */ new WeakMap();
1809
- function setFn(key, fn) {
1810
- fnMap.set(key, fn);
1811
- }
1812
- function setTestFixture(key, fixture) {
1813
- testFixtureMap.set(key, fixture);
1814
- }
1815
- function getTestFixtures(key) {
1816
- return testFixtureMap.get(key);
1817
- }
1818
- function setHooks(key, hooks) {
1819
- hooksMap.set(key, hooks);
1820
- }
1821
- function getHooks(key) {
1822
- return hooksMap.get(key);
1823
- }
1824
- const FIXTURE_STACK_TRACE_KEY = Symbol.for("VITEST_FIXTURE_STACK_TRACE");
1825
- class TestFixtures {
1826
- _suiteContexts;
1827
- _overrides = /* @__PURE__ */ new WeakMap();
1828
- _registrations;
1829
- static _definitions = [];
1830
- static _builtinFixtures = [
1831
- "task",
1832
- "signal",
1833
- "onTestFailed",
1834
- "onTestFinished",
1835
- "skip",
1836
- "annotate"
1837
- ];
1838
- static _fixtureOptionKeys = [
1839
- "auto",
1840
- "injected",
1841
- "scope"
1842
- ];
1843
- static _fixtureScopes = [
1844
- "test",
1845
- "file",
1846
- "worker"
1847
- ];
1848
- static _workerContextSuite = { type: "worker" };
1849
- static clearDefinitions() {
1850
- TestFixtures._definitions.length = 0;
1851
- }
1852
- static getWorkerContexts() {
1853
- return TestFixtures._definitions.map((f) => f.getWorkerContext());
1854
- }
1855
- static getFileContexts(file) {
1856
- return TestFixtures._definitions.map((f) => f.getFileContext(file));
1857
- }
1858
- static isFixtureOptions(obj) {
1859
- return isObject(obj) && Object.keys(obj).some((key) => TestFixtures._fixtureOptionKeys.includes(key));
1860
- }
1861
- constructor(registrations) {
1862
- this._registrations = registrations ?? /* @__PURE__ */ new Map();
1863
- this._suiteContexts = /* @__PURE__ */ new WeakMap();
1864
- TestFixtures._definitions.push(this);
1865
- }
1866
- extend(runner2, userFixtures) {
1867
- const { suite: suite2 } = getCurrentSuite();
1868
- const isTopLevel = !suite2 || suite2.file === suite2;
1869
- const registrations = this.parseUserFixtures(runner2, userFixtures, isTopLevel);
1870
- return new TestFixtures(registrations);
1871
- }
1872
- get(suite2) {
1873
- let currentSuite = suite2;
1874
- while (currentSuite) {
1875
- const overrides = this._overrides.get(currentSuite);
1876
- if (overrides) {
1877
- return overrides;
1878
- }
1879
- if (currentSuite === currentSuite.file) {
1880
- break;
1881
- }
1882
- currentSuite = currentSuite.suite || currentSuite.file;
1883
- }
1884
- return this._registrations;
1885
- }
1886
- override(runner2, userFixtures) {
1887
- const { suite: currentSuite, file } = getCurrentSuite();
1888
- const suite2 = currentSuite || file;
1889
- const isTopLevel = !currentSuite || currentSuite.file === currentSuite;
1890
- const suiteRegistrations = new Map(this.get(suite2));
1891
- const registrations = this.parseUserFixtures(runner2, userFixtures, isTopLevel, suiteRegistrations);
1892
- if (isTopLevel) {
1893
- this._registrations = registrations;
1894
- } else {
1895
- this._overrides.set(suite2, registrations);
1896
- }
1897
- }
1898
- getFileContext(file) {
1899
- if (!this._suiteContexts.has(file)) {
1900
- this._suiteContexts.set(file, /* @__PURE__ */ Object.create(null));
1901
- }
1902
- return this._suiteContexts.get(file);
1903
- }
1904
- getWorkerContext() {
1905
- if (!this._suiteContexts.has(TestFixtures._workerContextSuite)) {
1906
- this._suiteContexts.set(TestFixtures._workerContextSuite, /* @__PURE__ */ Object.create(null));
1907
- }
1908
- return this._suiteContexts.get(TestFixtures._workerContextSuite);
1909
- }
1910
- parseUserFixtures(runner2, userFixtures, supportNonTest, registrations = new Map(this._registrations)) {
1911
- const errors = [];
1912
- Object.entries(userFixtures).forEach(([name, fn]) => {
1913
- var _a;
1914
- let options;
1915
- let value;
1916
- let _options;
1917
- if (Array.isArray(fn) && fn.length >= 2 && TestFixtures.isFixtureOptions(fn[1])) {
1918
- _options = fn[1];
1919
- options = {
1920
- auto: _options.auto ?? false,
1921
- scope: _options.scope ?? "test",
1922
- injected: _options.injected ?? false
1923
- };
1924
- value = options.injected ? ((_a = runner2.injectValue) == null ? void 0 : _a.call(runner2, name)) ?? fn[0] : fn[0];
1925
- } else {
1926
- value = fn;
1927
- }
1928
- const parent = registrations.get(name);
1929
- if (parent && options) {
1930
- if (parent.scope !== options.scope) {
1931
- errors.push(new FixtureDependencyError(`The "${name}" fixture was already registered with a "${options.scope}" scope.`));
1932
- }
1933
- if (parent.auto !== options.auto) {
1934
- errors.push(new FixtureDependencyError(`The "${name}" fixture was already registered as { auto: ${options.auto} }.`));
1935
- }
1936
- } else if (parent) {
1937
- options = {
1938
- auto: parent.auto,
1939
- scope: parent.scope,
1940
- injected: parent.injected
1941
- };
1942
- } else if (!options) {
1943
- options = {
1944
- auto: false,
1945
- injected: false,
1946
- scope: "test"
1947
- };
1948
- }
1949
- if (options.scope && !TestFixtures._fixtureScopes.includes(options.scope)) {
1950
- errors.push(new FixtureDependencyError(`The "${name}" fixture has unknown scope "${options.scope}".`));
1951
- }
1952
- if (!supportNonTest && options.scope !== "test") {
1953
- errors.push(new FixtureDependencyError(`The "${name}" fixture cannot be defined with a ${options.scope} scope${!(_options == null ? void 0 : _options.scope) && (parent == null ? void 0 : parent.scope) ? " (inherited from the base fixture)" : ""} inside the describe block. Define it at the top level of the file instead.`));
1954
- }
1955
- const deps = isFixtureFunction(value) ? getUsedProps(value) : /* @__PURE__ */ new Set();
1956
- const item = {
1957
- name,
1958
- value,
1959
- auto: options.auto ?? false,
1960
- injected: options.injected ?? false,
1961
- scope: options.scope ?? "test",
1962
- deps,
1963
- parent
1964
- };
1965
- if (isFixtureFunction(value)) {
1966
- Object.assign(value, { [FIXTURE_STACK_TRACE_KEY]: new Error("STACK_TRACE_ERROR") });
1967
- }
1968
- registrations.set(name, item);
1969
- if (item.scope === "worker" && (runner2.pool === "vmThreads" || runner2.pool === "vmForks")) {
1970
- item.scope = "file";
1971
- }
1972
- });
1973
- for (const fixture of registrations.values()) {
1974
- for (const depName of fixture.deps) {
1975
- if (TestFixtures._builtinFixtures.includes(depName)) {
1976
- continue;
1977
- }
1978
- const dep = registrations.get(depName);
1979
- if (!dep) {
1980
- errors.push(new FixtureDependencyError(`The "${fixture.name}" fixture depends on unknown fixture "${depName}".`));
1981
- continue;
1982
- }
1983
- if (depName === fixture.name && !fixture.parent) {
1984
- errors.push(new FixtureDependencyError(`The "${fixture.name}" fixture depends on itself, but does not have a base implementation.`));
1985
- continue;
1986
- }
1987
- if (TestFixtures._fixtureScopes.indexOf(fixture.scope) > TestFixtures._fixtureScopes.indexOf(dep.scope)) {
1988
- errors.push(new FixtureDependencyError(`The ${fixture.scope} "${fixture.name}" fixture cannot depend on a ${dep.scope} fixture "${dep.name}".`));
1989
- continue;
1990
- }
1991
- }
1992
- }
1993
- if (errors.length === 1) {
1994
- throw errors[0];
1995
- } else if (errors.length > 1) {
1996
- throw new AggregateError(errors, "Cannot resolve user fixtures. See errors for more information.");
1997
- }
1998
- return registrations;
1999
- }
2000
- }
2001
- const cleanupFnArrayMap = /* @__PURE__ */ new WeakMap();
2002
- const contextHasFixturesCache = /* @__PURE__ */ new WeakMap();
2003
- function withFixtures(fn, options) {
2004
- const collector = getCurrentSuite();
2005
- const suite2 = (options == null ? void 0 : options.suite) || collector.suite || collector.file;
2006
- return async (hookContext) => {
2007
- var _a;
2008
- const context = hookContext || (options == null ? void 0 : options.context);
2009
- if (!context) {
2010
- if (options == null ? void 0 : options.suiteHook) {
2011
- validateSuiteHook(fn, options.suiteHook, options.stackTraceError);
2012
- }
2013
- return fn({});
2014
- }
2015
- const fixtures = (options == null ? void 0 : options.fixtures) || getTestFixtures(context);
2016
- if (!fixtures) {
2017
- return fn(context);
2018
- }
2019
- const registrations = fixtures.get(suite2);
2020
- if (!registrations.size) {
2021
- return fn(context);
2022
- }
2023
- const usedFixtures = [];
2024
- const usedProps = getUsedProps(fn);
2025
- for (const fixture of registrations.values()) {
2026
- if (isAutoFixture(fixture, options) || usedProps.has(fixture.name)) {
2027
- usedFixtures.push(fixture);
2028
- }
2029
- }
2030
- if (!usedFixtures.length) {
2031
- return fn(context);
2032
- }
2033
- if (!cleanupFnArrayMap.has(context)) {
2034
- cleanupFnArrayMap.set(context, []);
2035
- }
2036
- const cleanupFnArray = cleanupFnArrayMap.get(context);
2037
- const pendingFixtures = resolveDeps(usedFixtures, registrations);
2038
- if (!pendingFixtures.length) {
2039
- return fn(context);
2040
- }
2041
- if (options == null ? void 0 : options.suiteHook) {
2042
- const testScopedFixtures = pendingFixtures.filter((f) => f.scope === "test");
2043
- if (testScopedFixtures.length > 0) {
2044
- const fixtureNames = testScopedFixtures.map((f) => `"${f.name}"`).join(", ");
2045
- const alternativeHook = {
2046
- aroundAll: "aroundEach",
2047
- beforeAll: "beforeEach",
2048
- afterAll: "afterEach"
2049
- };
2050
- const error = new FixtureDependencyError(`Test-scoped fixtures cannot be used inside ${options.suiteHook} hook. The following fixtures are test-scoped: ${fixtureNames}. Use { scope: 'file' } or { scope: 'worker' } fixtures instead, or move the logic to ${alternativeHook[options.suiteHook]} hook.`);
2051
- if ((_a = options.stackTraceError) == null ? void 0 : _a.stack) {
2052
- error.stack = error.message + options.stackTraceError.stack.replace(options.stackTraceError.message, "");
2053
- }
2054
- throw error;
2055
- }
2056
- }
2057
- if (!contextHasFixturesCache.has(context)) {
2058
- contextHasFixturesCache.set(context, /* @__PURE__ */ new WeakSet());
2059
- }
2060
- const cachedFixtures = contextHasFixturesCache.get(context);
2061
- for (const fixture of pendingFixtures) {
2062
- if (fixture.scope === "test") {
2063
- if (cachedFixtures.has(fixture)) {
2064
- continue;
2065
- }
2066
- cachedFixtures.add(fixture);
2067
- const resolvedValue = await resolveTestFixtureValue(fixture, context, cleanupFnArray);
2068
- context[fixture.name] = resolvedValue;
2069
- cleanupFnArray.push(() => {
2070
- cachedFixtures.delete(fixture);
2071
- });
2072
- } else {
2073
- const resolvedValue = await resolveScopeFixtureValue(fixtures, suite2, fixture);
2074
- context[fixture.name] = resolvedValue;
2075
- }
2076
- }
2077
- return fn(context);
2078
- };
2079
- }
2080
- function isAutoFixture(fixture, options) {
2081
- if (!fixture.auto) {
2082
- return false;
2083
- }
2084
- if ((options == null ? void 0 : options.suiteHook) && fixture.scope === "test") {
2085
- return false;
2086
- }
2087
- return true;
2088
- }
2089
- function isFixtureFunction(value) {
2090
- return typeof value === "function";
2091
- }
2092
- function resolveTestFixtureValue(fixture, context, cleanupFnArray) {
2093
- if (!isFixtureFunction(fixture.value)) {
2094
- return fixture.value;
2095
- }
2096
- return resolveFixtureFunction(fixture.value, fixture.name, context, cleanupFnArray);
2097
- }
2098
- const scopedFixturePromiseCache = /* @__PURE__ */ new WeakMap();
2099
- async function resolveScopeFixtureValue(fixtures, suite2, fixture) {
2100
- const workerContext = fixtures.getWorkerContext();
2101
- const fileContext = fixtures.getFileContext(suite2.file);
2102
- const fixtureContext = fixture.scope === "worker" ? workerContext : fileContext;
2103
- if (!isFixtureFunction(fixture.value)) {
2104
- fixtureContext[fixture.name] = fixture.value;
2105
- return fixture.value;
2106
- }
2107
- if (fixture.name in fixtureContext) {
2108
- return fixtureContext[fixture.name];
2109
- }
2110
- if (scopedFixturePromiseCache.has(fixture)) {
2111
- return scopedFixturePromiseCache.get(fixture);
2112
- }
2113
- if (!cleanupFnArrayMap.has(fixtureContext)) {
2114
- cleanupFnArrayMap.set(fixtureContext, []);
2115
- }
2116
- const cleanupFnFileArray = cleanupFnArrayMap.get(fixtureContext);
2117
- const promise = resolveFixtureFunction(fixture.value, fixture.name, fixture.scope === "file" ? {
2118
- ...workerContext,
2119
- ...fileContext
2120
- } : fixtureContext, cleanupFnFileArray).then((value) => {
2121
- fixtureContext[fixture.name] = value;
2122
- scopedFixturePromiseCache.delete(fixture);
2123
- return value;
2124
- });
2125
- scopedFixturePromiseCache.set(fixture, promise);
2126
- return promise;
2127
- }
2128
- async function resolveFixtureFunction(fixtureFn, fixtureName, context, cleanupFnArray) {
2129
- const useFnArgPromise = createDefer();
2130
- const stackTraceError = FIXTURE_STACK_TRACE_KEY in fixtureFn && fixtureFn[FIXTURE_STACK_TRACE_KEY] instanceof Error ? fixtureFn[FIXTURE_STACK_TRACE_KEY] : void 0;
2131
- let isUseFnArgResolved = false;
2132
- const fixtureReturn = fixtureFn(context, async (useFnArg) => {
2133
- isUseFnArgResolved = true;
2134
- useFnArgPromise.resolve(useFnArg);
2135
- const useReturnPromise = createDefer();
2136
- cleanupFnArray.push(async () => {
2137
- useReturnPromise.resolve();
2138
- await fixtureReturn;
2139
- });
2140
- await useReturnPromise;
2141
- }).then(() => {
2142
- if (!isUseFnArgResolved) {
2143
- const error = new Error(`Fixture "${fixtureName}" returned without calling "use". Make sure to call "use" in every code path of the fixture function.`);
2144
- if (stackTraceError == null ? void 0 : stackTraceError.stack) {
2145
- error.stack = error.message + stackTraceError.stack.replace(stackTraceError.message, "");
2146
- }
2147
- useFnArgPromise.reject(error);
2148
- }
2149
- }).catch((e) => {
2150
- if (!isUseFnArgResolved) {
2151
- useFnArgPromise.reject(e);
2152
- return;
2153
- }
2154
- throw e;
2155
- });
2156
- return useFnArgPromise;
2157
- }
2158
- function resolveDeps(usedFixtures, registrations, depSet = /* @__PURE__ */ new Set(), pendingFixtures = []) {
2159
- usedFixtures.forEach((fixture) => {
2160
- if (pendingFixtures.includes(fixture)) {
2161
- return;
2162
- }
2163
- if (!isFixtureFunction(fixture.value) || !fixture.deps) {
2164
- pendingFixtures.push(fixture);
2165
- return;
2166
- }
2167
- if (depSet.has(fixture)) {
2168
- if (fixture.parent) {
2169
- fixture = fixture.parent;
2170
- } else {
2171
- throw new Error(`Circular fixture dependency detected: ${fixture.name} <- ${[...depSet].reverse().map((d2) => d2.name).join(" <- ")}`);
2172
- }
2173
- }
2174
- depSet.add(fixture);
2175
- resolveDeps([...fixture.deps].map((n) => n === fixture.name ? fixture.parent : registrations.get(n)).filter((n) => !!n), registrations, depSet, pendingFixtures);
2176
- pendingFixtures.push(fixture);
2177
- depSet.clear();
2178
- });
2179
- return pendingFixtures;
2180
- }
2181
- function validateSuiteHook(fn, hook, suiteError) {
2182
- var _a;
2183
- const usedProps = getUsedProps(fn, {
2184
- sourceError: suiteError,
2185
- suiteHook: hook
2186
- });
2187
- if (usedProps.size) {
2188
- const error = new FixtureAccessError(`The ${hook} hook uses fixtures "${[...usedProps].join('", "')}", but has no access to context. Did you forget to call it as "test.${hook}()" instead of "${hook}()"?
2189
- If you used internal "suite" task as the first argument previously, access it in the second argument instead. See https://vitest.dev/guide/test-context#suite-level-hooks`);
2190
- if (suiteError) {
2191
- error.stack = (_a = suiteError.stack) == null ? void 0 : _a.replace(suiteError.message, error.message);
2192
- }
2193
- throw error;
2194
- }
2195
- }
2196
- const kPropsSymbol = Symbol("$vitest:fixture-props");
2197
- const kPropNamesSymbol = Symbol("$vitest:fixture-prop-names");
2198
- function configureProps(fn, options) {
2199
- Object.defineProperty(fn, kPropsSymbol, {
2200
- value: options,
2201
- enumerable: false
2202
- });
2203
- }
2204
- function memoProps(fn, props) {
2205
- fn[kPropNamesSymbol] = props;
2206
- return props;
2207
- }
2208
- function getUsedProps(fn, { sourceError, suiteHook } = {}) {
2209
- var _a, _b;
2210
- if (kPropNamesSymbol in fn) {
2211
- return fn[kPropNamesSymbol];
2212
- }
2213
- const { index: fixturesIndex = 0, original: implementation = fn } = kPropsSymbol in fn ? fn[kPropsSymbol] : {};
2214
- let fnString = filterOutComments(implementation.toString());
2215
- if (/__async\((?:this|null), (?:null|arguments|\[[_0-9, ]*\]), function\*/.test(fnString)) {
2216
- fnString = fnString.split(/__async\((?:this|null),/)[1];
2217
- }
2218
- const match = fnString.match(/[^(]*\(([^)]*)/);
2219
- if (!match) {
2220
- return memoProps(fn, /* @__PURE__ */ new Set());
2221
- }
2222
- const args = splitByComma(match[1]);
2223
- if (!args.length) {
2224
- return memoProps(fn, /* @__PURE__ */ new Set());
2225
- }
2226
- const fixturesArgument = args[fixturesIndex];
2227
- if (!fixturesArgument) {
2228
- return memoProps(fn, /* @__PURE__ */ new Set());
2229
- }
2230
- if (!(fixturesArgument[0] === "{" && fixturesArgument.endsWith("}"))) {
2231
- const ordinalArgument = ordinal(fixturesIndex + 1);
2232
- const error = new FixtureParseError(`The ${ordinalArgument} argument inside a fixture must use object destructuring pattern, e.g. ({ task } => {}). Instead, received "${fixturesArgument}".${suiteHook ? ` If you used internal "suite" task as the ${ordinalArgument} argument previously, access it in the ${ordinal(fixturesIndex + 2)} argument instead.` : ""}`);
2233
- if (sourceError) {
2234
- error.stack = (_a = sourceError.stack) == null ? void 0 : _a.replace(sourceError.message, error.message);
2235
- }
2236
- throw error;
2237
- }
2238
- const _first = fixturesArgument.slice(1, -1).replace(/\s/g, "");
2239
- const props = splitByComma(_first).map((prop) => {
2240
- return prop.replace(/:.*|=.*/g, "");
2241
- });
2242
- const last = props.at(-1);
2243
- if (last && last.startsWith("...")) {
2244
- const error = new FixtureParseError(`Rest parameters are not supported in fixtures, received "${last}".`);
2245
- if (sourceError) {
2246
- error.stack = (_b = sourceError.stack) == null ? void 0 : _b.replace(sourceError.message, error.message);
2247
- }
2248
- throw error;
2249
- }
2250
- return memoProps(fn, new Set(props));
2251
- }
2252
- function splitByComma(s) {
2253
- const result = [];
2254
- const stack = [];
2255
- let start = 0;
2256
- for (let i2 = 0; i2 < s.length; i2++) {
2257
- if (s[i2] === "{" || s[i2] === "[") {
2258
- stack.push(s[i2] === "{" ? "}" : "]");
2259
- } else if (s[i2] === stack.at(-1)) {
2260
- stack.pop();
2261
- } else if (!stack.length && s[i2] === ",") {
2262
- const token = s.substring(start, i2).trim();
2263
- if (token) {
2264
- result.push(token);
2265
- }
2266
- start = i2 + 1;
2267
- }
2268
- }
2269
- const lastToken = s.substring(start).trim();
2270
- if (lastToken) {
2271
- result.push(lastToken);
2272
- }
2273
- return result;
2274
- }
2275
- const kChainableContext = Symbol("kChainableContext");
2276
- function getChainableContext(chainable) {
2277
- return chainable == null ? void 0 : chainable[kChainableContext];
2278
- }
2279
- function createChainable(keys, fn, context) {
2280
- function create(context2) {
2281
- const chain2 = function(...args) {
2282
- return fn.apply(context2, args);
2283
- };
2284
- Object.assign(chain2, fn);
2285
- Object.defineProperty(chain2, kChainableContext, {
2286
- value: {
2287
- withContext: () => chain2.bind(context2),
2288
- getFixtures: () => context2.fixtures,
2289
- setContext: (key, value) => {
2290
- context2[key] = value;
2291
- },
2292
- mergeContext: (ctx) => {
2293
- Object.assign(context2, ctx);
2294
- }
2295
- },
2296
- enumerable: false
2297
- });
2298
- for (const key of keys) {
2299
- Object.defineProperty(chain2, key, { get() {
2300
- return create({
2301
- ...context2,
2302
- [key]: true
2303
- });
2304
- } });
2305
- }
2306
- return chain2;
2307
- }
2308
- const chain = create(context ?? {});
2309
- Object.defineProperty(chain, "fn", {
2310
- value: fn,
2311
- enumerable: false
2312
- });
2313
- return chain;
2314
- }
2315
- function getDefaultHookTimeout() {
2316
- return getRunner().config.hookTimeout;
2317
- }
2318
- const CLEANUP_TIMEOUT_KEY = Symbol.for("VITEST_CLEANUP_TIMEOUT");
2319
- const CLEANUP_STACK_TRACE_KEY = Symbol.for("VITEST_CLEANUP_STACK_TRACE");
2320
- const AROUND_TIMEOUT_KEY = Symbol.for("VITEST_AROUND_TIMEOUT");
2321
- const AROUND_STACK_TRACE_KEY = Symbol.for("VITEST_AROUND_STACK_TRACE");
2322
- function beforeAll(fn, timeout = getDefaultHookTimeout()) {
2323
- assertTypes(fn, '"beforeAll" callback', ["function"]);
2324
- const stackTraceError = new Error("STACK_TRACE_ERROR");
2325
- const context = getChainableContext(this);
2326
- return getCurrentSuite().on("beforeAll", Object.assign(withTimeout(withSuiteFixtures("beforeAll", fn, context, stackTraceError), timeout, true, stackTraceError), {
2327
- [CLEANUP_TIMEOUT_KEY]: timeout,
2328
- [CLEANUP_STACK_TRACE_KEY]: stackTraceError
2329
- }));
2330
- }
2331
- function afterAll(fn, timeout) {
2332
- assertTypes(fn, '"afterAll" callback', ["function"]);
2333
- const context = getChainableContext(this);
2334
- const stackTraceError = new Error("STACK_TRACE_ERROR");
2335
- return getCurrentSuite().on("afterAll", withTimeout(withSuiteFixtures("afterAll", fn, context, stackTraceError), timeout ?? getDefaultHookTimeout(), true, stackTraceError));
2336
- }
2337
- function beforeEach(fn, timeout = getDefaultHookTimeout()) {
2338
- assertTypes(fn, '"beforeEach" callback', ["function"]);
2339
- const stackTraceError = new Error("STACK_TRACE_ERROR");
2340
- const wrapper = (context, suite2) => {
2341
- const fixtureResolver = withFixtures(fn, { suite: suite2 });
2342
- return fixtureResolver(context);
2343
- };
2344
- return getCurrentSuite().on("beforeEach", Object.assign(withTimeout(wrapper, timeout ?? getDefaultHookTimeout(), true, stackTraceError, abortIfTimeout), {
2345
- [CLEANUP_TIMEOUT_KEY]: timeout,
2346
- [CLEANUP_STACK_TRACE_KEY]: stackTraceError
2347
- }));
2348
- }
2349
- function afterEach(fn, timeout) {
2350
- assertTypes(fn, '"afterEach" callback', ["function"]);
2351
- const wrapper = (context, suite2) => {
2352
- const fixtureResolver = withFixtures(fn, { suite: suite2 });
2353
- return fixtureResolver(context);
2354
- };
2355
- return getCurrentSuite().on("afterEach", withTimeout(wrapper, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
2356
- }
2357
- function aroundAll(fn, timeout) {
2358
- assertTypes(fn, '"aroundAll" callback', ["function"]);
2359
- const stackTraceError = new Error("STACK_TRACE_ERROR");
2360
- const resolvedTimeout = timeout ?? getDefaultHookTimeout();
2361
- const context = getChainableContext(this);
2362
- return getCurrentSuite().on("aroundAll", Object.assign(withSuiteFixtures("aroundAll", fn, context, stackTraceError, 1), {
2363
- [AROUND_TIMEOUT_KEY]: resolvedTimeout,
2364
- [AROUND_STACK_TRACE_KEY]: stackTraceError
2365
- }));
2366
- }
2367
- function aroundEach(fn, timeout) {
2368
- assertTypes(fn, '"aroundEach" callback', ["function"]);
2369
- const stackTraceError = new Error("STACK_TRACE_ERROR");
2370
- const resolvedTimeout = timeout ?? getDefaultHookTimeout();
2371
- const wrapper = (runTest, context, suite2) => {
2372
- const innerFn = (ctx) => fn(runTest, ctx, suite2);
2373
- configureProps(innerFn, {
2374
- index: 1,
2375
- original: fn
2376
- });
2377
- const fixtureResolver = withFixtures(innerFn, { suite: suite2 });
2378
- return fixtureResolver(context);
2379
- };
2380
- return getCurrentSuite().on("aroundEach", Object.assign(wrapper, {
2381
- [AROUND_TIMEOUT_KEY]: resolvedTimeout,
2382
- [AROUND_STACK_TRACE_KEY]: stackTraceError
2383
- }));
2384
- }
2385
- function withSuiteFixtures(suiteHook, fn, context, stackTraceError, contextIndex = 0) {
2386
- return (...args) => {
2387
- const suite2 = args.at(-1);
2388
- const prefix = args.slice(0, -1);
2389
- const wrapper = (ctx) => fn(...prefix, ctx, suite2);
2390
- configureProps(wrapper, {
2391
- index: contextIndex,
2392
- original: fn
2393
- });
2394
- const fixtures = context == null ? void 0 : context.getFixtures();
2395
- const fileContext = fixtures == null ? void 0 : fixtures.getFileContext(suite2.file);
2396
- const fixtured = withFixtures(wrapper, {
2397
- suiteHook,
2398
- fixtures,
2399
- context: fileContext,
2400
- stackTraceError
2401
- });
2402
- return fixtured();
2403
- };
2404
- }
2405
- // @__NO_SIDE_EFFECTS__
2406
- function generateHash(str) {
2407
- let hash = 0;
2408
- if (str.length === 0) {
2409
- return `${hash}`;
2410
- }
2411
- for (let i2 = 0; i2 < str.length; i2++) {
2412
- const char = str.charCodeAt(i2);
2413
- hash = (hash << 5) - hash + char;
2414
- hash = hash & hash;
2415
- }
2416
- return `${hash}`;
2417
- }
2418
- // @__NO_SIDE_EFFECTS__
2419
- function generateFileHash(file, projectName) {
2420
- return /* @__PURE__ */ generateHash(`${file}${projectName || ""}`);
2421
- }
2422
- function findTestFileStackTrace(testFilePath, error) {
2423
- const lines = error.split("\n").slice(1);
2424
- for (const line of lines) {
2425
- const stack = parseSingleStack(line);
2426
- if (stack && stack.file === testFilePath) {
2427
- return stack;
2428
- }
2429
- }
2430
- }
2431
- function validateTags(config, tags) {
2432
- if (!config.strictTags) {
2433
- return;
2434
- }
2435
- const availableTags = new Set(config.tags.map((tag) => tag.name));
2436
- for (const tag of tags) {
2437
- if (!availableTags.has(tag)) {
2438
- throw createNoTagsError(config.tags, tag);
2439
- }
2440
- }
2441
- }
2442
- function createNoTagsError(availableTags, tag, prefix = "tag") {
2443
- if (!availableTags.length) {
2444
- throw new Error(`The Vitest config does't define any "tags", cannot apply "${tag}" ${prefix} for this test. See: https://vitest.dev/guide/test-tags`);
2445
- }
2446
- throw new Error(`The ${prefix} "${tag}" is not defined in the configuration. Available tags are:
2447
- ${availableTags.map((t) => `- ${t.name}${t.description ? `: ${t.description}` : ""}`).join("\n")}`);
2448
- }
2449
- function getNames(task) {
2450
- const names = [task.name];
2451
- let current = task;
2452
- while (current == null ? void 0 : current.suite) {
2453
- current = current.suite;
2454
- if (current == null ? void 0 : current.name) {
2455
- names.unshift(current.name);
2456
- }
2457
- }
2458
- if (current !== task.file) {
2459
- names.unshift(task.file.name);
2460
- }
2461
- return names;
2462
- }
2463
- function getTestName(task, separator = " > ") {
2464
- return getNames(task).slice(1).join(separator);
2465
- }
2466
- function createTaskName(names, separator = " > ") {
2467
- return names.filter((name) => name !== void 0).join(separator);
2468
- }
2469
- const suite = createSuite();
2470
- createTest(function(name, optionsOrFn, optionsOrTest) {
2471
- getCurrentSuite().test.fn.call(this, formatName(name), optionsOrFn, optionsOrTest);
2472
- });
2473
- let runner;
2474
- let defaultSuite;
2475
- let currentTestFilepath;
2476
- function assert(condition, message) {
2477
- if (!condition) {
2478
- throw new Error(`Vitest failed to find ${message}. One of the following is possible:
2479
- - "vitest" is imported directly without running "vitest" command
2480
- - "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)
2481
- - "vitest" is imported inside Vite / Vitest config file
2482
- - Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues
2483
- `);
2484
- }
2485
- }
2486
- function getRunner() {
2487
- assert(runner, "the runner");
2488
- return runner;
2489
- }
2490
- function getCurrentSuite() {
2491
- const currentSuite = collectorContext.currentSuite || defaultSuite;
2492
- assert(currentSuite, "the current suite");
2493
- return currentSuite;
2494
- }
2495
- function createSuiteHooks() {
2496
- return {
2497
- beforeAll: [],
2498
- afterAll: [],
2499
- beforeEach: [],
2500
- afterEach: [],
2501
- aroundEach: [],
2502
- aroundAll: []
2503
- };
2504
- }
2505
- const POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
2506
- function parseArguments(optionsOrFn, timeoutOrTest) {
2507
- if (timeoutOrTest != null && typeof timeoutOrTest === "object") {
2508
- throw new TypeError(`Signature "test(name, fn, { ... })" was deprecated in Vitest 3 and removed in Vitest 4. Please, provide options as a second argument instead.`);
2509
- }
2510
- let options = {};
2511
- let fn;
2512
- if (typeof timeoutOrTest === "number") {
2513
- options = { timeout: timeoutOrTest };
2514
- } else if (typeof optionsOrFn === "object") {
2515
- options = optionsOrFn;
2516
- }
2517
- if (typeof optionsOrFn === "function") {
2518
- if (typeof timeoutOrTest === "function") {
2519
- throw new TypeError("Cannot use two functions as arguments. Please use the second argument for options.");
2520
- }
2521
- fn = optionsOrFn;
2522
- } else if (typeof timeoutOrTest === "function") {
2523
- fn = timeoutOrTest;
2524
- }
2525
- return {
2526
- options,
2527
- handler: fn
2528
- };
2529
- }
2530
- function createSuiteCollector(name, factory = () => {
2531
- }, mode, each, suiteOptions) {
2532
- const tasks = [];
2533
- let suite2;
2534
- initSuite();
2535
- const task = function(name2 = "", options = {}) {
2536
- var _a, _b, _c, _d, _e;
2537
- const currentSuite = (_a = collectorContext.currentSuite) == null ? void 0 : _a.suite;
2538
- const parentTask = currentSuite ?? ((_b = collectorContext.currentSuite) == null ? void 0 : _b.file);
2539
- const parentTags = (parentTask == null ? void 0 : parentTask.tags) || [];
2540
- const testTags = unique([...parentTags, ...toArray(options.tags)]);
2541
- const tagsOptions = testTags.map((tag) => {
2542
- var _a2;
2543
- const tagDefinition = (_a2 = runner.config.tags) == null ? void 0 : _a2.find((t) => t.name === tag);
2544
- if (!tagDefinition && runner.config.strictTags) {
2545
- throw createNoTagsError(runner.config.tags, tag);
2546
- }
2547
- return tagDefinition;
2548
- }).filter((r) => r != null).sort((tag1, tag2) => (tag2.priority ?? POSITIVE_INFINITY) - (tag1.priority ?? POSITIVE_INFINITY)).reduce((acc, tag) => {
2549
- const { name: name3, description, priority, meta, ...options2 } = tag;
2550
- Object.assign(acc, options2);
2551
- if (meta) {
2552
- acc.meta = Object.assign(acc.meta ?? /* @__PURE__ */ Object.create(null), meta);
2553
- }
2554
- return acc;
2555
- }, {});
2556
- const testOwnMeta = options.meta;
2557
- options = {
2558
- ...tagsOptions,
2559
- ...options
2560
- };
2561
- const timeout = options.timeout ?? runner.config.testTimeout;
2562
- const parentMeta = currentSuite == null ? void 0 : currentSuite.meta;
2563
- const tagMeta = tagsOptions.meta;
2564
- const testMeta = /* @__PURE__ */ Object.create(null);
2565
- if (tagMeta) {
2566
- Object.assign(testMeta, tagMeta);
2567
- }
2568
- if (parentMeta) {
2569
- Object.assign(testMeta, parentMeta);
2570
- }
2571
- if (testOwnMeta) {
2572
- Object.assign(testMeta, testOwnMeta);
2573
- }
2574
- const task2 = {
2575
- id: "",
2576
- name: name2,
2577
- fullName: createTaskName([(currentSuite == null ? void 0 : currentSuite.fullName) ?? ((_d = (_c = collectorContext.currentSuite) == null ? void 0 : _c.file) == null ? void 0 : _d.fullName), name2]),
2578
- fullTestName: createTaskName([currentSuite == null ? void 0 : currentSuite.fullTestName, name2]),
2579
- suite: currentSuite,
2580
- each: options.each,
2581
- fails: options.fails,
2582
- context: void 0,
2583
- type: "test",
2584
- file: (currentSuite == null ? void 0 : currentSuite.file) ?? ((_e = collectorContext.currentSuite) == null ? void 0 : _e.file),
2585
- timeout,
2586
- retry: options.retry ?? runner.config.retry,
2587
- repeats: options.repeats,
2588
- mode: options.only ? "only" : options.skip ? "skip" : options.todo ? "todo" : "run",
2589
- meta: testMeta,
2590
- annotations: [],
2591
- artifacts: [],
2592
- tags: testTags
2593
- };
2594
- const handler = options.handler;
2595
- if (task2.mode === "run" && !handler) {
2596
- task2.mode = "todo";
2597
- }
2598
- if (options.concurrent || !options.sequential && runner.config.sequence.concurrent) {
2599
- task2.concurrent = true;
2600
- }
2601
- task2.shuffle = suiteOptions == null ? void 0 : suiteOptions.shuffle;
2602
- const context = createTestContext(task2, runner);
2603
- Object.defineProperty(task2, "context", {
2604
- value: context,
2605
- enumerable: false
2606
- });
2607
- setTestFixture(context, options.fixtures ?? new TestFixtures());
2608
- const limit = Error.stackTraceLimit;
2609
- Error.stackTraceLimit = 10;
2610
- const stackTraceError = new Error("STACK_TRACE_ERROR");
2611
- Error.stackTraceLimit = limit;
2612
- if (handler) {
2613
- setFn(task2, withTimeout(withCancel(withAwaitAsyncAssertions(withFixtures(handler, { context }), task2), task2.context.signal), timeout, false, stackTraceError, (_, error) => abortIfTimeout([context], error)));
2614
- }
2615
- if (runner.config.includeTaskLocation) {
2616
- const error = stackTraceError.stack;
2617
- const stack = findTestFileStackTrace(currentTestFilepath, error);
2618
- if (stack) {
2619
- task2.location = {
2620
- line: stack.line,
2621
- column: stack.column
2622
- };
2623
- }
2624
- }
2625
- tasks.push(task2);
2626
- return task2;
2627
- };
2628
- const test2 = createTest(function(name2, optionsOrFn, timeoutOrTest) {
2629
- let { options, handler } = parseArguments(optionsOrFn, timeoutOrTest);
2630
- if (typeof suiteOptions === "object") {
2631
- options = Object.assign({}, suiteOptions, options);
2632
- }
2633
- const concurrent = this.concurrent ?? (!this.sequential && (options == null ? void 0 : options.concurrent));
2634
- if (options.concurrent != null && concurrent != null) {
2635
- options.concurrent = concurrent;
2636
- }
2637
- const sequential = this.sequential ?? (!this.concurrent && (options == null ? void 0 : options.sequential));
2638
- if (options.sequential != null && sequential != null) {
2639
- options.sequential = sequential;
2640
- }
2641
- const test3 = task(formatName(name2), {
2642
- ...this,
2643
- ...options,
2644
- handler
2645
- });
2646
- test3.type = "test";
2647
- });
2648
- const collector = {
2649
- type: "collector",
2650
- name,
2651
- mode,
2652
- suite: suite2,
2653
- options: suiteOptions,
2654
- test: test2,
2655
- file: suite2.file,
2656
- tasks,
2657
- collect,
2658
- task,
2659
- clear,
2660
- on: addHook
2661
- };
2662
- function addHook(name2, ...fn) {
2663
- getHooks(suite2)[name2].push(...fn);
2664
- }
2665
- function initSuite(includeLocation) {
2666
- var _a, _b, _c, _d, _e;
2667
- if (typeof suiteOptions === "number") {
2668
- suiteOptions = { timeout: suiteOptions };
2669
- }
2670
- const currentSuite = (_a = collectorContext.currentSuite) == null ? void 0 : _a.suite;
2671
- const parentTask = currentSuite ?? ((_b = collectorContext.currentSuite) == null ? void 0 : _b.file);
2672
- const suiteTags = toArray(suiteOptions == null ? void 0 : suiteOptions.tags);
2673
- validateTags(runner.config, suiteTags);
2674
- suite2 = {
2675
- id: "",
2676
- type: "suite",
2677
- name,
2678
- fullName: createTaskName([(currentSuite == null ? void 0 : currentSuite.fullName) ?? ((_d = (_c = collectorContext.currentSuite) == null ? void 0 : _c.file) == null ? void 0 : _d.fullName), name]),
2679
- fullTestName: createTaskName([currentSuite == null ? void 0 : currentSuite.fullTestName, name]),
2680
- suite: currentSuite,
2681
- mode,
2682
- each,
2683
- file: (currentSuite == null ? void 0 : currentSuite.file) ?? ((_e = collectorContext.currentSuite) == null ? void 0 : _e.file),
2684
- shuffle: suiteOptions == null ? void 0 : suiteOptions.shuffle,
2685
- tasks: [],
2686
- meta: (suiteOptions == null ? void 0 : suiteOptions.meta) ?? /* @__PURE__ */ Object.create(null),
2687
- concurrent: suiteOptions == null ? void 0 : suiteOptions.concurrent,
2688
- tags: unique([...(parentTask == null ? void 0 : parentTask.tags) || [], ...suiteTags])
2689
- };
2690
- setHooks(suite2, createSuiteHooks());
2691
- }
2692
- function clear() {
2693
- tasks.length = 0;
2694
- initSuite();
2695
- }
2696
- async function collect(file) {
2697
- if (!file) {
2698
- throw new TypeError("File is required to collect tasks.");
2699
- }
2700
- if (factory) {
2701
- await runWithSuite(collector, () => factory(test2));
2702
- }
2703
- const allChildren = [];
2704
- for (const i2 of tasks) {
2705
- allChildren.push(i2.type === "collector" ? await i2.collect(file) : i2);
2706
- }
2707
- suite2.tasks = allChildren;
2708
- return suite2;
2709
- }
2710
- collectTask(collector);
2711
- return collector;
2712
- }
2713
- function withAwaitAsyncAssertions(fn, task) {
2714
- return (async (...args) => {
2715
- const fnResult = await fn(...args);
2716
- if (task.promises) {
2717
- const result = await Promise.allSettled(task.promises);
2718
- const errors = result.map((r) => r.status === "rejected" ? r.reason : void 0).filter(Boolean);
2719
- if (errors.length) {
2720
- throw errors;
2721
- }
2722
- }
2723
- return fnResult;
2724
- });
2725
- }
2726
- function createSuite() {
2727
- function suiteFn(name, factoryOrOptions, optionsOrFactory) {
2728
- var _a;
2729
- const currentSuite = collectorContext.currentSuite || defaultSuite;
2730
- let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
2731
- const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
2732
- const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
2733
- const { meta: parentMeta, ...parentOptions } = (currentSuite == null ? void 0 : currentSuite.options) || {};
2734
- options = {
2735
- ...parentOptions,
2736
- ...options
2737
- };
2738
- const shuffle = this.shuffle ?? options.shuffle ?? ((_a = currentSuite == null ? void 0 : currentSuite.options) == null ? void 0 : _a.shuffle) ?? (runner == null ? void 0 : runner.config.sequence.shuffle);
2739
- if (shuffle != null) {
2740
- options.shuffle = shuffle;
2741
- }
2742
- let mode = this.only ?? options.only ? "only" : this.skip ?? options.skip ? "skip" : this.todo ?? options.todo ? "todo" : "run";
2743
- if (mode === "run" && !factory) {
2744
- mode = "todo";
2745
- }
2746
- const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
2747
- const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
2748
- if (isConcurrent != null) {
2749
- options.concurrent = isConcurrent && !isSequential;
2750
- }
2751
- if (isSequential != null) {
2752
- options.sequential = isSequential && !isConcurrent;
2753
- }
2754
- if (parentMeta) {
2755
- options.meta = Object.assign(/* @__PURE__ */ Object.create(null), parentMeta, options.meta);
2756
- }
2757
- return createSuiteCollector(formatName(name), factory, mode, this.each, options);
2758
- }
2759
- suiteFn.each = function(cases, ...args) {
2760
- const context = getChainableContext(this);
2761
- const suite2 = context.withContext();
2762
- context.setContext("each", true);
2763
- if (Array.isArray(cases) && args.length) {
2764
- cases = formatTemplateString(cases, args);
2765
- }
2766
- return (name, optionsOrFn, fnOrOptions) => {
2767
- const _name = formatName(name);
2768
- const arrayOnlyCases = cases.every(Array.isArray);
2769
- const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
2770
- const fnFirst = typeof optionsOrFn === "function";
2771
- cases.forEach((i2, idx) => {
2772
- const items = Array.isArray(i2) ? i2 : [i2];
2773
- if (fnFirst) {
2774
- if (arrayOnlyCases) {
2775
- suite2(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
2776
- } else {
2777
- suite2(formatTitle(_name, items, idx), handler ? () => handler(i2) : void 0, options.timeout);
2778
- }
2779
- } else {
2780
- if (arrayOnlyCases) {
2781
- suite2(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
2782
- } else {
2783
- suite2(formatTitle(_name, items, idx), options, handler ? () => handler(i2) : void 0);
2784
- }
2785
- }
2786
- });
2787
- context.setContext("each", void 0);
2788
- };
2789
- };
2790
- suiteFn.for = function(cases, ...args) {
2791
- if (Array.isArray(cases) && args.length) {
2792
- cases = formatTemplateString(cases, args);
2793
- }
2794
- return (name, optionsOrFn, fnOrOptions) => {
2795
- const name_ = formatName(name);
2796
- const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
2797
- cases.forEach((item, idx) => {
2798
- suite(formatTitle(name_, toArray(item), idx), options, handler ? () => handler(item) : void 0);
2799
- });
2800
- };
2801
- };
2802
- suiteFn.skipIf = (condition) => condition ? suite.skip : suite;
2803
- suiteFn.runIf = (condition) => condition ? suite : suite.skip;
2804
- return createChainable([
2805
- "concurrent",
2806
- "sequential",
2807
- "shuffle",
2808
- "skip",
2809
- "only",
2810
- "todo"
2811
- ], suiteFn);
2812
- }
2813
- function createTaskCollector(fn) {
2814
- const taskFn = fn;
2815
- taskFn.each = function(cases, ...args) {
2816
- const context = getChainableContext(this);
2817
- const test2 = context.withContext();
2818
- context.setContext("each", true);
2819
- if (Array.isArray(cases) && args.length) {
2820
- cases = formatTemplateString(cases, args);
2821
- }
2822
- return (name, optionsOrFn, fnOrOptions) => {
2823
- const _name = formatName(name);
2824
- const arrayOnlyCases = cases.every(Array.isArray);
2825
- const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
2826
- const fnFirst = typeof optionsOrFn === "function";
2827
- cases.forEach((i2, idx) => {
2828
- const items = Array.isArray(i2) ? i2 : [i2];
2829
- if (fnFirst) {
2830
- if (arrayOnlyCases) {
2831
- test2(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
2832
- } else {
2833
- test2(formatTitle(_name, items, idx), handler ? () => handler(i2) : void 0, options.timeout);
2834
- }
2835
- } else {
2836
- if (arrayOnlyCases) {
2837
- test2(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
2838
- } else {
2839
- test2(formatTitle(_name, items, idx), options, handler ? () => handler(i2) : void 0);
2840
- }
2841
- }
2842
- });
2843
- context.setContext("each", void 0);
2844
- };
2845
- };
2846
- taskFn.for = function(cases, ...args) {
2847
- const context = getChainableContext(this);
2848
- const test2 = context.withContext();
2849
- if (Array.isArray(cases) && args.length) {
2850
- cases = formatTemplateString(cases, args);
2851
- }
2852
- return (name, optionsOrFn, fnOrOptions) => {
2853
- const _name = formatName(name);
2854
- const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
2855
- cases.forEach((item, idx) => {
2856
- const handlerWrapper = handler ? (ctx) => handler(item, ctx) : void 0;
2857
- if (handlerWrapper) {
2858
- configureProps(handlerWrapper, {
2859
- index: 1,
2860
- original: handler
2861
- });
2862
- }
2863
- test2(formatTitle(_name, toArray(item), idx), options, handlerWrapper);
2864
- });
2865
- };
2866
- };
2867
- taskFn.skipIf = function(condition) {
2868
- return condition ? this.skip : this;
2869
- };
2870
- taskFn.runIf = function(condition) {
2871
- return condition ? this : this.skip;
2872
- };
2873
- function parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn) {
2874
- if (typeof fixturesOrName !== "string") {
2875
- return fixturesOrName;
2876
- }
2877
- const fixtureName = fixturesOrName;
2878
- let fixtureOptions;
2879
- let fixtureValue;
2880
- if (maybeFn !== void 0) {
2881
- fixtureOptions = optionsOrFn;
2882
- fixtureValue = maybeFn;
2883
- } else {
2884
- if (optionsOrFn !== null && typeof optionsOrFn === "object" && !Array.isArray(optionsOrFn) && TestFixtures.isFixtureOptions(optionsOrFn)) {
2885
- fixtureOptions = optionsOrFn;
2886
- fixtureValue = {};
2887
- } else {
2888
- fixtureOptions = void 0;
2889
- fixtureValue = optionsOrFn;
2890
- }
2891
- }
2892
- if (typeof fixtureValue === "function") {
2893
- const builderFn = fixtureValue;
2894
- const fixture = async (ctx, use) => {
2895
- let cleanup;
2896
- const onCleanup = (fn2) => {
2897
- if (cleanup !== void 0) {
2898
- throw new Error(`onCleanup can only be called once per fixture. Define separate fixtures if you need multiple cleanup functions.`);
2899
- }
2900
- cleanup = fn2;
2901
- };
2902
- const value = await builderFn(ctx, { onCleanup });
2903
- await use(value);
2904
- if (cleanup) {
2905
- await cleanup();
2906
- }
2907
- };
2908
- configureProps(fixture, { original: builderFn });
2909
- if (fixtureOptions) {
2910
- return { [fixtureName]: [fixture, fixtureOptions] };
2911
- }
2912
- return { [fixtureName]: fixture };
2913
- }
2914
- if (fixtureOptions) {
2915
- return { [fixtureName]: [fixtureValue, fixtureOptions] };
2916
- }
2917
- return { [fixtureName]: fixtureValue };
2918
- }
2919
- taskFn.override = function(fixturesOrName, optionsOrFn, maybeFn) {
2920
- const userFixtures = parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn);
2921
- getChainableContext(this).getFixtures().override(runner, userFixtures);
2922
- return this;
2923
- };
2924
- taskFn.scoped = function(fixtures) {
2925
- console.warn(`test.scoped() is deprecated and will be removed in future versions. Please use test.override() instead.`);
2926
- return this.override(fixtures);
2927
- };
2928
- taskFn.extend = function(fixturesOrName, optionsOrFn, maybeFn) {
2929
- const userFixtures = parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn);
2930
- const fixtures = getChainableContext(this).getFixtures().extend(runner, userFixtures);
2931
- const _test2 = createTest(function(name, optionsOrFn2, optionsOrTest) {
2932
- fn.call(this, formatName(name), optionsOrFn2, optionsOrTest);
2933
- });
2934
- getChainableContext(_test2).mergeContext({ fixtures });
2935
- return _test2;
2936
- };
2937
- taskFn.describe = suite;
2938
- taskFn.suite = suite;
2939
- taskFn.beforeEach = beforeEach;
2940
- taskFn.afterEach = afterEach;
2941
- taskFn.beforeAll = beforeAll;
2942
- taskFn.afterAll = afterAll;
2943
- taskFn.aroundEach = aroundEach;
2944
- taskFn.aroundAll = aroundAll;
2945
- const _test = createChainable([
2946
- "concurrent",
2947
- "sequential",
2948
- "skip",
2949
- "only",
2950
- "todo",
2951
- "fails"
2952
- ], taskFn, { fixtures: new TestFixtures() });
2953
- return _test;
2954
- }
2955
- function createTest(fn) {
2956
- return createTaskCollector(fn);
2957
- }
2958
- function formatName(name) {
2959
- return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
2960
- }
2961
- function formatTitle(template, items, idx) {
2962
- if (template.includes("%#") || template.includes("%$")) {
2963
- template = template.replace(/%%/g, "__vitest_escaped_%__").replace(/%#/g, `${idx}`).replace(/%\$/g, `${idx + 1}`).replace(/__vitest_escaped_%__/g, "%%");
2964
- }
2965
- const count = template.split("%").length - 1;
2966
- if (template.includes("%f")) {
2967
- const placeholders = template.match(/%f/g) || [];
2968
- placeholders.forEach((_, i3) => {
2969
- if (isNegativeNaN(items[i3]) || Object.is(items[i3], -0)) {
2970
- let occurrence = 0;
2971
- template = template.replace(/%f/g, (match) => {
2972
- occurrence++;
2973
- return occurrence === i3 + 1 ? "-%f" : match;
2974
- });
2975
- }
2976
- });
2977
- }
2978
- const inspectOptions = { truncate: runner.config.taskTitleValueFormatTruncate };
2979
- const isObjectItem = isObject(items[0]);
2980
- function formatAttribute(s) {
2981
- return s.replace(/\$([$\w.]+)/g, (_, key) => {
2982
- const isArrayKey = /^\d+$/.test(key);
2983
- if (!isObjectItem && !isArrayKey) {
2984
- return `$${key}`;
2985
- }
2986
- const arrayElement = isArrayKey ? objectAttr(items, key) : void 0;
2987
- const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
2988
- if (typeof value === "string") {
2989
- return truncateString(value, inspectOptions.truncate);
2990
- }
2991
- return inspect(value, inspectOptions);
2992
- });
2993
- }
2994
- let output = "";
2995
- let i2 = 0;
2996
- handleRegexMatch(
2997
- template,
2998
- formatRegExp,
2999
- // format "%"
3000
- (match) => {
3001
- if (i2 < count) {
3002
- output += format([match[0], items[i2++]], inspectOptions);
3003
- } else {
3004
- output += match[0];
3005
- }
3006
- },
3007
- // format "$"
3008
- (nonMatch) => {
3009
- output += formatAttribute(nonMatch);
3010
- }
3011
- );
3012
- return output;
3013
- }
3014
- function handleRegexMatch(input, regex, onMatch, onNonMatch) {
3015
- let lastIndex = 0;
3016
- for (const m of input.matchAll(regex)) {
3017
- if (lastIndex < m.index) {
3018
- onNonMatch(input.slice(lastIndex, m.index));
3019
- }
3020
- onMatch(m);
3021
- lastIndex = m.index + m[0].length;
3022
- }
3023
- if (lastIndex < input.length) {
3024
- onNonMatch(input.slice(lastIndex));
3025
- }
3026
- }
3027
- function formatTemplateString(cases, args) {
3028
- const header = cases.join("").trim().replace(/ /g, "").split("\n").map((i2) => i2.split("|"))[0];
3029
- const res = [];
3030
- for (let i2 = 0; i2 < Math.floor(args.length / header.length); i2++) {
3031
- const oneCase = {};
3032
- for (let j = 0; j < header.length; j++) {
3033
- oneCase[header[j]] = args[i2 * header.length + j];
3034
- }
3035
- res.push(oneCase);
3036
- }
3037
- return res;
3038
- }
3039
- const now$2 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
3040
- const collectorContext = {
3041
- currentSuite: null
3042
- };
3043
- function collectTask(task) {
3044
- var _a;
3045
- (_a = collectorContext.currentSuite) == null ? void 0 : _a.tasks.push(task);
3046
- }
3047
- async function runWithSuite(suite2, fn) {
3048
- const prev = collectorContext.currentSuite;
3049
- collectorContext.currentSuite = suite2;
3050
- await fn();
3051
- collectorContext.currentSuite = prev;
3052
- }
3053
- function withTimeout(fn, timeout, isHook = false, stackTraceError, onTimeout) {
3054
- if (timeout <= 0 || timeout === Number.POSITIVE_INFINITY) {
3055
- return fn;
3056
- }
3057
- const { setTimeout, clearTimeout } = getSafeTimers();
3058
- return (function runWithTimeout(...args) {
3059
- const startTime = now$2();
3060
- const runner2 = getRunner();
3061
- runner2._currentTaskStartTime = startTime;
3062
- runner2._currentTaskTimeout = timeout;
3063
- return new Promise((resolve_, reject_) => {
3064
- var _a;
3065
- const timer = setTimeout(() => {
3066
- clearTimeout(timer);
3067
- rejectTimeoutError();
3068
- }, timeout);
3069
- (_a = timer.unref) == null ? void 0 : _a.call(timer);
3070
- function rejectTimeoutError() {
3071
- const error = makeTimeoutError(isHook, timeout, stackTraceError);
3072
- onTimeout == null ? void 0 : onTimeout(args, error);
3073
- reject_(error);
3074
- }
3075
- function resolve2(result) {
3076
- runner2._currentTaskStartTime = void 0;
3077
- runner2._currentTaskTimeout = void 0;
3078
- clearTimeout(timer);
3079
- if (now$2() - startTime >= timeout) {
3080
- rejectTimeoutError();
3081
- return;
3082
- }
3083
- resolve_(result);
3084
- }
3085
- function reject(error) {
3086
- runner2._currentTaskStartTime = void 0;
3087
- runner2._currentTaskTimeout = void 0;
3088
- clearTimeout(timer);
3089
- reject_(error);
3090
- }
3091
- try {
3092
- const result = fn(...args);
3093
- if (typeof result === "object" && result != null && typeof result.then === "function") {
3094
- result.then(resolve2, reject);
3095
- } else {
3096
- resolve2(result);
3097
- }
3098
- } catch (error) {
3099
- reject(error);
3100
- }
3101
- });
3102
- });
3103
- }
3104
- function withCancel(fn, signal) {
3105
- return (function runWithCancel(...args) {
3106
- return new Promise((resolve2, reject) => {
3107
- signal.addEventListener("abort", () => reject(signal.reason));
3108
- try {
3109
- const result = fn(...args);
3110
- if (typeof result === "object" && result != null && typeof result.then === "function") {
3111
- result.then(resolve2, reject);
3112
- } else {
3113
- resolve2(result);
3114
- }
3115
- } catch (error) {
3116
- reject(error);
3117
- }
3118
- });
3119
- });
3120
- }
3121
- const abortControllers = /* @__PURE__ */ new WeakMap();
3122
- function abortIfTimeout([context], error) {
3123
- if (context) {
3124
- abortContextSignal(context, error);
3125
- }
3126
- }
3127
- function abortContextSignal(context, error) {
3128
- const abortController = abortControllers.get(context);
3129
- abortController == null ? void 0 : abortController.abort(error);
3130
- }
3131
- function createTestContext(test2, runner2) {
3132
- var _a;
3133
- const context = function() {
3134
- throw new Error("done() callback is deprecated, use promise instead");
3135
- };
3136
- let abortController = abortControllers.get(context);
3137
- if (!abortController) {
3138
- abortController = new AbortController();
3139
- abortControllers.set(context, abortController);
3140
- }
3141
- context.signal = abortController.signal;
3142
- context.task = test2;
3143
- context.skip = (condition, note) => {
3144
- if (condition === false) {
3145
- return void 0;
3146
- }
3147
- test2.result ?? (test2.result = { state: "skip" });
3148
- test2.result.pending = true;
3149
- throw new PendingError("test is skipped; abort execution", test2, typeof condition === "string" ? condition : note);
3150
- };
3151
- context.annotate = ((message, type, attachment) => {
3152
- if (test2.result && test2.result.state !== "run") {
3153
- throw new Error(`Cannot annotate tests outside of the test run. The test "${test2.name}" finished running with the "${test2.result.state}" state already.`);
3154
- }
3155
- const annotation = {
3156
- message,
3157
- type: typeof type === "object" || type === void 0 ? "notice" : type
3158
- };
3159
- const annotationAttachment = typeof type === "object" ? type : attachment;
3160
- if (annotationAttachment) {
3161
- annotation.attachment = annotationAttachment;
3162
- manageArtifactAttachment(annotation.attachment);
3163
- }
3164
- return recordAsyncOperation(test2, recordArtifact(test2, {
3165
- type: "internal:annotation",
3166
- annotation
3167
- }).then(async ({ annotation: annotation2 }) => {
3168
- if (!runner2.onTestAnnotate) {
3169
- throw new Error(`Test runner doesn't support test annotations.`);
3170
- }
3171
- await finishSendTasksUpdate(runner2);
3172
- const resolvedAnnotation = await runner2.onTestAnnotate(test2, annotation2);
3173
- test2.annotations.push(resolvedAnnotation);
3174
- return resolvedAnnotation;
3175
- }));
3176
- });
3177
- context.onTestFailed = (handler, timeout) => {
3178
- test2.onFailed || (test2.onFailed = []);
3179
- test2.onFailed.push(withTimeout(handler, timeout ?? runner2.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
3180
- };
3181
- context.onTestFinished = (handler, timeout) => {
3182
- test2.onFinished || (test2.onFinished = []);
3183
- test2.onFinished.push(withTimeout(handler, timeout ?? runner2.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
3184
- };
3185
- return ((_a = runner2.extendTaskContext) == null ? void 0 : _a.call(runner2, context)) || context;
3186
- }
3187
- function makeTimeoutError(isHook, timeout, stackTraceError) {
3188
- const message = `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.
3189
- If this is a long-running ${isHook ? "hook" : "test"}, pass a timeout value as the last argument or configure it globally with "${isHook ? "hookTimeout" : "testTimeout"}".`;
3190
- const error = new Error(message);
3191
- if (stackTraceError == null ? void 0 : stackTraceError.stack) {
3192
- error.stack = stackTraceError.stack.replace(error.message, stackTraceError.message);
3193
- }
3194
- return error;
3195
- }
3196
- globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
3197
- globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
3198
- getSafeTimers();
3199
- const packs = /* @__PURE__ */ new Map();
3200
- const eventsPacks = [];
3201
- const pendingTasksUpdates = [];
3202
- function sendTasksUpdate(runner2) {
3203
- var _a;
3204
- if (packs.size) {
3205
- const taskPacks = Array.from(packs).map(([id, task]) => {
3206
- return [
3207
- id,
3208
- task[0],
3209
- task[1]
3210
- ];
3211
- });
3212
- const p = (_a = runner2.onTaskUpdate) == null ? void 0 : _a.call(runner2, taskPacks, eventsPacks);
3213
- if (p) {
3214
- pendingTasksUpdates.push(p);
3215
- p.then(() => pendingTasksUpdates.splice(pendingTasksUpdates.indexOf(p), 1), () => {
3216
- });
3217
- }
3218
- eventsPacks.length = 0;
3219
- packs.clear();
3220
- }
3221
- }
3222
- async function finishSendTasksUpdate(runner2) {
3223
- sendTasksUpdate(runner2);
3224
- await Promise.all(pendingTasksUpdates);
3225
- }
3226
- async function recordArtifact(task, artifact) {
3227
- const runner2 = getRunner();
3228
- const stack = findTestFileStackTrace(task.file.filepath, new Error("STACK_TRACE").stack);
3229
- if (stack) {
3230
- artifact.location = {
3231
- file: stack.file,
3232
- line: stack.line,
3233
- column: stack.column
3234
- };
3235
- if (artifact.type === "internal:annotation") {
3236
- artifact.annotation.location = artifact.location;
3237
- }
3238
- }
3239
- if (Array.isArray(artifact.attachments)) {
3240
- for (const attachment of artifact.attachments) {
3241
- manageArtifactAttachment(attachment);
3242
- }
3243
- }
3244
- if (artifact.type === "internal:annotation") {
3245
- return artifact;
3246
- }
3247
- if (!runner2.onTestArtifactRecord) {
3248
- throw new Error(`Test runner doesn't support test artifacts.`);
3249
- }
3250
- await finishSendTasksUpdate(runner2);
3251
- const resolvedArtifact = await runner2.onTestArtifactRecord(task, artifact);
3252
- task.artifacts.push(resolvedArtifact);
3253
- return resolvedArtifact;
3254
- }
3255
- const table = [];
3256
- for (let i2 = 65; i2 < 91; i2++) {
3257
- table.push(String.fromCharCode(i2));
3258
- }
3259
- for (let i2 = 97; i2 < 123; i2++) {
3260
- table.push(String.fromCharCode(i2));
3261
- }
3262
- for (let i2 = 0; i2 < 10; i2++) {
3263
- table.push(i2.toString(10));
3264
- }
3265
- table.push("+", "/");
3266
- function encodeUint8Array(bytes) {
3267
- let base64 = "";
3268
- const len = bytes.byteLength;
3269
- for (let i2 = 0; i2 < len; i2 += 3) {
3270
- if (len === i2 + 1) {
3271
- const a = (bytes[i2] & 252) >> 2;
3272
- const b2 = (bytes[i2] & 3) << 4;
3273
- base64 += table[a];
3274
- base64 += table[b2];
3275
- base64 += "==";
3276
- } else if (len === i2 + 2) {
3277
- const a = (bytes[i2] & 252) >> 2;
3278
- const b2 = (bytes[i2] & 3) << 4 | (bytes[i2 + 1] & 240) >> 4;
3279
- const c = (bytes[i2 + 1] & 15) << 2;
3280
- base64 += table[a];
3281
- base64 += table[b2];
3282
- base64 += table[c];
3283
- base64 += "=";
3284
- } else {
3285
- const a = (bytes[i2] & 252) >> 2;
3286
- const b2 = (bytes[i2] & 3) << 4 | (bytes[i2 + 1] & 240) >> 4;
3287
- const c = (bytes[i2 + 1] & 15) << 2 | (bytes[i2 + 2] & 192) >> 6;
3288
- const d2 = bytes[i2 + 2] & 63;
3289
- base64 += table[a];
3290
- base64 += table[b2];
3291
- base64 += table[c];
3292
- base64 += table[d2];
3293
- }
3294
- }
3295
- return base64;
3296
- }
3297
- function recordAsyncOperation(test2, promise) {
3298
- promise = promise.finally(() => {
3299
- if (!test2.promises) {
3300
- return;
3301
- }
3302
- const index2 = test2.promises.indexOf(promise);
3303
- if (index2 !== -1) {
3304
- test2.promises.splice(index2, 1);
3305
- }
3306
- });
3307
- if (!test2.promises) {
3308
- test2.promises = [];
3309
- }
3310
- test2.promises.push(promise);
3311
- return promise;
3312
- }
3313
- function manageArtifactAttachment(attachment) {
3314
- if (attachment.body == null && !attachment.path) {
3315
- throw new TypeError(`Test attachment requires "body" or "path" to be set. Both are missing.`);
3316
- }
3317
- if (attachment.body && attachment.path) {
3318
- throw new TypeError(`Test attachment requires only one of "body" or "path" to be set. Both are specified.`);
3319
- }
3320
- if (attachment.path && attachment.bodyEncoding) {
3321
- throw new TypeError(`Test attachment with "path" should not have "bodyEncoding" specified.`);
3322
- }
3323
- if (attachment.body instanceof Uint8Array) {
3324
- attachment.body = encodeUint8Array(attachment.body);
3325
- }
3326
- if (attachment.body != null) {
3327
- attachment.bodyEncoding ?? (attachment.bodyEncoding = "base64");
3328
- }
3329
- }
3330
- async function importId(id) {
3331
- const name = `/@id/${id}`.replace(/\\/g, "/");
3332
- return (/* @__PURE__ */ getBrowserState()).wrapModule(() => import(
3333
- /* @vite-ignore */
3334
- name
3335
- ));
3336
- }
3337
- async function importFs(id) {
3338
- const name = `/@fs/${id}`.replace(/\\/g, "/");
3339
- return (/* @__PURE__ */ getBrowserState()).wrapModule(() => import(
3340
- /* @vite-ignore */
3341
- name
3342
- ));
3343
- }
3344
- const moduleRunner = {
3345
- isBrowser: true,
3346
- import: (id) => {
3347
- if (id[0] === "/" || id[1] === ":") {
3348
- return importFs(id);
3349
- }
3350
- return importId(id);
3351
- }
3352
- };
3353
- const now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
3354
- function getConfig() {
3355
- return (/* @__PURE__ */ getBrowserState()).config;
3356
- }
3357
- // @__NO_SIDE_EFFECTS__
3358
- function getBrowserState() {
3359
- return window.__vitest_browser_runner__;
3360
- }
3361
- // @__NO_SIDE_EFFECTS__
3362
- function getWorkerState() {
3363
- const state = window.__vitest_worker__;
3364
- if (!state) {
3365
- throw new Error("Worker state is not found. This is an issue with Vitest. Please, open an issue.");
3366
- }
3367
- return state;
3368
- }
3369
- export {
3370
- getConfig as a,
3371
- generateFileHash as b,
3372
- resolve as c,
3373
- getWorkerState as d,
3374
- getTestName as e,
3375
- getBrowserState as g,
3376
- moduleRunner as m,
3377
- now as n,
3378
- relative as r
3379
- };