vitest 0.27.3 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE.md +4 -93
  2. package/browser.d.ts +1 -1
  3. package/dist/browser.d.ts +11 -13
  4. package/dist/browser.js +9 -34
  5. package/dist/{chunk-api-setup.0a2398d8.js → chunk-api-setup.52751a38.js} +26 -12
  6. package/dist/chunk-constants.797d3ebf.js +42 -0
  7. package/dist/{chunk-install-pkg.7b006b3e.js → chunk-install-pkg.cfd23146.js} +51 -11
  8. package/dist/{vendor-index.57682f0c.js → chunk-integrations-coverage.48e6286b.js} +33 -4
  9. package/dist/chunk-integrations-globals.0d5f50f0.js +29 -0
  10. package/dist/chunk-integrations-run-once.38756e30.js +27 -0
  11. package/dist/chunk-integrations-utils.f1f6f1ed.js +118 -0
  12. package/dist/{chunk-node-git.59caac18.js → chunk-node-git.d9ad64ab.js} +6 -8
  13. package/dist/{chunk-snapshot-manager.d16903ef.js → chunk-node-pkg.dcdf4369.js} +7440 -172
  14. package/dist/{chunk-runtime-mocker.66533d65.js → chunk-runtime-mocker.03017e8c.js} +13 -12
  15. package/dist/{chunk-runtime-rpc.e79efa9a.js → chunk-runtime-rpc.9c0386cc.js} +3 -2
  16. package/dist/chunk-runtime-setup.d9302cfd.js +20 -0
  17. package/dist/chunk-snapshot-env.6457638e.js +11 -0
  18. package/dist/chunk-utils-base.977ae74f.js +77 -0
  19. package/dist/chunk-utils-env.860d90c2.js +6 -0
  20. package/dist/chunk-utils-global.442d1d33.js +73 -0
  21. package/dist/{chunk-utils-import.eb63557e.js → chunk-utils-import.9911c99d.js} +3289 -169
  22. package/dist/chunk-utils-tasks.1b603032.js +103 -0
  23. package/dist/cli-wrapper.js +7 -6
  24. package/dist/cli.js +16 -15
  25. package/dist/config.d.ts +7 -2
  26. package/dist/entry.js +233 -28
  27. package/dist/env-afee91f0.d.ts +10 -0
  28. package/dist/environments.d.ts +7 -2
  29. package/dist/index.d.ts +160 -11
  30. package/dist/index.js +17 -18
  31. package/dist/loader.js +6 -6
  32. package/dist/node.d.ts +9 -7
  33. package/dist/node.js +18 -17
  34. package/dist/runners-chunk.js +215 -0
  35. package/dist/runners.d.ts +39 -0
  36. package/dist/runners.js +18 -0
  37. package/dist/spy.js +1 -2
  38. package/dist/suite.d.ts +2 -0
  39. package/dist/suite.js +2 -19
  40. package/dist/{types-c1386a7d.d.ts → types-c800444e.d.ts} +160 -425
  41. package/dist/{vendor-index.e6c27006.js → vendor-index.618ca5a1.js} +1078 -10
  42. package/dist/{vendor-index.b0346fe4.js → vendor-index.bdee400f.js} +1 -0
  43. package/dist/worker.js +11 -13
  44. package/package.json +21 -12
  45. package/runners.d.ts +1 -0
  46. package/suite.d.ts +1 -0
  47. package/dist/chunk-integrations-coverage.18366936.js +0 -242
  48. package/dist/chunk-integrations-globals.59b4d460.js +0 -28
  49. package/dist/chunk-mock-date.91595ccd.js +0 -350
  50. package/dist/chunk-runtime-chain.07d16eac.js +0 -2594
  51. package/dist/chunk-runtime-error.f2062967.js +0 -144
  52. package/dist/chunk-runtime-setup.8ca273cd.js +0 -653
  53. package/dist/chunk-utils-env.4ebb0106.js +0 -229
  54. package/dist/chunk-utils-source-map.832515f7.js +0 -408
  55. package/dist/chunk-utils-timers.52534f96.js +0 -3573
  56. package/dist/index-2dd51af4.d.ts +0 -258
  57. package/dist/vendor-index.451e37bc.js +0 -1071
  58. package/dist/vendor-index.723a074f.js +0 -102
  59. package/dist/vendor-index.9c919048.js +0 -61
  60. package/dist/vendor-index.9f20a9be.js +0 -6291
@@ -1,15 +1,22 @@
1
- import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, b as bench, c as createExpect, e as globalExpect } from './chunk-runtime-chain.07d16eac.js';
2
- import { g as getWorkerState, R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-mock-date.91595ccd.js';
3
- import { p as parseSingleStack } from './chunk-utils-source-map.832515f7.js';
1
+ import { getCurrentSuite } from '@vitest/runner';
2
+ import { createChainable, getNames } from '@vitest/runner/utils';
3
+ import { getSafeTimers, noop } from '@vitest/utils';
4
+ import { g as getWorkerState, i as isRunningInBenchmark, a as getCallLastIndex, b as getCurrentEnvironment, r as resetModules } from './chunk-utils-global.442d1d33.js';
5
+ import * as chai$1 from 'chai';
6
+ import { expect } from 'chai';
4
7
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
5
- import util from 'util';
6
- import { s as spyOn, f as fn, i as isMockFunction, a as spies } from './vendor-index.723a074f.js';
7
- import { s as safeSetTimeout } from './chunk-utils-timers.52534f96.js';
8
- import * as chai from 'chai';
9
- import { assert, should } from 'chai';
8
+ import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, getState, setState } from '@vitest/expect';
9
+ import { r as rpc } from './chunk-runtime-rpc.9c0386cc.js';
10
+ import { join, dirname } from 'pathe';
11
+ import { g as getSnapshotEnironment } from './chunk-snapshot-env.6457638e.js';
12
+ import { i as isObject, s as slash } from './chunk-utils-base.977ae74f.js';
13
+ import { p as positionToOffset, o as offsetToLineNumber, l as lineSplitRE, a as parseStacktrace, g as getFullName, b as parseSingleStack } from './chunk-utils-tasks.1b603032.js';
14
+ import require$$0 from 'util';
15
+ import { spyOn, fn, isMockFunction, spies } from '@vitest/spy';
10
16
 
11
17
  function waitNextTick() {
12
- return new Promise((resolve) => safeSetTimeout(resolve, 0));
18
+ const { setTimeout } = getSafeTimers();
19
+ return new Promise((resolve) => setTimeout(resolve, 0));
13
20
  }
14
21
  async function waitForImportsToResolve() {
15
22
  await waitNextTick();
@@ -28,65 +35,3241 @@ async function waitForImportsToResolve() {
28
35
  await waitForImportsToResolve();
29
36
  }
30
37
 
31
- let _test;
32
- function setCurrentTest(test) {
33
- _test = test;
38
+ const benchFns = /* @__PURE__ */ new WeakMap();
39
+ const benchOptsMap = /* @__PURE__ */ new WeakMap();
40
+ function getBenchOptions(key) {
41
+ return benchOptsMap.get(key);
34
42
  }
35
- function getCurrentTest() {
36
- return _test;
43
+ function getBenchFn(key) {
44
+ return benchFns.get(key);
37
45
  }
46
+ const bench = createBenchmark(
47
+ function(name, fn = noop, options = {}) {
48
+ if (!isRunningInBenchmark())
49
+ throw new Error("`bench()` is only available in benchmark mode.");
50
+ const task = getCurrentSuite().custom.call(this, name);
51
+ task.meta = {
52
+ benchmark: true
53
+ };
54
+ benchFns.set(task, fn);
55
+ benchOptsMap.set(task, options);
56
+ }
57
+ );
58
+ function createBenchmark(fn) {
59
+ const benchmark = createChainable(
60
+ ["skip", "only", "todo"],
61
+ fn
62
+ );
63
+ benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark;
64
+ benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip;
65
+ return benchmark;
66
+ }
67
+
68
+ function commonjsRequire(path) {
69
+ throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
70
+ }
71
+
72
+ var chaiSubset = {exports: {}};
73
+
74
+ (function (module, exports) {
75
+ (function() {
76
+ (function(chaiSubset) {
77
+ if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') {
78
+ return module.exports = chaiSubset;
79
+ } else {
80
+ return chai.use(chaiSubset);
81
+ }
82
+ })(function(chai, utils) {
83
+ var Assertion = chai.Assertion;
84
+ var assertionPrototype = Assertion.prototype;
85
+
86
+ Assertion.addMethod('containSubset', function (expected) {
87
+ var actual = utils.flag(this, 'object');
88
+ var showDiff = chai.config.showDiff;
89
+
90
+ assertionPrototype.assert.call(this,
91
+ compare(expected, actual),
92
+ 'expected #{act} to contain subset #{exp}',
93
+ 'expected #{act} to not contain subset #{exp}',
94
+ expected,
95
+ actual,
96
+ showDiff
97
+ );
98
+ });
99
+
100
+ chai.assert.containSubset = function(val, exp, msg) {
101
+ new chai.Assertion(val, msg).to.be.containSubset(exp);
102
+ };
103
+
104
+ function compare(expected, actual) {
105
+ if (expected === actual) {
106
+ return true;
107
+ }
108
+ if (typeof(actual) !== typeof(expected)) {
109
+ return false;
110
+ }
111
+ if (typeof(expected) !== 'object' || expected === null) {
112
+ return expected === actual;
113
+ }
114
+ if (!!expected && !actual) {
115
+ return false;
116
+ }
117
+
118
+ if (Array.isArray(expected)) {
119
+ if (typeof(actual.length) !== 'number') {
120
+ return false;
121
+ }
122
+ var aa = Array.prototype.slice.call(actual);
123
+ return expected.every(function (exp) {
124
+ return aa.some(function (act) {
125
+ return compare(exp, act);
126
+ });
127
+ });
128
+ }
129
+
130
+ if (expected instanceof Date) {
131
+ if (actual instanceof Date) {
132
+ return expected.getTime() === actual.getTime();
133
+ } else {
134
+ return false;
135
+ }
136
+ }
137
+
138
+ return Object.keys(expected).every(function (key) {
139
+ var eo = expected[key];
140
+ var ao = actual[key];
141
+ if (typeof(eo) === 'object' && eo !== null && ao !== null) {
142
+ return compare(eo, ao);
143
+ }
144
+ if (typeof(eo) === 'function') {
145
+ return eo(ao);
146
+ }
147
+ return ao === eo;
148
+ });
149
+ }
150
+ });
151
+
152
+ }).call(commonjsGlobal);
153
+ } (chaiSubset));
154
+
155
+ var Subset = chaiSubset.exports;
156
+
157
+ var naturalCompare$1 = {exports: {}};
158
+
159
+ /*
160
+ * @version 1.4.0
161
+ * @date 2015-10-26
162
+ * @stability 3 - Stable
163
+ * @author Lauri Rooden (https://github.com/litejs/natural-compare-lite)
164
+ * @license MIT License
165
+ */
166
+
167
+
168
+ var naturalCompare = function(a, b) {
169
+ var i, codeA
170
+ , codeB = 1
171
+ , posA = 0
172
+ , posB = 0
173
+ , alphabet = String.alphabet;
174
+
175
+ function getCode(str, pos, code) {
176
+ if (code) {
177
+ for (i = pos; code = getCode(str, i), code < 76 && code > 65;) ++i;
178
+ return +str.slice(pos - 1, i)
179
+ }
180
+ code = alphabet && alphabet.indexOf(str.charAt(pos));
181
+ return code > -1 ? code + 76 : ((code = str.charCodeAt(pos) || 0), code < 45 || code > 127) ? code
182
+ : code < 46 ? 65 // -
183
+ : code < 48 ? code - 1
184
+ : code < 58 ? code + 18 // 0-9
185
+ : code < 65 ? code - 11
186
+ : code < 91 ? code + 11 // A-Z
187
+ : code < 97 ? code - 37
188
+ : code < 123 ? code + 5 // a-z
189
+ : code - 63
190
+ }
191
+
192
+
193
+ if ((a+="") != (b+="")) for (;codeB;) {
194
+ codeA = getCode(a, posA++);
195
+ codeB = getCode(b, posB++);
196
+
197
+ if (codeA < 76 && codeB < 76 && codeA > 66 && codeB > 66) {
198
+ codeA = getCode(a, posA, posA);
199
+ codeB = getCode(b, posB, posA = i);
200
+ posB = i;
201
+ }
202
+
203
+ if (codeA != codeB) return (codeA < codeB) ? -1 : 1
204
+ }
205
+ return 0
206
+ };
207
+
208
+ try {
209
+ naturalCompare$1.exports = naturalCompare;
210
+ } catch (e) {
211
+ String.naturalCompare = naturalCompare;
212
+ }
213
+
214
+ var build = {};
215
+
216
+ var ansiStyles = {exports: {}};
217
+
218
+ (function (module) {
219
+
220
+ const ANSI_BACKGROUND_OFFSET = 10;
221
+
222
+ const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
223
+
224
+ const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
225
+
226
+ function assembleStyles() {
227
+ const codes = new Map();
228
+ const styles = {
229
+ modifier: {
230
+ reset: [0, 0],
231
+ // 21 isn't widely supported and 22 does the same thing
232
+ bold: [1, 22],
233
+ dim: [2, 22],
234
+ italic: [3, 23],
235
+ underline: [4, 24],
236
+ overline: [53, 55],
237
+ inverse: [7, 27],
238
+ hidden: [8, 28],
239
+ strikethrough: [9, 29]
240
+ },
241
+ color: {
242
+ black: [30, 39],
243
+ red: [31, 39],
244
+ green: [32, 39],
245
+ yellow: [33, 39],
246
+ blue: [34, 39],
247
+ magenta: [35, 39],
248
+ cyan: [36, 39],
249
+ white: [37, 39],
250
+
251
+ // Bright color
252
+ blackBright: [90, 39],
253
+ redBright: [91, 39],
254
+ greenBright: [92, 39],
255
+ yellowBright: [93, 39],
256
+ blueBright: [94, 39],
257
+ magentaBright: [95, 39],
258
+ cyanBright: [96, 39],
259
+ whiteBright: [97, 39]
260
+ },
261
+ bgColor: {
262
+ bgBlack: [40, 49],
263
+ bgRed: [41, 49],
264
+ bgGreen: [42, 49],
265
+ bgYellow: [43, 49],
266
+ bgBlue: [44, 49],
267
+ bgMagenta: [45, 49],
268
+ bgCyan: [46, 49],
269
+ bgWhite: [47, 49],
270
+
271
+ // Bright color
272
+ bgBlackBright: [100, 49],
273
+ bgRedBright: [101, 49],
274
+ bgGreenBright: [102, 49],
275
+ bgYellowBright: [103, 49],
276
+ bgBlueBright: [104, 49],
277
+ bgMagentaBright: [105, 49],
278
+ bgCyanBright: [106, 49],
279
+ bgWhiteBright: [107, 49]
280
+ }
281
+ };
282
+
283
+ // Alias bright black as gray (and grey)
284
+ styles.color.gray = styles.color.blackBright;
285
+ styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
286
+ styles.color.grey = styles.color.blackBright;
287
+ styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
288
+
289
+ for (const [groupName, group] of Object.entries(styles)) {
290
+ for (const [styleName, style] of Object.entries(group)) {
291
+ styles[styleName] = {
292
+ open: `\u001B[${style[0]}m`,
293
+ close: `\u001B[${style[1]}m`
294
+ };
295
+
296
+ group[styleName] = styles[styleName];
297
+
298
+ codes.set(style[0], style[1]);
299
+ }
300
+
301
+ Object.defineProperty(styles, groupName, {
302
+ value: group,
303
+ enumerable: false
304
+ });
305
+ }
306
+
307
+ Object.defineProperty(styles, 'codes', {
308
+ value: codes,
309
+ enumerable: false
310
+ });
311
+
312
+ styles.color.close = '\u001B[39m';
313
+ styles.bgColor.close = '\u001B[49m';
314
+
315
+ styles.color.ansi256 = wrapAnsi256();
316
+ styles.color.ansi16m = wrapAnsi16m();
317
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
318
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
319
+
320
+ // From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
321
+ Object.defineProperties(styles, {
322
+ rgbToAnsi256: {
323
+ value: (red, green, blue) => {
324
+ // We use the extended greyscale palette here, with the exception of
325
+ // black and white. normal palette only has 4 greyscale shades.
326
+ if (red === green && green === blue) {
327
+ if (red < 8) {
328
+ return 16;
329
+ }
330
+
331
+ if (red > 248) {
332
+ return 231;
333
+ }
334
+
335
+ return Math.round(((red - 8) / 247) * 24) + 232;
336
+ }
337
+
338
+ return 16 +
339
+ (36 * Math.round(red / 255 * 5)) +
340
+ (6 * Math.round(green / 255 * 5)) +
341
+ Math.round(blue / 255 * 5);
342
+ },
343
+ enumerable: false
344
+ },
345
+ hexToRgb: {
346
+ value: hex => {
347
+ const matches = /(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(hex.toString(16));
348
+ if (!matches) {
349
+ return [0, 0, 0];
350
+ }
351
+
352
+ let {colorString} = matches.groups;
353
+
354
+ if (colorString.length === 3) {
355
+ colorString = colorString.split('').map(character => character + character).join('');
356
+ }
357
+
358
+ const integer = Number.parseInt(colorString, 16);
359
+
360
+ return [
361
+ (integer >> 16) & 0xFF,
362
+ (integer >> 8) & 0xFF,
363
+ integer & 0xFF
364
+ ];
365
+ },
366
+ enumerable: false
367
+ },
368
+ hexToAnsi256: {
369
+ value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
370
+ enumerable: false
371
+ }
372
+ });
373
+
374
+ return styles;
375
+ }
376
+
377
+ // Make the export immutable
378
+ Object.defineProperty(module, 'exports', {
379
+ enumerable: true,
380
+ get: assembleStyles
381
+ });
382
+ } (ansiStyles));
383
+
384
+ var collections = {};
385
+
386
+ Object.defineProperty(collections, '__esModule', {
387
+ value: true
388
+ });
389
+ collections.printIteratorEntries = printIteratorEntries;
390
+ collections.printIteratorValues = printIteratorValues;
391
+ collections.printListItems = printListItems;
392
+ collections.printObjectProperties = printObjectProperties;
393
+
394
+ /**
395
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
396
+ *
397
+ * This source code is licensed under the MIT license found in the
398
+ * LICENSE file in the root directory of this source tree.
399
+ *
400
+ */
401
+ const getKeysOfEnumerableProperties = (object, compareKeys) => {
402
+ const keys = Object.keys(object).sort(compareKeys);
403
+
404
+ if (Object.getOwnPropertySymbols) {
405
+ Object.getOwnPropertySymbols(object).forEach(symbol => {
406
+ if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) {
407
+ keys.push(symbol);
408
+ }
409
+ });
410
+ }
411
+
412
+ return keys;
413
+ };
414
+ /**
415
+ * Return entries (for example, of a map)
416
+ * with spacing, indentation, and comma
417
+ * without surrounding punctuation (for example, braces)
418
+ */
419
+
420
+ function printIteratorEntries(
421
+ iterator,
422
+ config,
423
+ indentation,
424
+ depth,
425
+ refs,
426
+ printer, // Too bad, so sad that separator for ECMAScript Map has been ' => '
427
+ // What a distracting diff if you change a data structure to/from
428
+ // ECMAScript Object or Immutable.Map/OrderedMap which use the default.
429
+ separator = ': '
430
+ ) {
431
+ let result = '';
432
+ let current = iterator.next();
433
+
434
+ if (!current.done) {
435
+ result += config.spacingOuter;
436
+ const indentationNext = indentation + config.indent;
437
+
438
+ while (!current.done) {
439
+ const name = printer(
440
+ current.value[0],
441
+ config,
442
+ indentationNext,
443
+ depth,
444
+ refs
445
+ );
446
+ const value = printer(
447
+ current.value[1],
448
+ config,
449
+ indentationNext,
450
+ depth,
451
+ refs
452
+ );
453
+ result += indentationNext + name + separator + value;
454
+ current = iterator.next();
455
+
456
+ if (!current.done) {
457
+ result += ',' + config.spacingInner;
458
+ } else if (!config.min) {
459
+ result += ',';
460
+ }
461
+ }
462
+
463
+ result += config.spacingOuter + indentation;
464
+ }
465
+
466
+ return result;
467
+ }
468
+ /**
469
+ * Return values (for example, of a set)
470
+ * with spacing, indentation, and comma
471
+ * without surrounding punctuation (braces or brackets)
472
+ */
473
+
474
+ function printIteratorValues(
475
+ iterator,
476
+ config,
477
+ indentation,
478
+ depth,
479
+ refs,
480
+ printer
481
+ ) {
482
+ let result = '';
483
+ let current = iterator.next();
484
+
485
+ if (!current.done) {
486
+ result += config.spacingOuter;
487
+ const indentationNext = indentation + config.indent;
488
+
489
+ while (!current.done) {
490
+ result +=
491
+ indentationNext +
492
+ printer(current.value, config, indentationNext, depth, refs);
493
+ current = iterator.next();
494
+
495
+ if (!current.done) {
496
+ result += ',' + config.spacingInner;
497
+ } else if (!config.min) {
498
+ result += ',';
499
+ }
500
+ }
501
+
502
+ result += config.spacingOuter + indentation;
503
+ }
504
+
505
+ return result;
506
+ }
507
+ /**
508
+ * Return items (for example, of an array)
509
+ * with spacing, indentation, and comma
510
+ * without surrounding punctuation (for example, brackets)
511
+ **/
512
+
513
+ function printListItems(list, config, indentation, depth, refs, printer) {
514
+ let result = '';
515
+
516
+ if (list.length) {
517
+ result += config.spacingOuter;
518
+ const indentationNext = indentation + config.indent;
519
+
520
+ for (let i = 0; i < list.length; i++) {
521
+ result += indentationNext;
522
+
523
+ if (i in list) {
524
+ result += printer(list[i], config, indentationNext, depth, refs);
525
+ }
526
+
527
+ if (i < list.length - 1) {
528
+ result += ',' + config.spacingInner;
529
+ } else if (!config.min) {
530
+ result += ',';
531
+ }
532
+ }
533
+
534
+ result += config.spacingOuter + indentation;
535
+ }
536
+
537
+ return result;
538
+ }
539
+ /**
540
+ * Return properties of an object
541
+ * with spacing, indentation, and comma
542
+ * without surrounding punctuation (for example, braces)
543
+ */
544
+
545
+ function printObjectProperties(val, config, indentation, depth, refs, printer) {
546
+ let result = '';
547
+ const keys = getKeysOfEnumerableProperties(val, config.compareKeys);
548
+
549
+ if (keys.length) {
550
+ result += config.spacingOuter;
551
+ const indentationNext = indentation + config.indent;
552
+
553
+ for (let i = 0; i < keys.length; i++) {
554
+ const key = keys[i];
555
+ const name = printer(key, config, indentationNext, depth, refs);
556
+ const value = printer(val[key], config, indentationNext, depth, refs);
557
+ result += indentationNext + name + ': ' + value;
558
+
559
+ if (i < keys.length - 1) {
560
+ result += ',' + config.spacingInner;
561
+ } else if (!config.min) {
562
+ result += ',';
563
+ }
564
+ }
565
+
566
+ result += config.spacingOuter + indentation;
567
+ }
568
+
569
+ return result;
570
+ }
571
+
572
+ var AsymmetricMatcher$1 = {};
573
+
574
+ Object.defineProperty(AsymmetricMatcher$1, '__esModule', {
575
+ value: true
576
+ });
577
+ AsymmetricMatcher$1.test = AsymmetricMatcher$1.serialize = AsymmetricMatcher$1.default = void 0;
578
+
579
+ var _collections$3 = collections;
580
+
581
+ var global$2 = (function () {
582
+ if (typeof globalThis !== 'undefined') {
583
+ return globalThis;
584
+ } else if (typeof global$2 !== 'undefined') {
585
+ return global$2;
586
+ } else if (typeof self !== 'undefined') {
587
+ return self;
588
+ } else if (typeof window !== 'undefined') {
589
+ return window;
590
+ } else {
591
+ return Function('return this')();
592
+ }
593
+ })();
594
+
595
+ var Symbol$2 = global$2['jest-symbol-do-not-touch'] || global$2.Symbol;
596
+ const asymmetricMatcher =
597
+ typeof Symbol$2 === 'function' && Symbol$2.for
598
+ ? Symbol$2.for('jest.asymmetricMatcher')
599
+ : 0x1357a5;
600
+ const SPACE$2 = ' ';
601
+
602
+ const serialize$8 = (val, config, indentation, depth, refs, printer) => {
603
+ const stringedValue = val.toString();
604
+
605
+ if (
606
+ stringedValue === 'ArrayContaining' ||
607
+ stringedValue === 'ArrayNotContaining'
608
+ ) {
609
+ if (++depth > config.maxDepth) {
610
+ return '[' + stringedValue + ']';
611
+ }
612
+
613
+ return (
614
+ stringedValue +
615
+ SPACE$2 +
616
+ '[' +
617
+ (0, _collections$3.printListItems)(
618
+ val.sample,
619
+ config,
620
+ indentation,
621
+ depth,
622
+ refs,
623
+ printer
624
+ ) +
625
+ ']'
626
+ );
627
+ }
628
+
629
+ if (
630
+ stringedValue === 'ObjectContaining' ||
631
+ stringedValue === 'ObjectNotContaining'
632
+ ) {
633
+ if (++depth > config.maxDepth) {
634
+ return '[' + stringedValue + ']';
635
+ }
636
+
637
+ return (
638
+ stringedValue +
639
+ SPACE$2 +
640
+ '{' +
641
+ (0, _collections$3.printObjectProperties)(
642
+ val.sample,
643
+ config,
644
+ indentation,
645
+ depth,
646
+ refs,
647
+ printer
648
+ ) +
649
+ '}'
650
+ );
651
+ }
652
+
653
+ if (
654
+ stringedValue === 'StringMatching' ||
655
+ stringedValue === 'StringNotMatching'
656
+ ) {
657
+ return (
658
+ stringedValue +
659
+ SPACE$2 +
660
+ printer(val.sample, config, indentation, depth, refs)
661
+ );
662
+ }
663
+
664
+ if (
665
+ stringedValue === 'StringContaining' ||
666
+ stringedValue === 'StringNotContaining'
667
+ ) {
668
+ return (
669
+ stringedValue +
670
+ SPACE$2 +
671
+ printer(val.sample, config, indentation, depth, refs)
672
+ );
673
+ }
674
+
675
+ return val.toAsymmetricMatcher();
676
+ };
677
+
678
+ AsymmetricMatcher$1.serialize = serialize$8;
679
+
680
+ const test$7 = val => val && val.$$typeof === asymmetricMatcher;
681
+
682
+ AsymmetricMatcher$1.test = test$7;
683
+ const plugin$7 = {
684
+ serialize: serialize$8,
685
+ test: test$7
686
+ };
687
+ var _default$7 = plugin$7;
688
+ AsymmetricMatcher$1.default = _default$7;
689
+
690
+ var ConvertAnsi = {};
691
+
692
+ var ansiRegex = ({onlyFirst = false} = {}) => {
693
+ const pattern = [
694
+ '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
695
+ '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
696
+ ].join('|');
697
+
698
+ return new RegExp(pattern, onlyFirst ? undefined : 'g');
699
+ };
700
+
701
+ Object.defineProperty(ConvertAnsi, '__esModule', {
702
+ value: true
703
+ });
704
+ ConvertAnsi.test = ConvertAnsi.serialize = ConvertAnsi.default = void 0;
705
+
706
+ var _ansiRegex = _interopRequireDefault$2(ansiRegex);
707
+
708
+ var _ansiStyles$1 = _interopRequireDefault$2(ansiStyles.exports);
709
+
710
+ function _interopRequireDefault$2(obj) {
711
+ return obj && obj.__esModule ? obj : {default: obj};
712
+ }
713
+
714
+ /**
715
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
716
+ *
717
+ * This source code is licensed under the MIT license found in the
718
+ * LICENSE file in the root directory of this source tree.
719
+ */
720
+ const toHumanReadableAnsi = text =>
721
+ text.replace((0, _ansiRegex.default)(), match => {
722
+ switch (match) {
723
+ case _ansiStyles$1.default.red.close:
724
+ case _ansiStyles$1.default.green.close:
725
+ case _ansiStyles$1.default.cyan.close:
726
+ case _ansiStyles$1.default.gray.close:
727
+ case _ansiStyles$1.default.white.close:
728
+ case _ansiStyles$1.default.yellow.close:
729
+ case _ansiStyles$1.default.bgRed.close:
730
+ case _ansiStyles$1.default.bgGreen.close:
731
+ case _ansiStyles$1.default.bgYellow.close:
732
+ case _ansiStyles$1.default.inverse.close:
733
+ case _ansiStyles$1.default.dim.close:
734
+ case _ansiStyles$1.default.bold.close:
735
+ case _ansiStyles$1.default.reset.open:
736
+ case _ansiStyles$1.default.reset.close:
737
+ return '</>';
738
+
739
+ case _ansiStyles$1.default.red.open:
740
+ return '<red>';
741
+
742
+ case _ansiStyles$1.default.green.open:
743
+ return '<green>';
744
+
745
+ case _ansiStyles$1.default.cyan.open:
746
+ return '<cyan>';
747
+
748
+ case _ansiStyles$1.default.gray.open:
749
+ return '<gray>';
750
+
751
+ case _ansiStyles$1.default.white.open:
752
+ return '<white>';
753
+
754
+ case _ansiStyles$1.default.yellow.open:
755
+ return '<yellow>';
756
+
757
+ case _ansiStyles$1.default.bgRed.open:
758
+ return '<bgRed>';
759
+
760
+ case _ansiStyles$1.default.bgGreen.open:
761
+ return '<bgGreen>';
762
+
763
+ case _ansiStyles$1.default.bgYellow.open:
764
+ return '<bgYellow>';
765
+
766
+ case _ansiStyles$1.default.inverse.open:
767
+ return '<inverse>';
768
+
769
+ case _ansiStyles$1.default.dim.open:
770
+ return '<dim>';
771
+
772
+ case _ansiStyles$1.default.bold.open:
773
+ return '<bold>';
774
+
775
+ default:
776
+ return '';
777
+ }
778
+ });
779
+
780
+ const test$6 = val =>
781
+ typeof val === 'string' && !!val.match((0, _ansiRegex.default)());
782
+
783
+ ConvertAnsi.test = test$6;
784
+
785
+ const serialize$7 = (val, config, indentation, depth, refs, printer) =>
786
+ printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
787
+
788
+ ConvertAnsi.serialize = serialize$7;
789
+ const plugin$6 = {
790
+ serialize: serialize$7,
791
+ test: test$6
792
+ };
793
+ var _default$6 = plugin$6;
794
+ ConvertAnsi.default = _default$6;
795
+
796
+ var DOMCollection$1 = {};
797
+
798
+ Object.defineProperty(DOMCollection$1, '__esModule', {
799
+ value: true
800
+ });
801
+ DOMCollection$1.test = DOMCollection$1.serialize = DOMCollection$1.default = void 0;
802
+
803
+ var _collections$2 = collections;
804
+
805
+ /**
806
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
807
+ *
808
+ * This source code is licensed under the MIT license found in the
809
+ * LICENSE file in the root directory of this source tree.
810
+ */
811
+
812
+ /* eslint-disable local/ban-types-eventually */
813
+ const SPACE$1 = ' ';
814
+ const OBJECT_NAMES = ['DOMStringMap', 'NamedNodeMap'];
815
+ const ARRAY_REGEXP = /^(HTML\w*Collection|NodeList)$/;
816
+
817
+ const testName = name =>
818
+ OBJECT_NAMES.indexOf(name) !== -1 || ARRAY_REGEXP.test(name);
819
+
820
+ const test$5 = val =>
821
+ val &&
822
+ val.constructor &&
823
+ !!val.constructor.name &&
824
+ testName(val.constructor.name);
825
+
826
+ DOMCollection$1.test = test$5;
827
+
828
+ const isNamedNodeMap = collection =>
829
+ collection.constructor.name === 'NamedNodeMap';
830
+
831
+ const serialize$6 = (collection, config, indentation, depth, refs, printer) => {
832
+ const name = collection.constructor.name;
833
+
834
+ if (++depth > config.maxDepth) {
835
+ return '[' + name + ']';
836
+ }
837
+
838
+ return (
839
+ (config.min ? '' : name + SPACE$1) +
840
+ (OBJECT_NAMES.indexOf(name) !== -1
841
+ ? '{' +
842
+ (0, _collections$2.printObjectProperties)(
843
+ isNamedNodeMap(collection)
844
+ ? Array.from(collection).reduce((props, attribute) => {
845
+ props[attribute.name] = attribute.value;
846
+ return props;
847
+ }, {})
848
+ : {...collection},
849
+ config,
850
+ indentation,
851
+ depth,
852
+ refs,
853
+ printer
854
+ ) +
855
+ '}'
856
+ : '[' +
857
+ (0, _collections$2.printListItems)(
858
+ Array.from(collection),
859
+ config,
860
+ indentation,
861
+ depth,
862
+ refs,
863
+ printer
864
+ ) +
865
+ ']')
866
+ );
867
+ };
868
+
869
+ DOMCollection$1.serialize = serialize$6;
870
+ const plugin$5 = {
871
+ serialize: serialize$6,
872
+ test: test$5
873
+ };
874
+ var _default$5 = plugin$5;
875
+ DOMCollection$1.default = _default$5;
876
+
877
+ var DOMElement$1 = {};
878
+
879
+ var markup = {};
880
+
881
+ var escapeHTML$1 = {};
882
+
883
+ Object.defineProperty(escapeHTML$1, '__esModule', {
884
+ value: true
885
+ });
886
+ escapeHTML$1.default = escapeHTML;
887
+
888
+ /**
889
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
890
+ *
891
+ * This source code is licensed under the MIT license found in the
892
+ * LICENSE file in the root directory of this source tree.
893
+ */
894
+ function escapeHTML(str) {
895
+ return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
896
+ }
897
+
898
+ Object.defineProperty(markup, '__esModule', {
899
+ value: true
900
+ });
901
+ markup.printText =
902
+ markup.printProps =
903
+ markup.printElementAsLeaf =
904
+ markup.printElement =
905
+ markup.printComment =
906
+ markup.printChildren =
907
+ void 0;
908
+
909
+ var _escapeHTML = _interopRequireDefault$1(escapeHTML$1);
910
+
911
+ function _interopRequireDefault$1(obj) {
912
+ return obj && obj.__esModule ? obj : {default: obj};
913
+ }
914
+
915
+ /**
916
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
917
+ *
918
+ * This source code is licensed under the MIT license found in the
919
+ * LICENSE file in the root directory of this source tree.
920
+ */
921
+ // Return empty string if keys is empty.
922
+ const printProps = (keys, props, config, indentation, depth, refs, printer) => {
923
+ const indentationNext = indentation + config.indent;
924
+ const colors = config.colors;
925
+ return keys
926
+ .map(key => {
927
+ const value = props[key];
928
+ let printed = printer(value, config, indentationNext, depth, refs);
929
+
930
+ if (typeof value !== 'string') {
931
+ if (printed.indexOf('\n') !== -1) {
932
+ printed =
933
+ config.spacingOuter +
934
+ indentationNext +
935
+ printed +
936
+ config.spacingOuter +
937
+ indentation;
938
+ }
939
+
940
+ printed = '{' + printed + '}';
941
+ }
942
+
943
+ return (
944
+ config.spacingInner +
945
+ indentation +
946
+ colors.prop.open +
947
+ key +
948
+ colors.prop.close +
949
+ '=' +
950
+ colors.value.open +
951
+ printed +
952
+ colors.value.close
953
+ );
954
+ })
955
+ .join('');
956
+ }; // Return empty string if children is empty.
957
+
958
+ markup.printProps = printProps;
959
+
960
+ const printChildren = (children, config, indentation, depth, refs, printer) =>
961
+ children
962
+ .map(
963
+ child =>
964
+ config.spacingOuter +
965
+ indentation +
966
+ (typeof child === 'string'
967
+ ? printText(child, config)
968
+ : printer(child, config, indentation, depth, refs))
969
+ )
970
+ .join('');
971
+
972
+ markup.printChildren = printChildren;
973
+
974
+ const printText = (text, config) => {
975
+ const contentColor = config.colors.content;
976
+ return (
977
+ contentColor.open + (0, _escapeHTML.default)(text) + contentColor.close
978
+ );
979
+ };
980
+
981
+ markup.printText = printText;
982
+
983
+ const printComment = (comment, config) => {
984
+ const commentColor = config.colors.comment;
985
+ return (
986
+ commentColor.open +
987
+ '<!--' +
988
+ (0, _escapeHTML.default)(comment) +
989
+ '-->' +
990
+ commentColor.close
991
+ );
992
+ }; // Separate the functions to format props, children, and element,
993
+ // so a plugin could override a particular function, if needed.
994
+ // Too bad, so sad: the traditional (but unnecessary) space
995
+ // in a self-closing tagColor requires a second test of printedProps.
996
+
997
+ markup.printComment = printComment;
998
+
999
+ const printElement = (
1000
+ type,
1001
+ printedProps,
1002
+ printedChildren,
1003
+ config,
1004
+ indentation
1005
+ ) => {
1006
+ const tagColor = config.colors.tag;
1007
+ return (
1008
+ tagColor.open +
1009
+ '<' +
1010
+ type +
1011
+ (printedProps &&
1012
+ tagColor.close +
1013
+ printedProps +
1014
+ config.spacingOuter +
1015
+ indentation +
1016
+ tagColor.open) +
1017
+ (printedChildren
1018
+ ? '>' +
1019
+ tagColor.close +
1020
+ printedChildren +
1021
+ config.spacingOuter +
1022
+ indentation +
1023
+ tagColor.open +
1024
+ '</' +
1025
+ type
1026
+ : (printedProps && !config.min ? '' : ' ') + '/') +
1027
+ '>' +
1028
+ tagColor.close
1029
+ );
1030
+ };
1031
+
1032
+ markup.printElement = printElement;
1033
+
1034
+ const printElementAsLeaf = (type, config) => {
1035
+ const tagColor = config.colors.tag;
1036
+ return (
1037
+ tagColor.open +
1038
+ '<' +
1039
+ type +
1040
+ tagColor.close +
1041
+ ' …' +
1042
+ tagColor.open +
1043
+ ' />' +
1044
+ tagColor.close
1045
+ );
1046
+ };
1047
+
1048
+ markup.printElementAsLeaf = printElementAsLeaf;
1049
+
1050
+ Object.defineProperty(DOMElement$1, '__esModule', {
1051
+ value: true
1052
+ });
1053
+ DOMElement$1.test = DOMElement$1.serialize = DOMElement$1.default = void 0;
1054
+
1055
+ var _markup$2 = markup;
1056
+
1057
+ /**
1058
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1059
+ *
1060
+ * This source code is licensed under the MIT license found in the
1061
+ * LICENSE file in the root directory of this source tree.
1062
+ */
1063
+ const ELEMENT_NODE = 1;
1064
+ const TEXT_NODE = 3;
1065
+ const COMMENT_NODE = 8;
1066
+ const FRAGMENT_NODE = 11;
1067
+ const ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/;
1068
+
1069
+ const testHasAttribute = val => {
1070
+ try {
1071
+ return typeof val.hasAttribute === 'function' && val.hasAttribute('is');
1072
+ } catch {
1073
+ return false;
1074
+ }
1075
+ };
1076
+
1077
+ const testNode = val => {
1078
+ const constructorName = val.constructor.name;
1079
+ const {nodeType, tagName} = val;
1080
+ const isCustomElement =
1081
+ (typeof tagName === 'string' && tagName.includes('-')) ||
1082
+ testHasAttribute(val);
1083
+ return (
1084
+ (nodeType === ELEMENT_NODE &&
1085
+ (ELEMENT_REGEXP.test(constructorName) || isCustomElement)) ||
1086
+ (nodeType === TEXT_NODE && constructorName === 'Text') ||
1087
+ (nodeType === COMMENT_NODE && constructorName === 'Comment') ||
1088
+ (nodeType === FRAGMENT_NODE && constructorName === 'DocumentFragment')
1089
+ );
1090
+ };
1091
+
1092
+ const test$4 = val => {
1093
+ var _val$constructor;
1094
+
1095
+ return (
1096
+ (val === null || val === void 0
1097
+ ? void 0
1098
+ : (_val$constructor = val.constructor) === null ||
1099
+ _val$constructor === void 0
1100
+ ? void 0
1101
+ : _val$constructor.name) && testNode(val)
1102
+ );
1103
+ };
1104
+
1105
+ DOMElement$1.test = test$4;
1106
+
1107
+ function nodeIsText(node) {
1108
+ return node.nodeType === TEXT_NODE;
1109
+ }
1110
+
1111
+ function nodeIsComment(node) {
1112
+ return node.nodeType === COMMENT_NODE;
1113
+ }
1114
+
1115
+ function nodeIsFragment(node) {
1116
+ return node.nodeType === FRAGMENT_NODE;
1117
+ }
1118
+
1119
+ const serialize$5 = (node, config, indentation, depth, refs, printer) => {
1120
+ if (nodeIsText(node)) {
1121
+ return (0, _markup$2.printText)(node.data, config);
1122
+ }
1123
+
1124
+ if (nodeIsComment(node)) {
1125
+ return (0, _markup$2.printComment)(node.data, config);
1126
+ }
1127
+
1128
+ const type = nodeIsFragment(node)
1129
+ ? 'DocumentFragment'
1130
+ : node.tagName.toLowerCase();
1131
+
1132
+ if (++depth > config.maxDepth) {
1133
+ return (0, _markup$2.printElementAsLeaf)(type, config);
1134
+ }
1135
+
1136
+ return (0, _markup$2.printElement)(
1137
+ type,
1138
+ (0, _markup$2.printProps)(
1139
+ nodeIsFragment(node)
1140
+ ? []
1141
+ : Array.from(node.attributes)
1142
+ .map(attr => attr.name)
1143
+ .sort(),
1144
+ nodeIsFragment(node)
1145
+ ? {}
1146
+ : Array.from(node.attributes).reduce((props, attribute) => {
1147
+ props[attribute.name] = attribute.value;
1148
+ return props;
1149
+ }, {}),
1150
+ config,
1151
+ indentation + config.indent,
1152
+ depth,
1153
+ refs,
1154
+ printer
1155
+ ),
1156
+ (0, _markup$2.printChildren)(
1157
+ Array.prototype.slice.call(node.childNodes || node.children),
1158
+ config,
1159
+ indentation + config.indent,
1160
+ depth,
1161
+ refs,
1162
+ printer
1163
+ ),
1164
+ config,
1165
+ indentation
1166
+ );
1167
+ };
1168
+
1169
+ DOMElement$1.serialize = serialize$5;
1170
+ const plugin$4 = {
1171
+ serialize: serialize$5,
1172
+ test: test$4
1173
+ };
1174
+ var _default$4 = plugin$4;
1175
+ DOMElement$1.default = _default$4;
1176
+
1177
+ var Immutable$1 = {};
1178
+
1179
+ Object.defineProperty(Immutable$1, '__esModule', {
1180
+ value: true
1181
+ });
1182
+ Immutable$1.test = Immutable$1.serialize = Immutable$1.default = void 0;
1183
+
1184
+ var _collections$1 = collections;
1185
+
1186
+ /**
1187
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1188
+ *
1189
+ * This source code is licensed under the MIT license found in the
1190
+ * LICENSE file in the root directory of this source tree.
1191
+ */
1192
+ // SENTINEL constants are from https://github.com/facebook/immutable-js
1193
+ const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
1194
+ const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
1195
+ const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
1196
+ const IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
1197
+ const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
1198
+ const IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
1199
+
1200
+ const IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
1201
+ const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
1202
+ const IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
1203
+
1204
+ const getImmutableName = name => 'Immutable.' + name;
1205
+
1206
+ const printAsLeaf = name => '[' + name + ']';
1207
+
1208
+ const SPACE = ' ';
1209
+ const LAZY = '…'; // Seq is lazy if it calls a method like filter
1210
+
1211
+ const printImmutableEntries = (
1212
+ val,
1213
+ config,
1214
+ indentation,
1215
+ depth,
1216
+ refs,
1217
+ printer,
1218
+ type
1219
+ ) =>
1220
+ ++depth > config.maxDepth
1221
+ ? printAsLeaf(getImmutableName(type))
1222
+ : getImmutableName(type) +
1223
+ SPACE +
1224
+ '{' +
1225
+ (0, _collections$1.printIteratorEntries)(
1226
+ val.entries(),
1227
+ config,
1228
+ indentation,
1229
+ depth,
1230
+ refs,
1231
+ printer
1232
+ ) +
1233
+ '}'; // Record has an entries method because it is a collection in immutable v3.
1234
+ // Return an iterator for Immutable Record from version v3 or v4.
1235
+
1236
+ function getRecordEntries(val) {
1237
+ let i = 0;
1238
+ return {
1239
+ next() {
1240
+ if (i < val._keys.length) {
1241
+ const key = val._keys[i++];
1242
+ return {
1243
+ done: false,
1244
+ value: [key, val.get(key)]
1245
+ };
1246
+ }
1247
+
1248
+ return {
1249
+ done: true,
1250
+ value: undefined
1251
+ };
1252
+ }
1253
+ };
1254
+ }
1255
+
1256
+ const printImmutableRecord = (
1257
+ val,
1258
+ config,
1259
+ indentation,
1260
+ depth,
1261
+ refs,
1262
+ printer
1263
+ ) => {
1264
+ // _name property is defined only for an Immutable Record instance
1265
+ // which was constructed with a second optional descriptive name arg
1266
+ const name = getImmutableName(val._name || 'Record');
1267
+ return ++depth > config.maxDepth
1268
+ ? printAsLeaf(name)
1269
+ : name +
1270
+ SPACE +
1271
+ '{' +
1272
+ (0, _collections$1.printIteratorEntries)(
1273
+ getRecordEntries(val),
1274
+ config,
1275
+ indentation,
1276
+ depth,
1277
+ refs,
1278
+ printer
1279
+ ) +
1280
+ '}';
1281
+ };
1282
+
1283
+ const printImmutableSeq = (val, config, indentation, depth, refs, printer) => {
1284
+ const name = getImmutableName('Seq');
1285
+
1286
+ if (++depth > config.maxDepth) {
1287
+ return printAsLeaf(name);
1288
+ }
1289
+
1290
+ if (val[IS_KEYED_SENTINEL]) {
1291
+ return (
1292
+ name +
1293
+ SPACE +
1294
+ '{' + // from Immutable collection of entries or from ECMAScript object
1295
+ (val._iter || val._object
1296
+ ? (0, _collections$1.printIteratorEntries)(
1297
+ val.entries(),
1298
+ config,
1299
+ indentation,
1300
+ depth,
1301
+ refs,
1302
+ printer
1303
+ )
1304
+ : LAZY) +
1305
+ '}'
1306
+ );
1307
+ }
1308
+
1309
+ return (
1310
+ name +
1311
+ SPACE +
1312
+ '[' +
1313
+ (val._iter || // from Immutable collection of values
1314
+ val._array || // from ECMAScript array
1315
+ val._collection || // from ECMAScript collection in immutable v4
1316
+ val._iterable // from ECMAScript collection in immutable v3
1317
+ ? (0, _collections$1.printIteratorValues)(
1318
+ val.values(),
1319
+ config,
1320
+ indentation,
1321
+ depth,
1322
+ refs,
1323
+ printer
1324
+ )
1325
+ : LAZY) +
1326
+ ']'
1327
+ );
1328
+ };
1329
+
1330
+ const printImmutableValues = (
1331
+ val,
1332
+ config,
1333
+ indentation,
1334
+ depth,
1335
+ refs,
1336
+ printer,
1337
+ type
1338
+ ) =>
1339
+ ++depth > config.maxDepth
1340
+ ? printAsLeaf(getImmutableName(type))
1341
+ : getImmutableName(type) +
1342
+ SPACE +
1343
+ '[' +
1344
+ (0, _collections$1.printIteratorValues)(
1345
+ val.values(),
1346
+ config,
1347
+ indentation,
1348
+ depth,
1349
+ refs,
1350
+ printer
1351
+ ) +
1352
+ ']';
1353
+
1354
+ const serialize$4 = (val, config, indentation, depth, refs, printer) => {
1355
+ if (val[IS_MAP_SENTINEL]) {
1356
+ return printImmutableEntries(
1357
+ val,
1358
+ config,
1359
+ indentation,
1360
+ depth,
1361
+ refs,
1362
+ printer,
1363
+ val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map'
1364
+ );
1365
+ }
1366
+
1367
+ if (val[IS_LIST_SENTINEL]) {
1368
+ return printImmutableValues(
1369
+ val,
1370
+ config,
1371
+ indentation,
1372
+ depth,
1373
+ refs,
1374
+ printer,
1375
+ 'List'
1376
+ );
1377
+ }
1378
+
1379
+ if (val[IS_SET_SENTINEL]) {
1380
+ return printImmutableValues(
1381
+ val,
1382
+ config,
1383
+ indentation,
1384
+ depth,
1385
+ refs,
1386
+ printer,
1387
+ val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set'
1388
+ );
1389
+ }
1390
+
1391
+ if (val[IS_STACK_SENTINEL]) {
1392
+ return printImmutableValues(
1393
+ val,
1394
+ config,
1395
+ indentation,
1396
+ depth,
1397
+ refs,
1398
+ printer,
1399
+ 'Stack'
1400
+ );
1401
+ }
1402
+
1403
+ if (val[IS_SEQ_SENTINEL]) {
1404
+ return printImmutableSeq(val, config, indentation, depth, refs, printer);
1405
+ } // For compatibility with immutable v3 and v4, let record be the default.
1406
+
1407
+ return printImmutableRecord(val, config, indentation, depth, refs, printer);
1408
+ }; // Explicitly comparing sentinel properties to true avoids false positive
1409
+ // when mock identity-obj-proxy returns the key as the value for any key.
1410
+
1411
+ Immutable$1.serialize = serialize$4;
1412
+
1413
+ const test$3 = val =>
1414
+ val &&
1415
+ (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
1416
+
1417
+ Immutable$1.test = test$3;
1418
+ const plugin$3 = {
1419
+ serialize: serialize$4,
1420
+ test: test$3
1421
+ };
1422
+ var _default$3 = plugin$3;
1423
+ Immutable$1.default = _default$3;
1424
+
1425
+ var ReactElement$1 = {};
1426
+
1427
+ var reactIs = {exports: {}};
1428
+
1429
+ var reactIs_production_min = {};
1430
+
1431
+ /** @license React v17.0.2
1432
+ * react-is.production.min.js
1433
+ *
1434
+ * Copyright (c) Facebook, Inc. and its affiliates.
1435
+ *
1436
+ * This source code is licensed under the MIT license found in the
1437
+ * LICENSE file in the root directory of this source tree.
1438
+ */
1439
+
1440
+ var hasRequiredReactIs_production_min;
1441
+
1442
+ function requireReactIs_production_min () {
1443
+ if (hasRequiredReactIs_production_min) return reactIs_production_min;
1444
+ hasRequiredReactIs_production_min = 1;
1445
+ var b=60103,c=60106,d=60107,e=60108,f=60114,g=60109,h=60110,k=60112,l=60113,m=60120,n=60115,p=60116,q=60121,r=60122,u=60117,v=60129,w=60131;
1446
+ if("function"===typeof Symbol&&Symbol.for){var x=Symbol.for;b=x("react.element");c=x("react.portal");d=x("react.fragment");e=x("react.strict_mode");f=x("react.profiler");g=x("react.provider");h=x("react.context");k=x("react.forward_ref");l=x("react.suspense");m=x("react.suspense_list");n=x("react.memo");p=x("react.lazy");q=x("react.block");r=x("react.server.block");u=x("react.fundamental");v=x("react.debug_trace_mode");w=x("react.legacy_hidden");}
1447
+ function y(a){if("object"===typeof a&&null!==a){var t=a.$$typeof;switch(t){case b:switch(a=a.type,a){case d:case f:case e:case l:case m:return a;default:switch(a=a&&a.$$typeof,a){case h:case k:case p:case n:case g:return a;default:return t}}case c:return t}}}var z=g,A=b,B=k,C=d,D=p,E=n,F=c,G=f,H=e,I=l;reactIs_production_min.ContextConsumer=h;reactIs_production_min.ContextProvider=z;reactIs_production_min.Element=A;reactIs_production_min.ForwardRef=B;reactIs_production_min.Fragment=C;reactIs_production_min.Lazy=D;reactIs_production_min.Memo=E;reactIs_production_min.Portal=F;reactIs_production_min.Profiler=G;reactIs_production_min.StrictMode=H;
1448
+ reactIs_production_min.Suspense=I;reactIs_production_min.isAsyncMode=function(){return !1};reactIs_production_min.isConcurrentMode=function(){return !1};reactIs_production_min.isContextConsumer=function(a){return y(a)===h};reactIs_production_min.isContextProvider=function(a){return y(a)===g};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===b};reactIs_production_min.isForwardRef=function(a){return y(a)===k};reactIs_production_min.isFragment=function(a){return y(a)===d};reactIs_production_min.isLazy=function(a){return y(a)===p};reactIs_production_min.isMemo=function(a){return y(a)===n};
1449
+ reactIs_production_min.isPortal=function(a){return y(a)===c};reactIs_production_min.isProfiler=function(a){return y(a)===f};reactIs_production_min.isStrictMode=function(a){return y(a)===e};reactIs_production_min.isSuspense=function(a){return y(a)===l};reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===d||a===f||a===v||a===e||a===l||a===m||a===w||"object"===typeof a&&null!==a&&(a.$$typeof===p||a.$$typeof===n||a.$$typeof===g||a.$$typeof===h||a.$$typeof===k||a.$$typeof===u||a.$$typeof===q||a[0]===r)?!0:!1};
1450
+ reactIs_production_min.typeOf=y;
1451
+ return reactIs_production_min;
1452
+ }
1453
+
1454
+ var reactIs_development = {};
1455
+
1456
+ /** @license React v17.0.2
1457
+ * react-is.development.js
1458
+ *
1459
+ * Copyright (c) Facebook, Inc. and its affiliates.
1460
+ *
1461
+ * This source code is licensed under the MIT license found in the
1462
+ * LICENSE file in the root directory of this source tree.
1463
+ */
1464
+
1465
+ var hasRequiredReactIs_development;
1466
+
1467
+ function requireReactIs_development () {
1468
+ if (hasRequiredReactIs_development) return reactIs_development;
1469
+ hasRequiredReactIs_development = 1;
1470
+
1471
+ if (process.env.NODE_ENV !== "production") {
1472
+ (function() {
1473
+
1474
+ // ATTENTION
1475
+ // When adding new symbols to this file,
1476
+ // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
1477
+ // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
1478
+ // nor polyfill, then a plain number is used for performance.
1479
+ var REACT_ELEMENT_TYPE = 0xeac7;
1480
+ var REACT_PORTAL_TYPE = 0xeaca;
1481
+ var REACT_FRAGMENT_TYPE = 0xeacb;
1482
+ var REACT_STRICT_MODE_TYPE = 0xeacc;
1483
+ var REACT_PROFILER_TYPE = 0xead2;
1484
+ var REACT_PROVIDER_TYPE = 0xeacd;
1485
+ var REACT_CONTEXT_TYPE = 0xeace;
1486
+ var REACT_FORWARD_REF_TYPE = 0xead0;
1487
+ var REACT_SUSPENSE_TYPE = 0xead1;
1488
+ var REACT_SUSPENSE_LIST_TYPE = 0xead8;
1489
+ var REACT_MEMO_TYPE = 0xead3;
1490
+ var REACT_LAZY_TYPE = 0xead4;
1491
+ var REACT_BLOCK_TYPE = 0xead9;
1492
+ var REACT_SERVER_BLOCK_TYPE = 0xeada;
1493
+ var REACT_FUNDAMENTAL_TYPE = 0xead5;
1494
+ var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
1495
+ var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
1496
+
1497
+ if (typeof Symbol === 'function' && Symbol.for) {
1498
+ var symbolFor = Symbol.for;
1499
+ REACT_ELEMENT_TYPE = symbolFor('react.element');
1500
+ REACT_PORTAL_TYPE = symbolFor('react.portal');
1501
+ REACT_FRAGMENT_TYPE = symbolFor('react.fragment');
1502
+ REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
1503
+ REACT_PROFILER_TYPE = symbolFor('react.profiler');
1504
+ REACT_PROVIDER_TYPE = symbolFor('react.provider');
1505
+ REACT_CONTEXT_TYPE = symbolFor('react.context');
1506
+ REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
1507
+ REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
1508
+ REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
1509
+ REACT_MEMO_TYPE = symbolFor('react.memo');
1510
+ REACT_LAZY_TYPE = symbolFor('react.lazy');
1511
+ REACT_BLOCK_TYPE = symbolFor('react.block');
1512
+ REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
1513
+ REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
1514
+ symbolFor('react.scope');
1515
+ symbolFor('react.opaque.id');
1516
+ REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
1517
+ symbolFor('react.offscreen');
1518
+ REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
1519
+ }
1520
+
1521
+ // Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
1522
+
1523
+ var enableScopeAPI = false; // Experimental Create Event Handle API.
1524
+
1525
+ function isValidElementType(type) {
1526
+ if (typeof type === 'string' || typeof type === 'function') {
1527
+ return true;
1528
+ } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
1529
+
1530
+
1531
+ if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
1532
+ return true;
1533
+ }
1534
+
1535
+ if (typeof type === 'object' && type !== null) {
1536
+ if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
1537
+ return true;
1538
+ }
1539
+ }
1540
+
1541
+ return false;
1542
+ }
1543
+
1544
+ function typeOf(object) {
1545
+ if (typeof object === 'object' && object !== null) {
1546
+ var $$typeof = object.$$typeof;
1547
+
1548
+ switch ($$typeof) {
1549
+ case REACT_ELEMENT_TYPE:
1550
+ var type = object.type;
1551
+
1552
+ switch (type) {
1553
+ case REACT_FRAGMENT_TYPE:
1554
+ case REACT_PROFILER_TYPE:
1555
+ case REACT_STRICT_MODE_TYPE:
1556
+ case REACT_SUSPENSE_TYPE:
1557
+ case REACT_SUSPENSE_LIST_TYPE:
1558
+ return type;
1559
+
1560
+ default:
1561
+ var $$typeofType = type && type.$$typeof;
1562
+
1563
+ switch ($$typeofType) {
1564
+ case REACT_CONTEXT_TYPE:
1565
+ case REACT_FORWARD_REF_TYPE:
1566
+ case REACT_LAZY_TYPE:
1567
+ case REACT_MEMO_TYPE:
1568
+ case REACT_PROVIDER_TYPE:
1569
+ return $$typeofType;
1570
+
1571
+ default:
1572
+ return $$typeof;
1573
+ }
1574
+
1575
+ }
1576
+
1577
+ case REACT_PORTAL_TYPE:
1578
+ return $$typeof;
1579
+ }
1580
+ }
1581
+
1582
+ return undefined;
1583
+ }
1584
+ var ContextConsumer = REACT_CONTEXT_TYPE;
1585
+ var ContextProvider = REACT_PROVIDER_TYPE;
1586
+ var Element = REACT_ELEMENT_TYPE;
1587
+ var ForwardRef = REACT_FORWARD_REF_TYPE;
1588
+ var Fragment = REACT_FRAGMENT_TYPE;
1589
+ var Lazy = REACT_LAZY_TYPE;
1590
+ var Memo = REACT_MEMO_TYPE;
1591
+ var Portal = REACT_PORTAL_TYPE;
1592
+ var Profiler = REACT_PROFILER_TYPE;
1593
+ var StrictMode = REACT_STRICT_MODE_TYPE;
1594
+ var Suspense = REACT_SUSPENSE_TYPE;
1595
+ var hasWarnedAboutDeprecatedIsAsyncMode = false;
1596
+ var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
1597
+
1598
+ function isAsyncMode(object) {
1599
+ {
1600
+ if (!hasWarnedAboutDeprecatedIsAsyncMode) {
1601
+ hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
1602
+
1603
+ console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
1604
+ }
1605
+ }
1606
+
1607
+ return false;
1608
+ }
1609
+ function isConcurrentMode(object) {
1610
+ {
1611
+ if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
1612
+ hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
1613
+
1614
+ console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
1615
+ }
1616
+ }
1617
+
1618
+ return false;
1619
+ }
1620
+ function isContextConsumer(object) {
1621
+ return typeOf(object) === REACT_CONTEXT_TYPE;
1622
+ }
1623
+ function isContextProvider(object) {
1624
+ return typeOf(object) === REACT_PROVIDER_TYPE;
1625
+ }
1626
+ function isElement(object) {
1627
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1628
+ }
1629
+ function isForwardRef(object) {
1630
+ return typeOf(object) === REACT_FORWARD_REF_TYPE;
1631
+ }
1632
+ function isFragment(object) {
1633
+ return typeOf(object) === REACT_FRAGMENT_TYPE;
1634
+ }
1635
+ function isLazy(object) {
1636
+ return typeOf(object) === REACT_LAZY_TYPE;
1637
+ }
1638
+ function isMemo(object) {
1639
+ return typeOf(object) === REACT_MEMO_TYPE;
1640
+ }
1641
+ function isPortal(object) {
1642
+ return typeOf(object) === REACT_PORTAL_TYPE;
1643
+ }
1644
+ function isProfiler(object) {
1645
+ return typeOf(object) === REACT_PROFILER_TYPE;
1646
+ }
1647
+ function isStrictMode(object) {
1648
+ return typeOf(object) === REACT_STRICT_MODE_TYPE;
1649
+ }
1650
+ function isSuspense(object) {
1651
+ return typeOf(object) === REACT_SUSPENSE_TYPE;
1652
+ }
1653
+
1654
+ reactIs_development.ContextConsumer = ContextConsumer;
1655
+ reactIs_development.ContextProvider = ContextProvider;
1656
+ reactIs_development.Element = Element;
1657
+ reactIs_development.ForwardRef = ForwardRef;
1658
+ reactIs_development.Fragment = Fragment;
1659
+ reactIs_development.Lazy = Lazy;
1660
+ reactIs_development.Memo = Memo;
1661
+ reactIs_development.Portal = Portal;
1662
+ reactIs_development.Profiler = Profiler;
1663
+ reactIs_development.StrictMode = StrictMode;
1664
+ reactIs_development.Suspense = Suspense;
1665
+ reactIs_development.isAsyncMode = isAsyncMode;
1666
+ reactIs_development.isConcurrentMode = isConcurrentMode;
1667
+ reactIs_development.isContextConsumer = isContextConsumer;
1668
+ reactIs_development.isContextProvider = isContextProvider;
1669
+ reactIs_development.isElement = isElement;
1670
+ reactIs_development.isForwardRef = isForwardRef;
1671
+ reactIs_development.isFragment = isFragment;
1672
+ reactIs_development.isLazy = isLazy;
1673
+ reactIs_development.isMemo = isMemo;
1674
+ reactIs_development.isPortal = isPortal;
1675
+ reactIs_development.isProfiler = isProfiler;
1676
+ reactIs_development.isStrictMode = isStrictMode;
1677
+ reactIs_development.isSuspense = isSuspense;
1678
+ reactIs_development.isValidElementType = isValidElementType;
1679
+ reactIs_development.typeOf = typeOf;
1680
+ })();
1681
+ }
1682
+ return reactIs_development;
1683
+ }
1684
+
1685
+ (function (module) {
1686
+
1687
+ if (process.env.NODE_ENV === 'production') {
1688
+ module.exports = requireReactIs_production_min();
1689
+ } else {
1690
+ module.exports = requireReactIs_development();
1691
+ }
1692
+ } (reactIs));
1693
+
1694
+ Object.defineProperty(ReactElement$1, '__esModule', {
1695
+ value: true
1696
+ });
1697
+ ReactElement$1.test = ReactElement$1.serialize = ReactElement$1.default = void 0;
1698
+
1699
+ var ReactIs = _interopRequireWildcard(reactIs.exports);
1700
+
1701
+ var _markup$1 = markup;
1702
+
1703
+ function _getRequireWildcardCache(nodeInterop) {
1704
+ if (typeof WeakMap !== 'function') return null;
1705
+ var cacheBabelInterop = new WeakMap();
1706
+ var cacheNodeInterop = new WeakMap();
1707
+ return (_getRequireWildcardCache = function (nodeInterop) {
1708
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
1709
+ })(nodeInterop);
1710
+ }
1711
+
1712
+ function _interopRequireWildcard(obj, nodeInterop) {
1713
+ if (!nodeInterop && obj && obj.__esModule) {
1714
+ return obj;
1715
+ }
1716
+ if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
1717
+ return {default: obj};
1718
+ }
1719
+ var cache = _getRequireWildcardCache(nodeInterop);
1720
+ if (cache && cache.has(obj)) {
1721
+ return cache.get(obj);
1722
+ }
1723
+ var newObj = {};
1724
+ var hasPropertyDescriptor =
1725
+ Object.defineProperty && Object.getOwnPropertyDescriptor;
1726
+ for (var key in obj) {
1727
+ if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
1728
+ var desc = hasPropertyDescriptor
1729
+ ? Object.getOwnPropertyDescriptor(obj, key)
1730
+ : null;
1731
+ if (desc && (desc.get || desc.set)) {
1732
+ Object.defineProperty(newObj, key, desc);
1733
+ } else {
1734
+ newObj[key] = obj[key];
1735
+ }
1736
+ }
1737
+ }
1738
+ newObj.default = obj;
1739
+ if (cache) {
1740
+ cache.set(obj, newObj);
1741
+ }
1742
+ return newObj;
1743
+ }
1744
+
1745
+ /**
1746
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1747
+ *
1748
+ * This source code is licensed under the MIT license found in the
1749
+ * LICENSE file in the root directory of this source tree.
1750
+ */
1751
+ // Given element.props.children, or subtree during recursive traversal,
1752
+ // return flattened array of children.
1753
+ const getChildren = (arg, children = []) => {
1754
+ if (Array.isArray(arg)) {
1755
+ arg.forEach(item => {
1756
+ getChildren(item, children);
1757
+ });
1758
+ } else if (arg != null && arg !== false) {
1759
+ children.push(arg);
1760
+ }
1761
+
1762
+ return children;
1763
+ };
1764
+
1765
+ const getType = element => {
1766
+ const type = element.type;
1767
+
1768
+ if (typeof type === 'string') {
1769
+ return type;
1770
+ }
1771
+
1772
+ if (typeof type === 'function') {
1773
+ return type.displayName || type.name || 'Unknown';
1774
+ }
1775
+
1776
+ if (ReactIs.isFragment(element)) {
1777
+ return 'React.Fragment';
1778
+ }
1779
+
1780
+ if (ReactIs.isSuspense(element)) {
1781
+ return 'React.Suspense';
1782
+ }
1783
+
1784
+ if (typeof type === 'object' && type !== null) {
1785
+ if (ReactIs.isContextProvider(element)) {
1786
+ return 'Context.Provider';
1787
+ }
1788
+
1789
+ if (ReactIs.isContextConsumer(element)) {
1790
+ return 'Context.Consumer';
1791
+ }
1792
+
1793
+ if (ReactIs.isForwardRef(element)) {
1794
+ if (type.displayName) {
1795
+ return type.displayName;
1796
+ }
1797
+
1798
+ const functionName = type.render.displayName || type.render.name || '';
1799
+ return functionName !== ''
1800
+ ? 'ForwardRef(' + functionName + ')'
1801
+ : 'ForwardRef';
1802
+ }
1803
+
1804
+ if (ReactIs.isMemo(element)) {
1805
+ const functionName =
1806
+ type.displayName || type.type.displayName || type.type.name || '';
1807
+ return functionName !== '' ? 'Memo(' + functionName + ')' : 'Memo';
1808
+ }
1809
+ }
1810
+
1811
+ return 'UNDEFINED';
1812
+ };
1813
+
1814
+ const getPropKeys$1 = element => {
1815
+ const {props} = element;
1816
+ return Object.keys(props)
1817
+ .filter(key => key !== 'children' && props[key] !== undefined)
1818
+ .sort();
1819
+ };
1820
+
1821
+ const serialize$3 = (element, config, indentation, depth, refs, printer) =>
1822
+ ++depth > config.maxDepth
1823
+ ? (0, _markup$1.printElementAsLeaf)(getType(element), config)
1824
+ : (0, _markup$1.printElement)(
1825
+ getType(element),
1826
+ (0, _markup$1.printProps)(
1827
+ getPropKeys$1(element),
1828
+ element.props,
1829
+ config,
1830
+ indentation + config.indent,
1831
+ depth,
1832
+ refs,
1833
+ printer
1834
+ ),
1835
+ (0, _markup$1.printChildren)(
1836
+ getChildren(element.props.children),
1837
+ config,
1838
+ indentation + config.indent,
1839
+ depth,
1840
+ refs,
1841
+ printer
1842
+ ),
1843
+ config,
1844
+ indentation
1845
+ );
1846
+
1847
+ ReactElement$1.serialize = serialize$3;
1848
+
1849
+ const test$2 = val => val != null && ReactIs.isElement(val);
1850
+
1851
+ ReactElement$1.test = test$2;
1852
+ const plugin$2 = {
1853
+ serialize: serialize$3,
1854
+ test: test$2
1855
+ };
1856
+ var _default$2 = plugin$2;
1857
+ ReactElement$1.default = _default$2;
1858
+
1859
+ var ReactTestComponent$1 = {};
1860
+
1861
+ Object.defineProperty(ReactTestComponent$1, '__esModule', {
1862
+ value: true
1863
+ });
1864
+ ReactTestComponent$1.test = ReactTestComponent$1.serialize = ReactTestComponent$1.default = void 0;
1865
+
1866
+ var _markup = markup;
1867
+
1868
+ var global$1 = (function () {
1869
+ if (typeof globalThis !== 'undefined') {
1870
+ return globalThis;
1871
+ } else if (typeof global$1 !== 'undefined') {
1872
+ return global$1;
1873
+ } else if (typeof self !== 'undefined') {
1874
+ return self;
1875
+ } else if (typeof window !== 'undefined') {
1876
+ return window;
1877
+ } else {
1878
+ return Function('return this')();
1879
+ }
1880
+ })();
1881
+
1882
+ var Symbol$1 = global$1['jest-symbol-do-not-touch'] || global$1.Symbol;
1883
+ const testSymbol =
1884
+ typeof Symbol$1 === 'function' && Symbol$1.for
1885
+ ? Symbol$1.for('react.test.json')
1886
+ : 0xea71357;
1887
+
1888
+ const getPropKeys = object => {
1889
+ const {props} = object;
1890
+ return props
1891
+ ? Object.keys(props)
1892
+ .filter(key => props[key] !== undefined)
1893
+ .sort()
1894
+ : [];
1895
+ };
1896
+
1897
+ const serialize$2 = (object, config, indentation, depth, refs, printer) =>
1898
+ ++depth > config.maxDepth
1899
+ ? (0, _markup.printElementAsLeaf)(object.type, config)
1900
+ : (0, _markup.printElement)(
1901
+ object.type,
1902
+ object.props
1903
+ ? (0, _markup.printProps)(
1904
+ getPropKeys(object),
1905
+ object.props,
1906
+ config,
1907
+ indentation + config.indent,
1908
+ depth,
1909
+ refs,
1910
+ printer
1911
+ )
1912
+ : '',
1913
+ object.children
1914
+ ? (0, _markup.printChildren)(
1915
+ object.children,
1916
+ config,
1917
+ indentation + config.indent,
1918
+ depth,
1919
+ refs,
1920
+ printer
1921
+ )
1922
+ : '',
1923
+ config,
1924
+ indentation
1925
+ );
1926
+
1927
+ ReactTestComponent$1.serialize = serialize$2;
1928
+
1929
+ const test$1 = val => val && val.$$typeof === testSymbol;
1930
+
1931
+ ReactTestComponent$1.test = test$1;
1932
+ const plugin$1 = {
1933
+ serialize: serialize$2,
1934
+ test: test$1
1935
+ };
1936
+ var _default$1 = plugin$1;
1937
+ ReactTestComponent$1.default = _default$1;
1938
+
1939
+ Object.defineProperty(build, '__esModule', {
1940
+ value: true
1941
+ });
1942
+ build.default = build.DEFAULT_OPTIONS = void 0;
1943
+ var format_1 = build.format = format;
1944
+ var plugins_1 = build.plugins = void 0;
1945
+
1946
+ var _ansiStyles = _interopRequireDefault(ansiStyles.exports);
1947
+
1948
+ var _collections = collections;
1949
+
1950
+ var _AsymmetricMatcher = _interopRequireDefault(
1951
+ AsymmetricMatcher$1
1952
+ );
1953
+
1954
+ var _ConvertAnsi = _interopRequireDefault(ConvertAnsi);
1955
+
1956
+ var _DOMCollection = _interopRequireDefault(DOMCollection$1);
1957
+
1958
+ var _DOMElement = _interopRequireDefault(DOMElement$1);
1959
+
1960
+ var _Immutable = _interopRequireDefault(Immutable$1);
1961
+
1962
+ var _ReactElement = _interopRequireDefault(ReactElement$1);
1963
+
1964
+ var _ReactTestComponent = _interopRequireDefault(
1965
+ ReactTestComponent$1
1966
+ );
1967
+
1968
+ function _interopRequireDefault(obj) {
1969
+ return obj && obj.__esModule ? obj : {default: obj};
1970
+ }
1971
+
1972
+ /**
1973
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1974
+ *
1975
+ * This source code is licensed under the MIT license found in the
1976
+ * LICENSE file in the root directory of this source tree.
1977
+ */
1978
+
1979
+ /* eslint-disable local/ban-types-eventually */
1980
+ const toString = Object.prototype.toString;
1981
+ const toISOString = Date.prototype.toISOString;
1982
+ const errorToString = Error.prototype.toString;
1983
+ const regExpToString = RegExp.prototype.toString;
1984
+ /**
1985
+ * Explicitly comparing typeof constructor to function avoids undefined as name
1986
+ * when mock identity-obj-proxy returns the key as the value for any key.
1987
+ */
1988
+
1989
+ const getConstructorName = val =>
1990
+ (typeof val.constructor === 'function' && val.constructor.name) || 'Object';
1991
+ /* global window */
1992
+
1993
+ /** Is val is equal to global window object? Works even if it does not exist :) */
1994
+
1995
+ const isWindow = val => typeof window !== 'undefined' && val === window;
1996
+
1997
+ const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
1998
+ const NEWLINE_REGEXP = /\n/gi;
1999
+
2000
+ class PrettyFormatPluginError extends Error {
2001
+ constructor(message, stack) {
2002
+ super(message);
2003
+ this.stack = stack;
2004
+ this.name = this.constructor.name;
2005
+ }
2006
+ }
2007
+
2008
+ function isToStringedArrayType(toStringed) {
2009
+ return (
2010
+ toStringed === '[object Array]' ||
2011
+ toStringed === '[object ArrayBuffer]' ||
2012
+ toStringed === '[object DataView]' ||
2013
+ toStringed === '[object Float32Array]' ||
2014
+ toStringed === '[object Float64Array]' ||
2015
+ toStringed === '[object Int8Array]' ||
2016
+ toStringed === '[object Int16Array]' ||
2017
+ toStringed === '[object Int32Array]' ||
2018
+ toStringed === '[object Uint8Array]' ||
2019
+ toStringed === '[object Uint8ClampedArray]' ||
2020
+ toStringed === '[object Uint16Array]' ||
2021
+ toStringed === '[object Uint32Array]'
2022
+ );
2023
+ }
2024
+
2025
+ function printNumber(val) {
2026
+ return Object.is(val, -0) ? '-0' : String(val);
2027
+ }
2028
+
2029
+ function printBigInt(val) {
2030
+ return String(`${val}n`);
2031
+ }
2032
+
2033
+ function printFunction(val, printFunctionName) {
2034
+ if (!printFunctionName) {
2035
+ return '[Function]';
2036
+ }
2037
+
2038
+ return '[Function ' + (val.name || 'anonymous') + ']';
2039
+ }
2040
+
2041
+ function printSymbol(val) {
2042
+ return String(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
2043
+ }
2044
+
2045
+ function printError(val) {
2046
+ return '[' + errorToString.call(val) + ']';
2047
+ }
2048
+ /**
2049
+ * The first port of call for printing an object, handles most of the
2050
+ * data-types in JS.
2051
+ */
2052
+
2053
+ function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
2054
+ if (val === true || val === false) {
2055
+ return '' + val;
2056
+ }
2057
+
2058
+ if (val === undefined) {
2059
+ return 'undefined';
2060
+ }
2061
+
2062
+ if (val === null) {
2063
+ return 'null';
2064
+ }
2065
+
2066
+ const typeOf = typeof val;
2067
+
2068
+ if (typeOf === 'number') {
2069
+ return printNumber(val);
2070
+ }
2071
+
2072
+ if (typeOf === 'bigint') {
2073
+ return printBigInt(val);
2074
+ }
2075
+
2076
+ if (typeOf === 'string') {
2077
+ if (escapeString) {
2078
+ return '"' + val.replace(/"|\\/g, '\\$&') + '"';
2079
+ }
2080
+
2081
+ return '"' + val + '"';
2082
+ }
2083
+
2084
+ if (typeOf === 'function') {
2085
+ return printFunction(val, printFunctionName);
2086
+ }
2087
+
2088
+ if (typeOf === 'symbol') {
2089
+ return printSymbol(val);
2090
+ }
2091
+
2092
+ const toStringed = toString.call(val);
2093
+
2094
+ if (toStringed === '[object WeakMap]') {
2095
+ return 'WeakMap {}';
2096
+ }
2097
+
2098
+ if (toStringed === '[object WeakSet]') {
2099
+ return 'WeakSet {}';
2100
+ }
2101
+
2102
+ if (
2103
+ toStringed === '[object Function]' ||
2104
+ toStringed === '[object GeneratorFunction]'
2105
+ ) {
2106
+ return printFunction(val, printFunctionName);
2107
+ }
38
2108
 
39
- const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
40
- const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
41
- const beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
42
- const afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
43
- const onTestFailed = createTestHook("onTestFailed", (test, handler) => {
44
- test.onFailed || (test.onFailed = []);
45
- test.onFailed.push(handler);
46
- });
47
- function createTestHook(name, handler) {
48
- return (fn) => {
49
- const current = getCurrentTest();
50
- if (!current)
51
- throw new Error(`Hook ${name}() can only be called inside a test`);
52
- handler(current, fn);
2109
+ if (toStringed === '[object Symbol]') {
2110
+ return printSymbol(val);
2111
+ }
2112
+
2113
+ if (toStringed === '[object Date]') {
2114
+ return isNaN(+val) ? 'Date { NaN }' : toISOString.call(val);
2115
+ }
2116
+
2117
+ if (toStringed === '[object Error]') {
2118
+ return printError(val);
2119
+ }
2120
+
2121
+ if (toStringed === '[object RegExp]') {
2122
+ if (escapeRegex) {
2123
+ // https://github.com/benjamingr/RegExp.escape/blob/main/polyfill.js
2124
+ return regExpToString.call(val).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
2125
+ }
2126
+
2127
+ return regExpToString.call(val);
2128
+ }
2129
+
2130
+ if (val instanceof Error) {
2131
+ return printError(val);
2132
+ }
2133
+
2134
+ return null;
2135
+ }
2136
+ /**
2137
+ * Handles more complex objects ( such as objects with circular references.
2138
+ * maps and sets etc )
2139
+ */
2140
+
2141
+ function printComplexValue(
2142
+ val,
2143
+ config,
2144
+ indentation,
2145
+ depth,
2146
+ refs,
2147
+ hasCalledToJSON
2148
+ ) {
2149
+ if (refs.indexOf(val) !== -1) {
2150
+ return '[Circular]';
2151
+ }
2152
+
2153
+ refs = refs.slice();
2154
+ refs.push(val);
2155
+ const hitMaxDepth = ++depth > config.maxDepth;
2156
+ const min = config.min;
2157
+
2158
+ if (
2159
+ config.callToJSON &&
2160
+ !hitMaxDepth &&
2161
+ val.toJSON &&
2162
+ typeof val.toJSON === 'function' &&
2163
+ !hasCalledToJSON
2164
+ ) {
2165
+ return printer(val.toJSON(), config, indentation, depth, refs, true);
2166
+ }
2167
+
2168
+ const toStringed = toString.call(val);
2169
+
2170
+ if (toStringed === '[object Arguments]') {
2171
+ return hitMaxDepth
2172
+ ? '[Arguments]'
2173
+ : (min ? '' : 'Arguments ') +
2174
+ '[' +
2175
+ (0, _collections.printListItems)(
2176
+ val,
2177
+ config,
2178
+ indentation,
2179
+ depth,
2180
+ refs,
2181
+ printer
2182
+ ) +
2183
+ ']';
2184
+ }
2185
+
2186
+ if (isToStringedArrayType(toStringed)) {
2187
+ return hitMaxDepth
2188
+ ? '[' + val.constructor.name + ']'
2189
+ : (min
2190
+ ? ''
2191
+ : !config.printBasicPrototype && val.constructor.name === 'Array'
2192
+ ? ''
2193
+ : val.constructor.name + ' ') +
2194
+ '[' +
2195
+ (0, _collections.printListItems)(
2196
+ val,
2197
+ config,
2198
+ indentation,
2199
+ depth,
2200
+ refs,
2201
+ printer
2202
+ ) +
2203
+ ']';
2204
+ }
2205
+
2206
+ if (toStringed === '[object Map]') {
2207
+ return hitMaxDepth
2208
+ ? '[Map]'
2209
+ : 'Map {' +
2210
+ (0, _collections.printIteratorEntries)(
2211
+ val.entries(),
2212
+ config,
2213
+ indentation,
2214
+ depth,
2215
+ refs,
2216
+ printer,
2217
+ ' => '
2218
+ ) +
2219
+ '}';
2220
+ }
2221
+
2222
+ if (toStringed === '[object Set]') {
2223
+ return hitMaxDepth
2224
+ ? '[Set]'
2225
+ : 'Set {' +
2226
+ (0, _collections.printIteratorValues)(
2227
+ val.values(),
2228
+ config,
2229
+ indentation,
2230
+ depth,
2231
+ refs,
2232
+ printer
2233
+ ) +
2234
+ '}';
2235
+ } // Avoid failure to serialize global window object in jsdom test environment.
2236
+ // For example, not even relevant if window is prop of React element.
2237
+
2238
+ return hitMaxDepth || isWindow(val)
2239
+ ? '[' + getConstructorName(val) + ']'
2240
+ : (min
2241
+ ? ''
2242
+ : !config.printBasicPrototype && getConstructorName(val) === 'Object'
2243
+ ? ''
2244
+ : getConstructorName(val) + ' ') +
2245
+ '{' +
2246
+ (0, _collections.printObjectProperties)(
2247
+ val,
2248
+ config,
2249
+ indentation,
2250
+ depth,
2251
+ refs,
2252
+ printer
2253
+ ) +
2254
+ '}';
2255
+ }
2256
+
2257
+ function isNewPlugin(plugin) {
2258
+ return plugin.serialize != null;
2259
+ }
2260
+
2261
+ function printPlugin(plugin, val, config, indentation, depth, refs) {
2262
+ let printed;
2263
+
2264
+ try {
2265
+ printed = isNewPlugin(plugin)
2266
+ ? plugin.serialize(val, config, indentation, depth, refs, printer)
2267
+ : plugin.print(
2268
+ val,
2269
+ valChild => printer(valChild, config, indentation, depth, refs),
2270
+ str => {
2271
+ const indentationNext = indentation + config.indent;
2272
+ return (
2273
+ indentationNext +
2274
+ str.replace(NEWLINE_REGEXP, '\n' + indentationNext)
2275
+ );
2276
+ },
2277
+ {
2278
+ edgeSpacing: config.spacingOuter,
2279
+ min: config.min,
2280
+ spacing: config.spacingInner
2281
+ },
2282
+ config.colors
2283
+ );
2284
+ } catch (error) {
2285
+ throw new PrettyFormatPluginError(error.message, error.stack);
2286
+ }
2287
+
2288
+ if (typeof printed !== 'string') {
2289
+ throw new Error(
2290
+ `pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`
2291
+ );
2292
+ }
2293
+
2294
+ return printed;
2295
+ }
2296
+
2297
+ function findPlugin(plugins, val) {
2298
+ for (let p = 0; p < plugins.length; p++) {
2299
+ try {
2300
+ if (plugins[p].test(val)) {
2301
+ return plugins[p];
2302
+ }
2303
+ } catch (error) {
2304
+ throw new PrettyFormatPluginError(error.message, error.stack);
2305
+ }
2306
+ }
2307
+
2308
+ return null;
2309
+ }
2310
+
2311
+ function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
2312
+ const plugin = findPlugin(config.plugins, val);
2313
+
2314
+ if (plugin !== null) {
2315
+ return printPlugin(plugin, val, config, indentation, depth, refs);
2316
+ }
2317
+
2318
+ const basicResult = printBasicValue(
2319
+ val,
2320
+ config.printFunctionName,
2321
+ config.escapeRegex,
2322
+ config.escapeString
2323
+ );
2324
+
2325
+ if (basicResult !== null) {
2326
+ return basicResult;
2327
+ }
2328
+
2329
+ return printComplexValue(
2330
+ val,
2331
+ config,
2332
+ indentation,
2333
+ depth,
2334
+ refs,
2335
+ hasCalledToJSON
2336
+ );
2337
+ }
2338
+
2339
+ const DEFAULT_THEME = {
2340
+ comment: 'gray',
2341
+ content: 'reset',
2342
+ prop: 'yellow',
2343
+ tag: 'cyan',
2344
+ value: 'green'
2345
+ };
2346
+ const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
2347
+ const DEFAULT_OPTIONS = {
2348
+ callToJSON: true,
2349
+ compareKeys: undefined,
2350
+ escapeRegex: false,
2351
+ escapeString: true,
2352
+ highlight: false,
2353
+ indent: 2,
2354
+ maxDepth: Infinity,
2355
+ min: false,
2356
+ plugins: [],
2357
+ printBasicPrototype: true,
2358
+ printFunctionName: true,
2359
+ theme: DEFAULT_THEME
2360
+ };
2361
+ build.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
2362
+
2363
+ function validateOptions(options) {
2364
+ Object.keys(options).forEach(key => {
2365
+ if (!DEFAULT_OPTIONS.hasOwnProperty(key)) {
2366
+ throw new Error(`pretty-format: Unknown option "${key}".`);
2367
+ }
2368
+ });
2369
+
2370
+ if (options.min && options.indent !== undefined && options.indent !== 0) {
2371
+ throw new Error(
2372
+ 'pretty-format: Options "min" and "indent" cannot be used together.'
2373
+ );
2374
+ }
2375
+
2376
+ if (options.theme !== undefined) {
2377
+ if (options.theme === null) {
2378
+ throw new Error('pretty-format: Option "theme" must not be null.');
2379
+ }
2380
+
2381
+ if (typeof options.theme !== 'object') {
2382
+ throw new Error(
2383
+ `pretty-format: Option "theme" must be of type "object" but instead received "${typeof options.theme}".`
2384
+ );
2385
+ }
2386
+ }
2387
+ }
2388
+
2389
+ const getColorsHighlight = options =>
2390
+ DEFAULT_THEME_KEYS.reduce((colors, key) => {
2391
+ const value =
2392
+ options.theme && options.theme[key] !== undefined
2393
+ ? options.theme[key]
2394
+ : DEFAULT_THEME[key];
2395
+ const color = value && _ansiStyles.default[value];
2396
+
2397
+ if (
2398
+ color &&
2399
+ typeof color.close === 'string' &&
2400
+ typeof color.open === 'string'
2401
+ ) {
2402
+ colors[key] = color;
2403
+ } else {
2404
+ throw new Error(
2405
+ `pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`
2406
+ );
2407
+ }
2408
+
2409
+ return colors;
2410
+ }, Object.create(null));
2411
+
2412
+ const getColorsEmpty = () =>
2413
+ DEFAULT_THEME_KEYS.reduce((colors, key) => {
2414
+ colors[key] = {
2415
+ close: '',
2416
+ open: ''
2417
+ };
2418
+ return colors;
2419
+ }, Object.create(null));
2420
+
2421
+ const getPrintFunctionName = options =>
2422
+ options && options.printFunctionName !== undefined
2423
+ ? options.printFunctionName
2424
+ : DEFAULT_OPTIONS.printFunctionName;
2425
+
2426
+ const getEscapeRegex = options =>
2427
+ options && options.escapeRegex !== undefined
2428
+ ? options.escapeRegex
2429
+ : DEFAULT_OPTIONS.escapeRegex;
2430
+
2431
+ const getEscapeString = options =>
2432
+ options && options.escapeString !== undefined
2433
+ ? options.escapeString
2434
+ : DEFAULT_OPTIONS.escapeString;
2435
+
2436
+ const getConfig = options => {
2437
+ var _options$printBasicPr;
2438
+
2439
+ return {
2440
+ callToJSON:
2441
+ options && options.callToJSON !== undefined
2442
+ ? options.callToJSON
2443
+ : DEFAULT_OPTIONS.callToJSON,
2444
+ colors:
2445
+ options && options.highlight
2446
+ ? getColorsHighlight(options)
2447
+ : getColorsEmpty(),
2448
+ compareKeys:
2449
+ options && typeof options.compareKeys === 'function'
2450
+ ? options.compareKeys
2451
+ : DEFAULT_OPTIONS.compareKeys,
2452
+ escapeRegex: getEscapeRegex(options),
2453
+ escapeString: getEscapeString(options),
2454
+ indent:
2455
+ options && options.min
2456
+ ? ''
2457
+ : createIndent(
2458
+ options && options.indent !== undefined
2459
+ ? options.indent
2460
+ : DEFAULT_OPTIONS.indent
2461
+ ),
2462
+ maxDepth:
2463
+ options && options.maxDepth !== undefined
2464
+ ? options.maxDepth
2465
+ : DEFAULT_OPTIONS.maxDepth,
2466
+ min:
2467
+ options && options.min !== undefined ? options.min : DEFAULT_OPTIONS.min,
2468
+ plugins:
2469
+ options && options.plugins !== undefined
2470
+ ? options.plugins
2471
+ : DEFAULT_OPTIONS.plugins,
2472
+ printBasicPrototype:
2473
+ (_options$printBasicPr =
2474
+ options === null || options === void 0
2475
+ ? void 0
2476
+ : options.printBasicPrototype) !== null &&
2477
+ _options$printBasicPr !== void 0
2478
+ ? _options$printBasicPr
2479
+ : true,
2480
+ printFunctionName: getPrintFunctionName(options),
2481
+ spacingInner: options && options.min ? ' ' : '\n',
2482
+ spacingOuter: options && options.min ? '' : '\n'
53
2483
  };
2484
+ };
2485
+
2486
+ function createIndent(indent) {
2487
+ return new Array(indent + 1).join(' ');
54
2488
  }
2489
+ /**
2490
+ * Returns a presentation string of your `val` object
2491
+ * @param val any potential JavaScript object
2492
+ * @param options Custom settings
2493
+ */
55
2494
 
56
- function withCallback(fn) {
57
- return new Promise(
58
- (resolve, reject) => fn((err) => {
59
- if (err)
60
- reject(err);
61
- else
62
- resolve();
2495
+ function format(val, options) {
2496
+ if (options) {
2497
+ validateOptions(options);
2498
+
2499
+ if (options.plugins) {
2500
+ const plugin = findPlugin(options.plugins, val);
2501
+
2502
+ if (plugin !== null) {
2503
+ return printPlugin(plugin, val, getConfig(options), '', 0, []);
2504
+ }
2505
+ }
2506
+ }
2507
+
2508
+ const basicResult = printBasicValue(
2509
+ val,
2510
+ getPrintFunctionName(options),
2511
+ getEscapeRegex(options),
2512
+ getEscapeString(options)
2513
+ );
2514
+
2515
+ if (basicResult !== null) {
2516
+ return basicResult;
2517
+ }
2518
+
2519
+ return printComplexValue(val, getConfig(options), '', 0, []);
2520
+ }
2521
+
2522
+ const plugins = {
2523
+ AsymmetricMatcher: _AsymmetricMatcher.default,
2524
+ ConvertAnsi: _ConvertAnsi.default,
2525
+ DOMCollection: _DOMCollection.default,
2526
+ DOMElement: _DOMElement.default,
2527
+ Immutable: _Immutable.default,
2528
+ ReactElement: _ReactElement.default,
2529
+ ReactTestComponent: _ReactTestComponent.default
2530
+ };
2531
+ plugins_1 = build.plugins = plugins;
2532
+ var _default = format;
2533
+ build.default = _default;
2534
+
2535
+ const serialize$1 = (val, config, indentation, depth, refs, printer) => {
2536
+ const name = val.getMockName();
2537
+ const nameString = name === "vi.fn()" ? "" : ` ${name}`;
2538
+ let callsString = "";
2539
+ if (val.mock.calls.length !== 0) {
2540
+ const indentationNext = indentation + config.indent;
2541
+ callsString = ` {${config.spacingOuter}${indentationNext}"calls": ${printer(val.mock.calls, config, indentationNext, depth, refs)}${config.min ? ", " : ","}${config.spacingOuter}${indentationNext}"results": ${printer(val.mock.results, config, indentationNext, depth, refs)}${config.min ? "" : ","}${config.spacingOuter}${indentation}}`;
2542
+ }
2543
+ return `[MockFunction${nameString}]${callsString}`;
2544
+ };
2545
+ const test = (val) => val && !!val._isMockFunction;
2546
+ const plugin = { serialize: serialize$1, test };
2547
+
2548
+ const {
2549
+ DOMCollection,
2550
+ DOMElement,
2551
+ Immutable,
2552
+ ReactElement,
2553
+ ReactTestComponent,
2554
+ AsymmetricMatcher
2555
+ } = plugins_1;
2556
+ let PLUGINS = [
2557
+ ReactTestComponent,
2558
+ ReactElement,
2559
+ DOMElement,
2560
+ DOMCollection,
2561
+ Immutable,
2562
+ AsymmetricMatcher,
2563
+ plugin
2564
+ ];
2565
+ const addSerializer = (plugin) => {
2566
+ PLUGINS = [plugin].concat(PLUGINS);
2567
+ };
2568
+ const getSerializers = () => PLUGINS;
2569
+
2570
+ const SNAPSHOT_VERSION = "1";
2571
+ const writeSnapshotVersion = () => `// Vitest Snapshot v${SNAPSHOT_VERSION}`;
2572
+ const testNameToKey = (testName, count) => `${testName} ${count}`;
2573
+ const keyToTestName = (key) => {
2574
+ if (!/ \d+$/.test(key))
2575
+ throw new Error("Snapshot keys must end with a number.");
2576
+ return key.replace(/ \d+$/, "");
2577
+ };
2578
+ const getSnapshotData = (content, options) => {
2579
+ const update = options.updateSnapshot;
2580
+ const data = /* @__PURE__ */ Object.create(null);
2581
+ let snapshotContents = "";
2582
+ let dirty = false;
2583
+ if (content != null) {
2584
+ try {
2585
+ snapshotContents = content;
2586
+ const populate = new Function("exports", snapshotContents);
2587
+ populate(data);
2588
+ } catch {
2589
+ }
2590
+ }
2591
+ const isInvalid = snapshotContents;
2592
+ if ((update === "all" || update === "new") && isInvalid)
2593
+ dirty = true;
2594
+ return { data, dirty };
2595
+ };
2596
+ const addExtraLineBreaks = (string) => string.includes("\n") ? `
2597
+ ${string}
2598
+ ` : string;
2599
+ const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith("\n") && string.endsWith("\n") ? string.slice(1, -1) : string;
2600
+ const escapeRegex = true;
2601
+ const printFunctionName = false;
2602
+ function serialize(val, indent = 2, formatOverrides = {}) {
2603
+ return normalizeNewlines(
2604
+ format_1(val, {
2605
+ escapeRegex,
2606
+ indent,
2607
+ plugins: getSerializers(),
2608
+ printFunctionName,
2609
+ ...formatOverrides
63
2610
  })
64
2611
  );
65
2612
  }
2613
+ function escapeBacktickString(str) {
2614
+ return str.replace(/`|\\|\${/g, "\\$&");
2615
+ }
2616
+ function printBacktickString(str) {
2617
+ return `\`${escapeBacktickString(str)}\``;
2618
+ }
2619
+ async function ensureDirectoryExists(filePath) {
2620
+ try {
2621
+ const environment = getSnapshotEnironment();
2622
+ await environment.prepareDirectory(join(dirname(filePath)));
2623
+ } catch {
2624
+ }
2625
+ }
2626
+ function normalizeNewlines(string) {
2627
+ return string.replace(/\r\n|\r/g, "\n");
2628
+ }
2629
+ async function saveSnapshotFile(snapshotData, snapshotPath) {
2630
+ const environment = getSnapshotEnironment();
2631
+ const snapshots = Object.keys(snapshotData).sort(naturalCompare$1.exports).map(
2632
+ (key) => `exports[${printBacktickString(key)}] = ${printBacktickString(normalizeNewlines(snapshotData[key]))};`
2633
+ );
2634
+ const content = `${writeSnapshotVersion()}
2635
+
2636
+ ${snapshots.join("\n\n")}
2637
+ `;
2638
+ const oldContent = await environment.readSnapshotFile(snapshotPath);
2639
+ const skipWriting = oldContent && oldContent === content;
2640
+ if (skipWriting)
2641
+ return;
2642
+ await ensureDirectoryExists(snapshotPath);
2643
+ await environment.saveSnapshotFile(
2644
+ snapshotPath,
2645
+ content
2646
+ );
2647
+ }
2648
+ function prepareExpected(expected) {
2649
+ function findStartIndent() {
2650
+ var _a, _b;
2651
+ const matchObject = /^( +)}\s+$/m.exec(expected || "");
2652
+ const objectIndent = (_a = matchObject == null ? void 0 : matchObject[1]) == null ? void 0 : _a.length;
2653
+ if (objectIndent)
2654
+ return objectIndent;
2655
+ const matchText = /^\n( +)"/.exec(expected || "");
2656
+ return ((_b = matchText == null ? void 0 : matchText[1]) == null ? void 0 : _b.length) || 0;
2657
+ }
2658
+ const startIndent = findStartIndent();
2659
+ let expectedTrimmed = expected == null ? void 0 : expected.trim();
2660
+ if (startIndent) {
2661
+ expectedTrimmed = expectedTrimmed == null ? void 0 : expectedTrimmed.replace(new RegExp(`^${" ".repeat(startIndent)}`, "gm"), "").replace(/ +}$/, "}");
2662
+ }
2663
+ return expectedTrimmed;
2664
+ }
2665
+ function deepMergeArray(target = [], source = []) {
2666
+ const mergedOutput = Array.from(target);
2667
+ source.forEach((sourceElement, index) => {
2668
+ const targetElement = mergedOutput[index];
2669
+ if (Array.isArray(target[index])) {
2670
+ mergedOutput[index] = deepMergeArray(target[index], sourceElement);
2671
+ } else if (isObject(targetElement)) {
2672
+ mergedOutput[index] = deepMergeSnapshot(target[index], sourceElement);
2673
+ } else {
2674
+ mergedOutput[index] = sourceElement;
2675
+ }
2676
+ });
2677
+ return mergedOutput;
2678
+ }
2679
+ function deepMergeSnapshot(target, source) {
2680
+ if (isObject(target) && isObject(source)) {
2681
+ const mergedOutput = { ...target };
2682
+ Object.keys(source).forEach((key) => {
2683
+ if (isObject(source[key]) && !source[key].$$typeof) {
2684
+ if (!(key in target))
2685
+ Object.assign(mergedOutput, { [key]: source[key] });
2686
+ else
2687
+ mergedOutput[key] = deepMergeSnapshot(target[key], source[key]);
2688
+ } else if (Array.isArray(source[key])) {
2689
+ mergedOutput[key] = deepMergeArray(target[key], source[key]);
2690
+ } else {
2691
+ Object.assign(mergedOutput, { [key]: source[key] });
2692
+ }
2693
+ });
2694
+ return mergedOutput;
2695
+ } else if (Array.isArray(target) && Array.isArray(source)) {
2696
+ return deepMergeArray(target, source);
2697
+ }
2698
+ return target;
2699
+ }
2700
+
2701
+ async function saveInlineSnapshots(snapshots) {
2702
+ const environment = getSnapshotEnironment();
2703
+ const MagicString = (await import('./chunk-magic-string.3a794426.js')).default;
2704
+ const files = new Set(snapshots.map((i) => i.file));
2705
+ await Promise.all(Array.from(files).map(async (file) => {
2706
+ const snaps = snapshots.filter((i) => i.file === file);
2707
+ const code = await environment.readSnapshotFile(file);
2708
+ const s = new MagicString(code);
2709
+ for (const snap of snaps) {
2710
+ const index = positionToOffset(code, snap.line, snap.column);
2711
+ replaceInlineSnap(code, s, index, snap.snapshot);
2712
+ }
2713
+ const transformed = s.toString();
2714
+ if (transformed !== code)
2715
+ await environment.saveSnapshotFile(file, transformed);
2716
+ }));
2717
+ }
2718
+ const startObjectRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\S\s]*\*\/\s*|\/\/.*\s+)*\s*({)/m;
2719
+ function replaceObjectSnap(code, s, index, newSnap) {
2720
+ code = code.slice(index);
2721
+ const startMatch = startObjectRegex.exec(code);
2722
+ if (!startMatch)
2723
+ return false;
2724
+ code = code.slice(startMatch.index);
2725
+ const charIndex = getCallLastIndex(code);
2726
+ if (charIndex === null)
2727
+ return false;
2728
+ s.appendLeft(index + startMatch.index + charIndex, `, ${prepareSnapString(newSnap, code, index)}`);
2729
+ return true;
2730
+ }
2731
+ function prepareSnapString(snap, source, index) {
2732
+ const lineNumber = offsetToLineNumber(source, index);
2733
+ const line = source.split(lineSplitRE)[lineNumber - 1];
2734
+ const indent = line.match(/^\s*/)[0] || "";
2735
+ const indentNext = indent.includes(" ") ? `${indent} ` : `${indent} `;
2736
+ const lines = snap.trim().replace(/\\/g, "\\\\").split(/\n/g);
2737
+ const isOneline = lines.length <= 1;
2738
+ const quote = isOneline ? "'" : "`";
2739
+ if (isOneline)
2740
+ return `'${lines.join("\n").replace(/'/g, "\\'")}'`;
2741
+ else
2742
+ return `${quote}
2743
+ ${lines.map((i) => i ? indentNext + i : "").join("\n").replace(/`/g, "\\`").replace(/\${/g, "\\${")}
2744
+ ${indent}${quote}`;
2745
+ }
2746
+ const startRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\S\s]*\*\/\s*|\/\/.*\s+)*\s*[\w_$]*(['"`\)])/m;
2747
+ function replaceInlineSnap(code, s, index, newSnap) {
2748
+ const startMatch = startRegex.exec(code.slice(index));
2749
+ if (!startMatch)
2750
+ return replaceObjectSnap(code, s, index, newSnap);
2751
+ const quote = startMatch[1];
2752
+ const startIndex = index + startMatch.index + startMatch[0].length;
2753
+ const snapString = prepareSnapString(newSnap, code, index);
2754
+ if (quote === ")") {
2755
+ s.appendRight(startIndex - 1, snapString);
2756
+ return true;
2757
+ }
2758
+ const quoteEndRE = new RegExp(`(?:^|[^\\\\])${quote}`);
2759
+ const endMatch = quoteEndRE.exec(code.slice(startIndex));
2760
+ if (!endMatch)
2761
+ return false;
2762
+ const endIndex = startIndex + endMatch.index + endMatch[0].length;
2763
+ s.overwrite(startIndex - 1, endIndex, snapString);
2764
+ return true;
2765
+ }
2766
+ const INDENTATION_REGEX = /^([^\S\n]*)\S/m;
2767
+ function stripSnapshotIndentation(inlineSnapshot) {
2768
+ const match = inlineSnapshot.match(INDENTATION_REGEX);
2769
+ if (!match || !match[1]) {
2770
+ return inlineSnapshot;
2771
+ }
2772
+ const indentation = match[1];
2773
+ const lines = inlineSnapshot.split(/\n/g);
2774
+ if (lines.length <= 2) {
2775
+ return inlineSnapshot;
2776
+ }
2777
+ if (lines[0].trim() !== "" || lines[lines.length - 1].trim() !== "") {
2778
+ return inlineSnapshot;
2779
+ }
2780
+ for (let i = 1; i < lines.length - 1; i++) {
2781
+ if (lines[i] !== "") {
2782
+ if (lines[i].indexOf(indentation) !== 0) {
2783
+ return inlineSnapshot;
2784
+ }
2785
+ lines[i] = lines[i].substring(indentation.length);
2786
+ }
2787
+ }
2788
+ lines[lines.length - 1] = "";
2789
+ inlineSnapshot = lines.join("\n");
2790
+ return inlineSnapshot;
2791
+ }
2792
+
2793
+ class SnapshotState {
2794
+ constructor(testFilePath, snapshotPath, snapshotContent, options) {
2795
+ this.testFilePath = testFilePath;
2796
+ this.snapshotPath = snapshotPath;
2797
+ const { data, dirty } = getSnapshotData(
2798
+ snapshotContent,
2799
+ options
2800
+ );
2801
+ this._fileExists = snapshotContent != null;
2802
+ this._initialData = data;
2803
+ this._snapshotData = data;
2804
+ this._dirty = dirty;
2805
+ this._inlineSnapshots = [];
2806
+ this._uncheckedKeys = new Set(Object.keys(this._snapshotData));
2807
+ this._counters = /* @__PURE__ */ new Map();
2808
+ this.expand = options.expand || false;
2809
+ this.added = 0;
2810
+ this.matched = 0;
2811
+ this.unmatched = 0;
2812
+ this._updateSnapshot = options.updateSnapshot;
2813
+ this.updated = 0;
2814
+ this._snapshotFormat = {
2815
+ printBasicPrototype: false,
2816
+ ...options.snapshotFormat
2817
+ };
2818
+ this._environment = getSnapshotEnironment();
2819
+ }
2820
+ static async create(testFilePath, options) {
2821
+ const environment = getSnapshotEnironment();
2822
+ const snapshotPath = await environment.resolvePath(testFilePath);
2823
+ const content = await environment.readSnapshotFile(snapshotPath);
2824
+ return new SnapshotState(testFilePath, snapshotPath, content, options);
2825
+ }
2826
+ markSnapshotsAsCheckedForTest(testName) {
2827
+ this._uncheckedKeys.forEach((uncheckedKey) => {
2828
+ if (keyToTestName(uncheckedKey) === testName)
2829
+ this._uncheckedKeys.delete(uncheckedKey);
2830
+ });
2831
+ }
2832
+ _inferInlineSnapshotStack(stacks) {
2833
+ const promiseIndex = stacks.findIndex((i) => i.method.match(/__VITEST_(RESOLVES|REJECTS)__/));
2834
+ if (promiseIndex !== -1)
2835
+ return stacks[promiseIndex + 3];
2836
+ const stackIndex = stacks.findIndex((i) => i.method.includes("__VITEST_INLINE_SNAPSHOT__"));
2837
+ return stackIndex !== -1 ? stacks[stackIndex + 2] : null;
2838
+ }
2839
+ _addSnapshot(key, receivedSerialized, options) {
2840
+ this._dirty = true;
2841
+ if (options.isInline) {
2842
+ const error = options.error || new Error("Unknown error");
2843
+ const stacks = parseStacktrace(error, true);
2844
+ stacks.forEach((i) => i.file = slash(i.file));
2845
+ const stack = this._inferInlineSnapshotStack(stacks);
2846
+ if (!stack) {
2847
+ throw new Error(
2848
+ `Vitest: Couldn't infer stack frame for inline snapshot.
2849
+ ${JSON.stringify(stacks)}`
2850
+ );
2851
+ }
2852
+ stack.column--;
2853
+ this._inlineSnapshots.push({
2854
+ snapshot: receivedSerialized,
2855
+ ...stack
2856
+ });
2857
+ } else {
2858
+ this._snapshotData[key] = receivedSerialized;
2859
+ }
2860
+ }
2861
+ clear() {
2862
+ this._snapshotData = this._initialData;
2863
+ this._counters = /* @__PURE__ */ new Map();
2864
+ this.added = 0;
2865
+ this.matched = 0;
2866
+ this.unmatched = 0;
2867
+ this.updated = 0;
2868
+ this._dirty = false;
2869
+ }
2870
+ async save() {
2871
+ const hasExternalSnapshots = Object.keys(this._snapshotData).length;
2872
+ const hasInlineSnapshots = this._inlineSnapshots.length;
2873
+ const isEmpty = !hasExternalSnapshots && !hasInlineSnapshots;
2874
+ const status = {
2875
+ deleted: false,
2876
+ saved: false
2877
+ };
2878
+ if ((this._dirty || this._uncheckedKeys.size) && !isEmpty) {
2879
+ if (hasExternalSnapshots) {
2880
+ await saveSnapshotFile(this._snapshotData, this.snapshotPath);
2881
+ this._fileExists = true;
2882
+ }
2883
+ if (hasInlineSnapshots)
2884
+ await saveInlineSnapshots(this._inlineSnapshots);
2885
+ status.saved = true;
2886
+ } else if (!hasExternalSnapshots && this._fileExists) {
2887
+ if (this._updateSnapshot === "all") {
2888
+ await this._environment.removeSnapshotFile(this.snapshotPath);
2889
+ this._fileExists = false;
2890
+ }
2891
+ status.deleted = true;
2892
+ }
2893
+ return status;
2894
+ }
2895
+ getUncheckedCount() {
2896
+ return this._uncheckedKeys.size || 0;
2897
+ }
2898
+ getUncheckedKeys() {
2899
+ return Array.from(this._uncheckedKeys);
2900
+ }
2901
+ removeUncheckedKeys() {
2902
+ if (this._updateSnapshot === "all" && this._uncheckedKeys.size) {
2903
+ this._dirty = true;
2904
+ this._uncheckedKeys.forEach((key) => delete this._snapshotData[key]);
2905
+ this._uncheckedKeys.clear();
2906
+ }
2907
+ }
2908
+ match({
2909
+ testName,
2910
+ received,
2911
+ key,
2912
+ inlineSnapshot,
2913
+ isInline,
2914
+ error
2915
+ }) {
2916
+ this._counters.set(testName, (this._counters.get(testName) || 0) + 1);
2917
+ const count = Number(this._counters.get(testName));
2918
+ if (!key)
2919
+ key = testNameToKey(testName, count);
2920
+ if (!(isInline && this._snapshotData[key] !== void 0))
2921
+ this._uncheckedKeys.delete(key);
2922
+ const receivedSerialized = addExtraLineBreaks(serialize(received, void 0, this._snapshotFormat));
2923
+ const expected = isInline ? inlineSnapshot : this._snapshotData[key];
2924
+ const expectedTrimmed = prepareExpected(expected);
2925
+ const pass = expectedTrimmed === prepareExpected(receivedSerialized);
2926
+ const hasSnapshot = expected !== void 0;
2927
+ const snapshotIsPersisted = isInline || this._fileExists;
2928
+ if (pass && !isInline) {
2929
+ this._snapshotData[key] = receivedSerialized;
2930
+ }
2931
+ if (hasSnapshot && this._updateSnapshot === "all" || (!hasSnapshot || !snapshotIsPersisted) && (this._updateSnapshot === "new" || this._updateSnapshot === "all")) {
2932
+ if (this._updateSnapshot === "all") {
2933
+ if (!pass) {
2934
+ if (hasSnapshot)
2935
+ this.updated++;
2936
+ else
2937
+ this.added++;
2938
+ this._addSnapshot(key, receivedSerialized, { error, isInline });
2939
+ } else {
2940
+ this.matched++;
2941
+ }
2942
+ } else {
2943
+ this._addSnapshot(key, receivedSerialized, { error, isInline });
2944
+ this.added++;
2945
+ }
2946
+ return {
2947
+ actual: "",
2948
+ count,
2949
+ expected: "",
2950
+ key,
2951
+ pass: true
2952
+ };
2953
+ } else {
2954
+ if (!pass) {
2955
+ this.unmatched++;
2956
+ return {
2957
+ actual: removeExtraLineBreaks(receivedSerialized),
2958
+ count,
2959
+ expected: expectedTrimmed !== void 0 ? removeExtraLineBreaks(expectedTrimmed) : void 0,
2960
+ key,
2961
+ pass: false
2962
+ };
2963
+ } else {
2964
+ this.matched++;
2965
+ return {
2966
+ actual: "",
2967
+ count,
2968
+ expected: "",
2969
+ key,
2970
+ pass: true
2971
+ };
2972
+ }
2973
+ }
2974
+ }
2975
+ async pack() {
2976
+ const snapshot = {
2977
+ filepath: this.testFilePath,
2978
+ added: 0,
2979
+ fileDeleted: false,
2980
+ matched: 0,
2981
+ unchecked: 0,
2982
+ uncheckedKeys: [],
2983
+ unmatched: 0,
2984
+ updated: 0
2985
+ };
2986
+ const uncheckedCount = this.getUncheckedCount();
2987
+ const uncheckedKeys = this.getUncheckedKeys();
2988
+ if (uncheckedCount)
2989
+ this.removeUncheckedKeys();
2990
+ const status = await this.save();
2991
+ snapshot.fileDeleted = status.deleted;
2992
+ snapshot.added = this.added;
2993
+ snapshot.matched = this.matched;
2994
+ snapshot.unmatched = this.unmatched;
2995
+ snapshot.updated = this.updated;
2996
+ snapshot.unchecked = !status.deleted ? uncheckedCount : 0;
2997
+ snapshot.uncheckedKeys = Array.from(uncheckedKeys);
2998
+ return snapshot;
2999
+ }
3000
+ }
66
3001
 
67
- const filesCount = /* @__PURE__ */ new Map();
68
- const cache = /* @__PURE__ */ new Map();
69
- function runOnce(fn, key) {
70
- const filepath = getWorkerState().filepath || "__unknown_files__";
71
- if (!key) {
72
- filesCount.set(filepath, (filesCount.get(filepath) || 0) + 1);
73
- key = String(filesCount.get(filepath));
3002
+ class SnapshotClient {
3003
+ constructor() {
3004
+ this.snapshotStateMap = /* @__PURE__ */ new Map();
3005
+ }
3006
+ async setTest(test) {
3007
+ var _a;
3008
+ this.test = test;
3009
+ if (((_a = this.snapshotState) == null ? void 0 : _a.testFilePath) !== this.test.file.filepath) {
3010
+ this.saveCurrent();
3011
+ const filePath = this.test.file.filepath;
3012
+ if (!this.getSnapshotState(test)) {
3013
+ this.snapshotStateMap.set(
3014
+ filePath,
3015
+ await SnapshotState.create(
3016
+ filePath,
3017
+ getWorkerState().config.snapshotOptions
3018
+ )
3019
+ );
3020
+ }
3021
+ this.snapshotState = this.getSnapshotState(test);
3022
+ }
3023
+ }
3024
+ getSnapshotState(test) {
3025
+ return this.snapshotStateMap.get(test.file.filepath);
3026
+ }
3027
+ clearTest() {
3028
+ this.test = void 0;
3029
+ }
3030
+ skipTestSnapshots(test) {
3031
+ var _a;
3032
+ (_a = this.snapshotState) == null ? void 0 : _a.markSnapshotsAsCheckedForTest(test.name);
3033
+ }
3034
+ assert(options) {
3035
+ const {
3036
+ test = this.test,
3037
+ message,
3038
+ isInline = false,
3039
+ properties,
3040
+ inlineSnapshot,
3041
+ error,
3042
+ errorMessage
3043
+ } = options;
3044
+ let { received } = options;
3045
+ if (!test)
3046
+ throw new Error("Snapshot cannot be used outside of test");
3047
+ if (typeof properties === "object") {
3048
+ if (typeof received !== "object" || !received)
3049
+ throw new Error("Received value must be an object when the matcher has properties");
3050
+ try {
3051
+ const pass2 = equals(received, properties, [iterableEquality, subsetEquality]);
3052
+ if (!pass2)
3053
+ expect(received).equals(properties);
3054
+ else
3055
+ received = deepMergeSnapshot(received, properties);
3056
+ } catch (err) {
3057
+ err.message = errorMessage || "Snapshot mismatched";
3058
+ throw err;
3059
+ }
3060
+ }
3061
+ const testName = [
3062
+ ...getNames(test).slice(1),
3063
+ ...message ? [message] : []
3064
+ ].join(" > ");
3065
+ const snapshotState = this.getSnapshotState(test);
3066
+ const { actual, expected, key, pass } = snapshotState.match({
3067
+ testName,
3068
+ received,
3069
+ isInline,
3070
+ error,
3071
+ inlineSnapshot
3072
+ });
3073
+ if (!pass) {
3074
+ try {
3075
+ expect(actual.trim()).equals(expected ? expected.trim() : "");
3076
+ } catch (error2) {
3077
+ error2.message = errorMessage || `Snapshot \`${key || "unknown"}\` mismatched`;
3078
+ throw error2;
3079
+ }
3080
+ }
3081
+ }
3082
+ async saveCurrent() {
3083
+ if (!this.snapshotState)
3084
+ return;
3085
+ const result = await this.snapshotState.pack();
3086
+ await rpc().snapshotSaved(result);
3087
+ this.snapshotState = void 0;
3088
+ }
3089
+ clear() {
3090
+ this.snapshotStateMap.clear();
74
3091
  }
75
- const id = `${filepath}:${key}`;
76
- if (!cache.has(id))
77
- cache.set(id, fn());
78
- return cache.get(id);
79
3092
  }
80
- function isFirstRun() {
81
- let firstRun = false;
82
- runOnce(() => {
83
- firstRun = true;
84
- }, "__vitest_first_run__");
85
- return firstRun;
3093
+
3094
+ let _client;
3095
+ function getSnapshotClient() {
3096
+ if (!_client)
3097
+ _client = new SnapshotClient();
3098
+ return _client;
86
3099
  }
87
- function resetRunOnceCounter() {
88
- filesCount.clear();
3100
+ const getErrorMessage = (err) => {
3101
+ if (err instanceof Error)
3102
+ return err.message;
3103
+ return err;
3104
+ };
3105
+ const getErrorString = (expected, promise) => {
3106
+ if (typeof expected !== "function") {
3107
+ if (!promise)
3108
+ throw new Error(`expected must be a function, received ${typeof expected}`);
3109
+ return getErrorMessage(expected);
3110
+ }
3111
+ try {
3112
+ expected();
3113
+ } catch (e) {
3114
+ return getErrorMessage(e);
3115
+ }
3116
+ throw new Error("snapshot function didn't throw");
3117
+ };
3118
+ const SnapshotPlugin = (chai, utils) => {
3119
+ for (const key of ["matchSnapshot", "toMatchSnapshot"]) {
3120
+ utils.addMethod(
3121
+ chai.Assertion.prototype,
3122
+ key,
3123
+ function(properties, message) {
3124
+ const expected = utils.flag(this, "object");
3125
+ const test = utils.flag(this, "vitest-test");
3126
+ if (typeof properties === "string" && typeof message === "undefined") {
3127
+ message = properties;
3128
+ properties = void 0;
3129
+ }
3130
+ const errorMessage = utils.flag(this, "message");
3131
+ getSnapshotClient().assert({
3132
+ received: expected,
3133
+ test,
3134
+ message,
3135
+ isInline: false,
3136
+ properties,
3137
+ errorMessage
3138
+ });
3139
+ }
3140
+ );
3141
+ }
3142
+ utils.addMethod(
3143
+ chai.Assertion.prototype,
3144
+ "toMatchInlineSnapshot",
3145
+ function __VITEST_INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
3146
+ const expected = utils.flag(this, "object");
3147
+ const error = utils.flag(this, "error");
3148
+ const test = utils.flag(this, "vitest-test");
3149
+ if (typeof properties === "string") {
3150
+ message = inlineSnapshot;
3151
+ inlineSnapshot = properties;
3152
+ properties = void 0;
3153
+ }
3154
+ if (inlineSnapshot)
3155
+ inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
3156
+ const errorMessage = utils.flag(this, "message");
3157
+ getSnapshotClient().assert({
3158
+ received: expected,
3159
+ test,
3160
+ message,
3161
+ isInline: true,
3162
+ properties,
3163
+ inlineSnapshot,
3164
+ error,
3165
+ errorMessage
3166
+ });
3167
+ }
3168
+ );
3169
+ utils.addMethod(
3170
+ chai.Assertion.prototype,
3171
+ "toThrowErrorMatchingSnapshot",
3172
+ function(message) {
3173
+ const expected = utils.flag(this, "object");
3174
+ const test = utils.flag(this, "vitest-test");
3175
+ const promise = utils.flag(this, "promise");
3176
+ const errorMessage = utils.flag(this, "message");
3177
+ getSnapshotClient().assert({
3178
+ received: getErrorString(expected, promise),
3179
+ test,
3180
+ message,
3181
+ errorMessage
3182
+ });
3183
+ }
3184
+ );
3185
+ utils.addMethod(
3186
+ chai.Assertion.prototype,
3187
+ "toThrowErrorMatchingInlineSnapshot",
3188
+ function __VITEST_INLINE_SNAPSHOT__(inlineSnapshot, message) {
3189
+ const expected = utils.flag(this, "object");
3190
+ const error = utils.flag(this, "error");
3191
+ const test = utils.flag(this, "vitest-test");
3192
+ const promise = utils.flag(this, "promise");
3193
+ const errorMessage = utils.flag(this, "message");
3194
+ getSnapshotClient().assert({
3195
+ received: getErrorString(expected, promise),
3196
+ test,
3197
+ message,
3198
+ inlineSnapshot,
3199
+ isInline: true,
3200
+ error,
3201
+ errorMessage
3202
+ });
3203
+ }
3204
+ );
3205
+ utils.addMethod(
3206
+ chai.expect,
3207
+ "addSnapshotSerializer",
3208
+ addSerializer
3209
+ );
3210
+ };
3211
+
3212
+ chai$1.use(JestExtend);
3213
+ chai$1.use(JestChaiExpect);
3214
+ chai$1.use(Subset);
3215
+ chai$1.use(SnapshotPlugin);
3216
+ chai$1.use(JestAsymmetricMatchers);
3217
+
3218
+ function createExpect(test) {
3219
+ var _a;
3220
+ const expect = (value, message) => {
3221
+ const { assertionCalls } = getState(expect);
3222
+ setState({ assertionCalls: assertionCalls + 1 }, expect);
3223
+ const assert2 = chai$1.expect(value, message);
3224
+ if (test)
3225
+ return assert2.withTest(test);
3226
+ else
3227
+ return assert2;
3228
+ };
3229
+ Object.assign(expect, chai$1.expect);
3230
+ expect.getState = () => getState(expect);
3231
+ expect.setState = (state) => setState(state, expect);
3232
+ const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
3233
+ setState({
3234
+ ...globalState,
3235
+ assertionCalls: 0,
3236
+ isExpectingAssertions: false,
3237
+ isExpectingAssertionsError: null,
3238
+ expectedAssertionsNumber: null,
3239
+ expectedAssertionsNumberErrorGen: null,
3240
+ environment: getCurrentEnvironment(),
3241
+ testPath: test ? (_a = test.suite.file) == null ? void 0 : _a.filepath : globalState.testPath,
3242
+ currentTestName: test ? getFullName(test) : globalState.currentTestName
3243
+ }, expect);
3244
+ expect.extend = (matchers) => chai$1.expect.extend(expect, matchers);
3245
+ function assertions(expected) {
3246
+ const errorGen = () => new Error(`expected number of assertions to be ${expected}, but got ${expect.getState().assertionCalls}`);
3247
+ if (Error.captureStackTrace)
3248
+ Error.captureStackTrace(errorGen(), assertions);
3249
+ expect.setState({
3250
+ expectedAssertionsNumber: expected,
3251
+ expectedAssertionsNumberErrorGen: errorGen
3252
+ });
3253
+ }
3254
+ function hasAssertions() {
3255
+ const error = new Error("expected any number of assertion, but got none");
3256
+ if (Error.captureStackTrace)
3257
+ Error.captureStackTrace(error, hasAssertions);
3258
+ expect.setState({
3259
+ isExpectingAssertions: true,
3260
+ isExpectingAssertionsError: error
3261
+ });
3262
+ }
3263
+ chai$1.util.addMethod(expect, "assertions", assertions);
3264
+ chai$1.util.addMethod(expect, "hasAssertions", hasAssertions);
3265
+ return expect;
89
3266
  }
3267
+ const globalExpect = createExpect();
3268
+ Object.defineProperty(globalThis, GLOBAL_EXPECT, {
3269
+ value: globalExpect,
3270
+ writable: true,
3271
+ configurable: true
3272
+ });
90
3273
 
91
3274
  function createSimpleStackTrace(options) {
92
3275
  const { message = "error", stackTraceLimit = 1 } = options || {};
@@ -1028,7 +4211,7 @@ function withGlobal(_global) {
1028
4211
  hrtimePresent && typeof _global.process.hrtime.bigint === "function";
1029
4212
  const nextTickPresent =
1030
4213
  _global.process && typeof _global.process.nextTick === "function";
1031
- const utilPromisify = _global.process && util.promisify;
4214
+ const utilPromisify = _global.process && require$$0.promisify;
1032
4215
  const performancePresent =
1033
4216
  _global.performance && typeof _global.performance.now === "function";
1034
4217
  const hasPerformancePrototype =
@@ -2643,6 +5826,55 @@ defaultImplementation.createClock;
2643
5826
  defaultImplementation.install;
2644
5827
  var withGlobal_1 = withGlobal;
2645
5828
 
5829
+ const RealDate = Date;
5830
+ let now = null;
5831
+ class MockDate extends RealDate {
5832
+ constructor(y, m, d, h, M, s, ms) {
5833
+ super();
5834
+ let date;
5835
+ switch (arguments.length) {
5836
+ case 0:
5837
+ if (now !== null)
5838
+ date = new RealDate(now.valueOf());
5839
+ else
5840
+ date = new RealDate();
5841
+ break;
5842
+ case 1:
5843
+ date = new RealDate(y);
5844
+ break;
5845
+ default:
5846
+ d = typeof d === "undefined" ? 1 : d;
5847
+ h = h || 0;
5848
+ M = M || 0;
5849
+ s = s || 0;
5850
+ ms = ms || 0;
5851
+ date = new RealDate(y, m, d, h, M, s, ms);
5852
+ break;
5853
+ }
5854
+ return date;
5855
+ }
5856
+ }
5857
+ MockDate.UTC = RealDate.UTC;
5858
+ MockDate.now = function() {
5859
+ return new MockDate().valueOf();
5860
+ };
5861
+ MockDate.parse = function(dateString) {
5862
+ return RealDate.parse(dateString);
5863
+ };
5864
+ MockDate.toString = function() {
5865
+ return RealDate.toString();
5866
+ };
5867
+ function mockDate(date) {
5868
+ const dateObj = new RealDate(date.valueOf());
5869
+ if (isNaN(dateObj.getTime()))
5870
+ throw new TypeError(`mockdate: The time set is an invalid date: ${date}`);
5871
+ globalThis.Date = MockDate;
5872
+ now = dateObj.valueOf();
5873
+ }
5874
+ function resetDate() {
5875
+ globalThis.Date = RealDate;
5876
+ }
5877
+
2646
5878
  class FakeTimers {
2647
5879
  constructor({
2648
5880
  global,
@@ -2962,123 +6194,11 @@ class VitestUtils {
2962
6194
  resetConfig() {
2963
6195
  if (this._config) {
2964
6196
  const state = getWorkerState();
2965
- state.config = { ...this._config };
6197
+ Object.assign(state.config, this._config);
2966
6198
  }
2967
6199
  }
2968
6200
  }
2969
6201
  const vitest = new VitestUtils();
2970
6202
  const vi = vitest;
2971
6203
 
2972
- function getRunningMode() {
2973
- return process.env.VITEST_MODE === "WATCH" ? "watch" : "run";
2974
- }
2975
- function isWatchMode() {
2976
- return getRunningMode() === "watch";
2977
- }
2978
-
2979
- var dist = {};
2980
-
2981
- (function (exports) {
2982
- Object.defineProperty(exports, "__esModule", { value: true });
2983
- exports.expectTypeOf = void 0;
2984
- const fn = () => true;
2985
- /**
2986
- * Similar to Jest's `expect`, but with type-awareness.
2987
- * Gives you access to a number of type-matchers that let you make assertions about the
2988
- * form of a reference or generic type parameter.
2989
- *
2990
- * @example
2991
- * import {foo, bar} from '../foo'
2992
- * import {expectTypeOf} from 'expect-type'
2993
- *
2994
- * test('foo types', () => {
2995
- * // make sure `foo` has type {a: number}
2996
- * expectTypeOf(foo).toMatchTypeOf({a: 1})
2997
- * expectTypeOf(foo).toHaveProperty('a').toBeNumber()
2998
- *
2999
- * // make sure `bar` is a function taking a string:
3000
- * expectTypeOf(bar).parameter(0).toBeString()
3001
- * expectTypeOf(bar).returns.not.toBeAny()
3002
- * })
3003
- *
3004
- * @description
3005
- * See the [full docs](https://npmjs.com/package/expect-type#documentation) for lots more examples.
3006
- */
3007
- const expectTypeOf = (_actual) => {
3008
- const nonFunctionProperties = [
3009
- 'parameters',
3010
- 'returns',
3011
- 'resolves',
3012
- 'not',
3013
- 'items',
3014
- 'constructorParameters',
3015
- 'instance',
3016
- 'guards',
3017
- 'asserts',
3018
- ];
3019
- const obj = {
3020
- /* eslint-disable mmkal/@typescript-eslint/no-unsafe-assignment */
3021
- toBeAny: fn,
3022
- toBeUnknown: fn,
3023
- toBeNever: fn,
3024
- toBeFunction: fn,
3025
- toBeObject: fn,
3026
- toBeArray: fn,
3027
- toBeString: fn,
3028
- toBeNumber: fn,
3029
- toBeBoolean: fn,
3030
- toBeVoid: fn,
3031
- toBeSymbol: fn,
3032
- toBeNull: fn,
3033
- toBeUndefined: fn,
3034
- toBeNullable: fn,
3035
- toMatchTypeOf: fn,
3036
- toEqualTypeOf: fn,
3037
- toBeCallableWith: fn,
3038
- toBeConstructibleWith: fn,
3039
- /* eslint-enable mmkal/@typescript-eslint/no-unsafe-assignment */
3040
- extract: exports.expectTypeOf,
3041
- exclude: exports.expectTypeOf,
3042
- toHaveProperty: exports.expectTypeOf,
3043
- parameter: exports.expectTypeOf,
3044
- };
3045
- const getterProperties = nonFunctionProperties;
3046
- getterProperties.forEach((prop) => Object.defineProperty(obj, prop, { get: () => (0, exports.expectTypeOf)({}) }));
3047
- return obj;
3048
- };
3049
- exports.expectTypeOf = expectTypeOf;
3050
- } (dist));
3051
-
3052
- const noop = () => {
3053
- };
3054
- const assertType = noop;
3055
-
3056
- var index = /*#__PURE__*/Object.freeze({
3057
- __proto__: null,
3058
- suite: suite,
3059
- test: test,
3060
- describe: describe,
3061
- it: it,
3062
- bench: bench,
3063
- runOnce: runOnce,
3064
- isFirstRun: isFirstRun,
3065
- beforeAll: beforeAll,
3066
- afterAll: afterAll,
3067
- beforeEach: beforeEach,
3068
- afterEach: afterEach,
3069
- onTestFailed: onTestFailed,
3070
- withCallback: withCallback,
3071
- assert: assert,
3072
- should: should,
3073
- createExpect: createExpect,
3074
- chai: chai,
3075
- expect: globalExpect,
3076
- vitest: vitest,
3077
- vi: vi,
3078
- getRunningMode: getRunningMode,
3079
- isWatchMode: isWatchMode,
3080
- expectTypeOf: dist.expectTypeOf,
3081
- assertType: assertType
3082
- });
3083
-
3084
- export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d, dist as e, assertType as f, runOnce as g, isFirstRun as h, index as i, vitest as j, getRunningMode as k, isWatchMode as l, onTestFailed as o, resetRunOnceCounter as r, setCurrentTest as s, vi as v, withCallback as w };
6204
+ export { RealDate as R, vi as a, bench as b, createExpect as c, getSnapshotClient as d, getBenchOptions as e, getBenchFn as f, globalExpect as g, vitest as v };