vitest 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,27 +1,27 @@
1
- import require$$0, { format as format$1 } from 'util';
2
- import { g as getWorkerState, i as isObject, t as toArray, n as noop, a as index$1, b as getCallLastIndex, s as slash, c as getNames, d as c$1, e as assertTypes, r as resetModules } from './chunk-utils-global.35d3b35d.js';
3
- import { s as setTimeout, c as clearTimeout, g as getOriginalPos, p as posToNumber, n as numberToPos, l as lineSplitRE, a as parseStacktrace, u as unifiedDiff } from './chunk-utils-timers.73950dcb.js';
1
+ import require$$0, { format } from 'util';
2
+ import { g as getWorkerState, i as isObject, t as toArray, n as noop, a as index$1, b as getCallLastIndex, s as slash, c as getNames, d as assertTypes, e as c, r as resetModules } from './chunk-utils-global.10dcdfa6.js';
3
+ import { s as setTimeout, c as clearTimeout, p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n as numberToPos, l as lineSplitRE, b as parseStacktrace, u as unifiedDiff, d as stringify, m as matcherUtils } from './chunk-utils-timers.4800834c.js';
4
4
  import chai$1, { expect as expect$1, util, assert, should } from 'chai';
5
5
  import { c as commonjsRequire, a as commonjsGlobal } from './vendor-_commonjsHelpers.34b404ce.js';
6
- import { r as rpc } from './chunk-runtime-rpc.3f693817.js';
6
+ import { r as rpc } from './chunk-runtime-rpc.4b80b6bd.js';
7
7
  import fs, { promises } from 'fs';
8
8
  import { isMockFunction, spyOn, fn, spies } from './spy.js';
9
9
 
10
- var __defProp$5 = Object.defineProperty;
10
+ var __defProp$4 = Object.defineProperty;
11
11
  var __defProps$2 = Object.defineProperties;
12
12
  var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
13
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
14
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
15
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
16
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
- var __spreadValues$5 = (a, b) => {
13
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
14
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
15
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
16
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
+ var __spreadValues$4 = (a, b) => {
18
18
  for (var prop in b || (b = {}))
19
- if (__hasOwnProp$5.call(b, prop))
20
- __defNormalProp$5(a, prop, b[prop]);
21
- if (__getOwnPropSymbols$5)
22
- for (var prop of __getOwnPropSymbols$5(b)) {
23
- if (__propIsEnum$5.call(b, prop))
24
- __defNormalProp$5(a, prop, b[prop]);
19
+ if (__hasOwnProp$4.call(b, prop))
20
+ __defNormalProp$4(a, prop, b[prop]);
21
+ if (__getOwnPropSymbols$4)
22
+ for (var prop of __getOwnPropSymbols$4(b)) {
23
+ if (__propIsEnum$4.call(b, prop))
24
+ __defNormalProp$4(a, prop, b[prop]);
25
25
  }
26
26
  return a;
27
27
  };
@@ -34,7 +34,7 @@ function createChainable(keys, fn) {
34
34
  for (const key of keys) {
35
35
  Object.defineProperty(chain2, key, {
36
36
  get() {
37
- return create(__spreadProps$2(__spreadValues$5({}, obj), { [key]: true }));
37
+ return create(__spreadProps$2(__spreadValues$4({}, obj), { [key]: true }));
38
38
  }
39
39
  });
40
40
  }
@@ -110,7 +110,7 @@ function getHooks(key) {
110
110
  }
111
111
 
112
112
  const suite = createSuite();
113
- const test$7 = createTest(function(name, fn, timeout) {
113
+ const test = createTest(function(name, fn, timeout) {
114
114
  getCurrentSuite().test.fn.call(this, name, fn, timeout);
115
115
  });
116
116
  function formatTitle(template, items, idx) {
@@ -118,7 +118,7 @@ function formatTitle(template, items, idx) {
118
118
  template = template.replace(/%%/g, "__vitest_escaped_%__").replace(/%#/g, `${idx}`).replace(/__vitest_escaped_%__/g, "%%");
119
119
  }
120
120
  const count = template.split("%").length - 1;
121
- let formatted = format$1(template, ...items.slice(0, count));
121
+ let formatted = format(template, ...items.slice(0, count));
122
122
  if (isObject(items[0])) {
123
123
  formatted = formatted.replace(/\$([$\w_]+)/g, (_, key) => {
124
124
  return items[0][key];
@@ -127,7 +127,7 @@ function formatTitle(template, items, idx) {
127
127
  return formatted;
128
128
  }
129
129
  const describe = suite;
130
- const it = test$7;
130
+ const it = test;
131
131
  const defaultSuite = suite("");
132
132
  function clearContext() {
133
133
  context.tasks.length = 0;
@@ -457,14 +457,14 @@ function isA(typeName, value) {
457
457
  function isDomNode(obj) {
458
458
  return obj !== null && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string" && typeof obj.isEqualNode === "function";
459
459
  }
460
- const IS_KEYED_SENTINEL$1 = "@@__IMMUTABLE_KEYED__@@";
461
- const IS_SET_SENTINEL$1 = "@@__IMMUTABLE_SET__@@";
462
- const IS_ORDERED_SENTINEL$1 = "@@__IMMUTABLE_ORDERED__@@";
460
+ const IS_KEYED_SENTINEL = "@@__IMMUTABLE_KEYED__@@";
461
+ const IS_SET_SENTINEL = "@@__IMMUTABLE_SET__@@";
462
+ const IS_ORDERED_SENTINEL = "@@__IMMUTABLE_ORDERED__@@";
463
463
  function isImmutableUnorderedKeyed(maybeKeyed) {
464
- return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL$1] && !maybeKeyed[IS_ORDERED_SENTINEL$1]);
464
+ return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL] && !maybeKeyed[IS_ORDERED_SENTINEL]);
465
465
  }
466
466
  function isImmutableUnorderedSet(maybeSet) {
467
- return !!(maybeSet && maybeSet[IS_SET_SENTINEL$1] && !maybeSet[IS_ORDERED_SENTINEL$1]);
467
+ return !!(maybeSet && maybeSet[IS_SET_SENTINEL] && !maybeSet[IS_ORDERED_SENTINEL]);
468
468
  }
469
469
  const IteratorSymbol = Symbol.iterator;
470
470
  const hasIterator = (object) => !!(object != null && object[IteratorSymbol]);
@@ -656,2437 +656,135 @@ try {
656
656
 
657
657
  var naturalCompare$1 = naturalCompare$2.exports;
658
658
 
659
- var build = {};
660
-
661
- var ansiStyles = {exports: {}};
662
-
663
- (function (module) {
664
-
665
- const ANSI_BACKGROUND_OFFSET = 10;
666
-
667
- const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
668
-
669
- const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
670
-
671
- function assembleStyles() {
672
- const codes = new Map();
673
- const styles = {
674
- modifier: {
675
- reset: [0, 0],
676
- // 21 isn't widely supported and 22 does the same thing
677
- bold: [1, 22],
678
- dim: [2, 22],
679
- italic: [3, 23],
680
- underline: [4, 24],
681
- overline: [53, 55],
682
- inverse: [7, 27],
683
- hidden: [8, 28],
684
- strikethrough: [9, 29]
685
- },
686
- color: {
687
- black: [30, 39],
688
- red: [31, 39],
689
- green: [32, 39],
690
- yellow: [33, 39],
691
- blue: [34, 39],
692
- magenta: [35, 39],
693
- cyan: [36, 39],
694
- white: [37, 39],
695
-
696
- // Bright color
697
- blackBright: [90, 39],
698
- redBright: [91, 39],
699
- greenBright: [92, 39],
700
- yellowBright: [93, 39],
701
- blueBright: [94, 39],
702
- magentaBright: [95, 39],
703
- cyanBright: [96, 39],
704
- whiteBright: [97, 39]
705
- },
706
- bgColor: {
707
- bgBlack: [40, 49],
708
- bgRed: [41, 49],
709
- bgGreen: [42, 49],
710
- bgYellow: [43, 49],
711
- bgBlue: [44, 49],
712
- bgMagenta: [45, 49],
713
- bgCyan: [46, 49],
714
- bgWhite: [47, 49],
715
-
716
- // Bright color
717
- bgBlackBright: [100, 49],
718
- bgRedBright: [101, 49],
719
- bgGreenBright: [102, 49],
720
- bgYellowBright: [103, 49],
721
- bgBlueBright: [104, 49],
722
- bgMagentaBright: [105, 49],
723
- bgCyanBright: [106, 49],
724
- bgWhiteBright: [107, 49]
725
- }
726
- };
727
-
728
- // Alias bright black as gray (and grey)
729
- styles.color.gray = styles.color.blackBright;
730
- styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
731
- styles.color.grey = styles.color.blackBright;
732
- styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
733
-
734
- for (const [groupName, group] of Object.entries(styles)) {
735
- for (const [styleName, style] of Object.entries(group)) {
736
- styles[styleName] = {
737
- open: `\u001B[${style[0]}m`,
738
- close: `\u001B[${style[1]}m`
739
- };
740
-
741
- group[styleName] = styles[styleName];
742
-
743
- codes.set(style[0], style[1]);
744
- }
745
-
746
- Object.defineProperty(styles, groupName, {
747
- value: group,
748
- enumerable: false
749
- });
750
- }
751
-
752
- Object.defineProperty(styles, 'codes', {
753
- value: codes,
754
- enumerable: false
755
- });
756
-
757
- styles.color.close = '\u001B[39m';
758
- styles.bgColor.close = '\u001B[49m';
759
-
760
- styles.color.ansi256 = wrapAnsi256();
761
- styles.color.ansi16m = wrapAnsi16m();
762
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
763
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
764
-
765
- // From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
766
- Object.defineProperties(styles, {
767
- rgbToAnsi256: {
768
- value: (red, green, blue) => {
769
- // We use the extended greyscale palette here, with the exception of
770
- // black and white. normal palette only has 4 greyscale shades.
771
- if (red === green && green === blue) {
772
- if (red < 8) {
773
- return 16;
774
- }
775
-
776
- if (red > 248) {
777
- return 231;
778
- }
779
-
780
- return Math.round(((red - 8) / 247) * 24) + 232;
781
- }
782
-
783
- return 16 +
784
- (36 * Math.round(red / 255 * 5)) +
785
- (6 * Math.round(green / 255 * 5)) +
786
- Math.round(blue / 255 * 5);
787
- },
788
- enumerable: false
789
- },
790
- hexToRgb: {
791
- value: hex => {
792
- const matches = /(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(hex.toString(16));
793
- if (!matches) {
794
- return [0, 0, 0];
795
- }
796
-
797
- let {colorString} = matches.groups;
798
-
799
- if (colorString.length === 3) {
800
- colorString = colorString.split('').map(character => character + character).join('');
801
- }
802
-
803
- const integer = Number.parseInt(colorString, 16);
804
-
805
- return [
806
- (integer >> 16) & 0xFF,
807
- (integer >> 8) & 0xFF,
808
- integer & 0xFF
809
- ];
810
- },
811
- enumerable: false
812
- },
813
- hexToAnsi256: {
814
- value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
815
- enumerable: false
816
- }
817
- });
818
-
819
- return styles;
820
- }
821
-
822
- // Make the export immutable
823
- Object.defineProperty(module, 'exports', {
824
- enumerable: true,
825
- get: assembleStyles
826
- });
827
- }(ansiStyles));
828
-
829
- var collections = {};
830
-
831
- Object.defineProperty(collections, '__esModule', {
832
- value: true
833
- });
834
- collections.printIteratorEntries = printIteratorEntries;
835
- collections.printIteratorValues = printIteratorValues;
836
- collections.printListItems = printListItems;
837
- collections.printObjectProperties = printObjectProperties;
838
-
839
- /**
840
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
841
- *
842
- * This source code is licensed under the MIT license found in the
843
- * LICENSE file in the root directory of this source tree.
844
- *
845
- */
846
- const getKeysOfEnumerableProperties = (object, compareKeys) => {
847
- const keys = Object.keys(object).sort(compareKeys);
848
-
849
- if (Object.getOwnPropertySymbols) {
850
- Object.getOwnPropertySymbols(object).forEach(symbol => {
851
- if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) {
852
- keys.push(symbol);
853
- }
854
- });
855
- }
856
-
857
- return keys;
659
+ const {
660
+ DOMCollection,
661
+ DOMElement,
662
+ Immutable,
663
+ ReactElement,
664
+ ReactTestComponent,
665
+ AsymmetricMatcher: AsymmetricMatcher$1
666
+ } = plugins_1;
667
+ let PLUGINS = [
668
+ ReactTestComponent,
669
+ ReactElement,
670
+ DOMElement,
671
+ DOMCollection,
672
+ Immutable,
673
+ AsymmetricMatcher$1
674
+ ];
675
+ const addSerializer = (plugin) => {
676
+ PLUGINS = [plugin].concat(PLUGINS);
858
677
  };
859
- /**
860
- * Return entries (for example, of a map)
861
- * with spacing, indentation, and comma
862
- * without surrounding punctuation (for example, braces)
863
- */
678
+ const getSerializers = () => PLUGINS;
864
679
 
865
- function printIteratorEntries(
866
- iterator,
867
- config,
868
- indentation,
869
- depth,
870
- refs,
871
- printer, // Too bad, so sad that separator for ECMAScript Map has been ' => '
872
- // What a distracting diff if you change a data structure to/from
873
- // ECMAScript Object or Immutable.Map/OrderedMap which use the default.
874
- separator = ': '
875
- ) {
876
- let result = '';
877
- let current = iterator.next();
878
-
879
- if (!current.done) {
880
- result += config.spacingOuter;
881
- const indentationNext = indentation + config.indent;
882
-
883
- while (!current.done) {
884
- const name = printer(
885
- current.value[0],
886
- config,
887
- indentationNext,
888
- depth,
889
- refs
890
- );
891
- const value = printer(
892
- current.value[1],
893
- config,
894
- indentationNext,
895
- depth,
896
- refs
897
- );
898
- result += indentationNext + name + separator + value;
899
- current = iterator.next();
900
-
901
- if (!current.done) {
902
- result += ',' + config.spacingInner;
903
- } else if (!config.min) {
904
- result += ',';
905
- }
680
+ var __defProp$3 = Object.defineProperty;
681
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
682
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
683
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
684
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
685
+ var __spreadValues$3 = (a, b) => {
686
+ for (var prop in b || (b = {}))
687
+ if (__hasOwnProp$3.call(b, prop))
688
+ __defNormalProp$3(a, prop, b[prop]);
689
+ if (__getOwnPropSymbols$3)
690
+ for (var prop of __getOwnPropSymbols$3(b)) {
691
+ if (__propIsEnum$3.call(b, prop))
692
+ __defNormalProp$3(a, prop, b[prop]);
906
693
  }
907
-
908
- result += config.spacingOuter + indentation;
909
- }
910
-
911
- return result;
912
- }
913
- /**
914
- * Return values (for example, of a set)
915
- * with spacing, indentation, and comma
916
- * without surrounding punctuation (braces or brackets)
917
- */
918
-
919
- function printIteratorValues(
920
- iterator,
921
- config,
922
- indentation,
923
- depth,
924
- refs,
925
- printer
926
- ) {
927
- let result = '';
928
- let current = iterator.next();
929
-
930
- if (!current.done) {
931
- result += config.spacingOuter;
932
- const indentationNext = indentation + config.indent;
933
-
934
- while (!current.done) {
935
- result +=
936
- indentationNext +
937
- printer(current.value, config, indentationNext, depth, refs);
938
- current = iterator.next();
939
-
940
- if (!current.done) {
941
- result += ',' + config.spacingInner;
942
- } else if (!config.min) {
943
- result += ',';
944
- }
694
+ return a;
695
+ };
696
+ const SNAPSHOT_VERSION = "1";
697
+ const writeSnapshotVersion = () => `// Vitest Snapshot v${SNAPSHOT_VERSION}`;
698
+ const testNameToKey = (testName, count) => `${testName} ${count}`;
699
+ const keyToTestName = (key) => {
700
+ if (!/ \d+$/.test(key))
701
+ throw new Error("Snapshot keys must end with a number.");
702
+ return key.replace(/ \d+$/, "");
703
+ };
704
+ const getSnapshotData = (snapshotPath, update) => {
705
+ const data = /* @__PURE__ */ Object.create(null);
706
+ let snapshotContents = "";
707
+ let dirty = false;
708
+ if (fs.existsSync(snapshotPath)) {
709
+ try {
710
+ snapshotContents = fs.readFileSync(snapshotPath, "utf8");
711
+ const populate = new Function("exports", snapshotContents);
712
+ populate(data);
713
+ } catch {
945
714
  }
946
-
947
- result += config.spacingOuter + indentation;
948
715
  }
949
-
950
- return result;
716
+ const isInvalid = snapshotContents;
717
+ if ((update === "all" || update === "new") && isInvalid)
718
+ dirty = true;
719
+ return { data, dirty };
720
+ };
721
+ const addExtraLineBreaks = (string) => string.includes("\n") ? `
722
+ ${string}
723
+ ` : string;
724
+ const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith("\n") && string.endsWith("\n") ? string.slice(1, -1) : string;
725
+ const escapeRegex = true;
726
+ const printFunctionName = false;
727
+ function serialize(val, indent = 2, formatOverrides = {}) {
728
+ return normalizeNewlines(format_1(val, __spreadValues$3({
729
+ escapeRegex,
730
+ indent,
731
+ plugins: getSerializers(),
732
+ printFunctionName
733
+ }, formatOverrides)));
951
734
  }
952
- /**
953
- * Return items (for example, of an array)
954
- * with spacing, indentation, and comma
955
- * without surrounding punctuation (for example, brackets)
956
- **/
957
-
958
- function printListItems(list, config, indentation, depth, refs, printer) {
959
- let result = '';
960
-
961
- if (list.length) {
962
- result += config.spacingOuter;
963
- const indentationNext = indentation + config.indent;
964
-
965
- for (let i = 0; i < list.length; i++) {
966
- result += indentationNext;
967
-
968
- if (i in list) {
969
- result += printer(list[i], config, indentationNext, depth, refs);
970
- }
971
-
972
- if (i < list.length - 1) {
973
- result += ',' + config.spacingInner;
974
- } else if (!config.min) {
975
- result += ',';
976
- }
977
- }
978
-
979
- result += config.spacingOuter + indentation;
980
- }
981
-
982
- return result;
735
+ function escapeBacktickString(str) {
736
+ return str.replace(/`|\\|\${/g, "\\$&");
983
737
  }
984
- /**
985
- * Return properties of an object
986
- * with spacing, indentation, and comma
987
- * without surrounding punctuation (for example, braces)
988
- */
989
-
990
- function printObjectProperties(val, config, indentation, depth, refs, printer) {
991
- let result = '';
992
- const keys = getKeysOfEnumerableProperties(val, config.compareKeys);
993
-
994
- if (keys.length) {
995
- result += config.spacingOuter;
996
- const indentationNext = indentation + config.indent;
997
-
998
- for (let i = 0; i < keys.length; i++) {
999
- const key = keys[i];
1000
- const name = printer(key, config, indentationNext, depth, refs);
1001
- const value = printer(val[key], config, indentationNext, depth, refs);
1002
- result += indentationNext + name + ': ' + value;
1003
-
1004
- if (i < keys.length - 1) {
1005
- result += ',' + config.spacingInner;
1006
- } else if (!config.min) {
1007
- result += ',';
1008
- }
1009
- }
1010
-
1011
- result += config.spacingOuter + indentation;
1012
- }
1013
-
1014
- return result;
738
+ function printBacktickString(str) {
739
+ return `\`${escapeBacktickString(str)}\``;
1015
740
  }
1016
-
1017
- var AsymmetricMatcher$3 = {};
1018
-
1019
- Object.defineProperty(AsymmetricMatcher$3, '__esModule', {
1020
- value: true
1021
- });
1022
- AsymmetricMatcher$3.test = AsymmetricMatcher$3.serialize = AsymmetricMatcher$3.default = void 0;
1023
-
1024
- var _collections$3 = collections;
1025
-
1026
- var global$3 = (function () {
1027
- if (typeof globalThis !== 'undefined') {
1028
- return globalThis;
1029
- } else if (typeof global$3 !== 'undefined') {
1030
- return global$3;
1031
- } else if (typeof self !== 'undefined') {
1032
- return self;
1033
- } else if (typeof window !== 'undefined') {
1034
- return window;
1035
- } else {
1036
- return Function('return this')();
1037
- }
1038
- })();
1039
-
1040
- var Symbol$2 = global$3['jest-symbol-do-not-touch'] || global$3.Symbol;
1041
- const asymmetricMatcher =
1042
- typeof Symbol$2 === 'function' && Symbol$2.for
1043
- ? Symbol$2.for('jest.asymmetricMatcher')
1044
- : 0x1357a5;
1045
- const SPACE$2 = ' ';
1046
-
1047
- const serialize$7 = (val, config, indentation, depth, refs, printer) => {
1048
- const stringedValue = val.toString();
1049
-
1050
- if (
1051
- stringedValue === 'ArrayContaining' ||
1052
- stringedValue === 'ArrayNotContaining'
1053
- ) {
1054
- if (++depth > config.maxDepth) {
1055
- return '[' + stringedValue + ']';
1056
- }
1057
-
1058
- return (
1059
- stringedValue +
1060
- SPACE$2 +
1061
- '[' +
1062
- (0, _collections$3.printListItems)(
1063
- val.sample,
1064
- config,
1065
- indentation,
1066
- depth,
1067
- refs,
1068
- printer
1069
- ) +
1070
- ']'
1071
- );
1072
- }
1073
-
1074
- if (
1075
- stringedValue === 'ObjectContaining' ||
1076
- stringedValue === 'ObjectNotContaining'
1077
- ) {
1078
- if (++depth > config.maxDepth) {
1079
- return '[' + stringedValue + ']';
1080
- }
1081
-
1082
- return (
1083
- stringedValue +
1084
- SPACE$2 +
1085
- '{' +
1086
- (0, _collections$3.printObjectProperties)(
1087
- val.sample,
1088
- config,
1089
- indentation,
1090
- depth,
1091
- refs,
1092
- printer
1093
- ) +
1094
- '}'
1095
- );
741
+ function ensureDirectoryExists(filePath) {
742
+ try {
743
+ fs.mkdirSync(index$1.join(index$1.dirname(filePath)), { recursive: true });
744
+ } catch {
1096
745
  }
746
+ }
747
+ function normalizeNewlines(string) {
748
+ return string.replace(/\r\n|\r/g, "\n");
749
+ }
750
+ async function saveSnapshotFile(snapshotData, snapshotPath) {
751
+ const snapshots = Object.keys(snapshotData).sort(naturalCompare$1).map((key) => `exports[${printBacktickString(key)}] = ${printBacktickString(normalizeNewlines(snapshotData[key]))};`);
752
+ ensureDirectoryExists(snapshotPath);
753
+ await promises.writeFile(snapshotPath, `${writeSnapshotVersion()}
1097
754
 
1098
- if (
1099
- stringedValue === 'StringMatching' ||
1100
- stringedValue === 'StringNotMatching'
1101
- ) {
1102
- return (
1103
- stringedValue +
1104
- SPACE$2 +
1105
- printer(val.sample, config, indentation, depth, refs)
1106
- );
755
+ ${snapshots.join("\n\n")}
756
+ `, "utf-8");
757
+ }
758
+ function prepareExpected(expected) {
759
+ function findStartIndent() {
760
+ var _a;
761
+ const match = /^( +)}\s+$/m.exec(expected || "");
762
+ return ((_a = match == null ? void 0 : match[1]) == null ? void 0 : _a.length) || 0;
1107
763
  }
1108
-
1109
- if (
1110
- stringedValue === 'StringContaining' ||
1111
- stringedValue === 'StringNotContaining'
1112
- ) {
1113
- return (
1114
- stringedValue +
1115
- SPACE$2 +
1116
- printer(val.sample, config, indentation, depth, refs)
1117
- );
764
+ const startIdent = findStartIndent();
765
+ let expectedTrimmed = expected == null ? void 0 : expected.trim();
766
+ if (startIdent) {
767
+ expectedTrimmed = expectedTrimmed == null ? void 0 : expectedTrimmed.replace(new RegExp(`^${" ".repeat(startIdent)}`, "gm"), "").replace(/ +}$/, "}");
1118
768
  }
1119
-
1120
- return val.toAsymmetricMatcher();
1121
- };
1122
-
1123
- AsymmetricMatcher$3.serialize = serialize$7;
1124
-
1125
- const test$6 = val => val && val.$$typeof === asymmetricMatcher;
1126
-
1127
- AsymmetricMatcher$3.test = test$6;
1128
- const plugin$6 = {
1129
- serialize: serialize$7,
1130
- test: test$6
1131
- };
1132
- var _default$7 = plugin$6;
1133
- AsymmetricMatcher$3.default = _default$7;
1134
-
1135
- var ConvertAnsi = {};
1136
-
1137
- var ansiRegex = ({onlyFirst = false} = {}) => {
1138
- const pattern = [
1139
- '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
1140
- '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
1141
- ].join('|');
1142
-
1143
- return new RegExp(pattern, onlyFirst ? undefined : 'g');
1144
- };
1145
-
1146
- Object.defineProperty(ConvertAnsi, '__esModule', {
1147
- value: true
1148
- });
1149
- ConvertAnsi.test = ConvertAnsi.serialize = ConvertAnsi.default = void 0;
1150
-
1151
- var _ansiRegex = _interopRequireDefault$2(ansiRegex);
1152
-
1153
- var _ansiStyles$1 = _interopRequireDefault$2(ansiStyles.exports);
1154
-
1155
- function _interopRequireDefault$2(obj) {
1156
- return obj && obj.__esModule ? obj : {default: obj};
769
+ return expectedTrimmed;
1157
770
  }
1158
-
1159
- /**
1160
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1161
- *
1162
- * This source code is licensed under the MIT license found in the
1163
- * LICENSE file in the root directory of this source tree.
1164
- */
1165
- const toHumanReadableAnsi = text =>
1166
- text.replace((0, _ansiRegex.default)(), match => {
1167
- switch (match) {
1168
- case _ansiStyles$1.default.red.close:
1169
- case _ansiStyles$1.default.green.close:
1170
- case _ansiStyles$1.default.cyan.close:
1171
- case _ansiStyles$1.default.gray.close:
1172
- case _ansiStyles$1.default.white.close:
1173
- case _ansiStyles$1.default.yellow.close:
1174
- case _ansiStyles$1.default.bgRed.close:
1175
- case _ansiStyles$1.default.bgGreen.close:
1176
- case _ansiStyles$1.default.bgYellow.close:
1177
- case _ansiStyles$1.default.inverse.close:
1178
- case _ansiStyles$1.default.dim.close:
1179
- case _ansiStyles$1.default.bold.close:
1180
- case _ansiStyles$1.default.reset.open:
1181
- case _ansiStyles$1.default.reset.close:
1182
- return '</>';
1183
-
1184
- case _ansiStyles$1.default.red.open:
1185
- return '<red>';
1186
-
1187
- case _ansiStyles$1.default.green.open:
1188
- return '<green>';
1189
-
1190
- case _ansiStyles$1.default.cyan.open:
1191
- return '<cyan>';
1192
-
1193
- case _ansiStyles$1.default.gray.open:
1194
- return '<gray>';
1195
-
1196
- case _ansiStyles$1.default.white.open:
1197
- return '<white>';
1198
-
1199
- case _ansiStyles$1.default.yellow.open:
1200
- return '<yellow>';
1201
-
1202
- case _ansiStyles$1.default.bgRed.open:
1203
- return '<bgRed>';
1204
-
1205
- case _ansiStyles$1.default.bgGreen.open:
1206
- return '<bgGreen>';
1207
-
1208
- case _ansiStyles$1.default.bgYellow.open:
1209
- return '<bgYellow>';
1210
-
1211
- case _ansiStyles$1.default.inverse.open:
1212
- return '<inverse>';
1213
-
1214
- case _ansiStyles$1.default.dim.open:
1215
- return '<dim>';
1216
-
1217
- case _ansiStyles$1.default.bold.open:
1218
- return '<bold>';
1219
-
1220
- default:
1221
- return '';
1222
- }
1223
- });
1224
-
1225
- const test$5 = val =>
1226
- typeof val === 'string' && !!val.match((0, _ansiRegex.default)());
1227
-
1228
- ConvertAnsi.test = test$5;
1229
-
1230
- const serialize$6 = (val, config, indentation, depth, refs, printer) =>
1231
- printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
1232
-
1233
- ConvertAnsi.serialize = serialize$6;
1234
- const plugin$5 = {
1235
- serialize: serialize$6,
1236
- test: test$5
1237
- };
1238
- var _default$6 = plugin$5;
1239
- ConvertAnsi.default = _default$6;
1240
-
1241
- var DOMCollection$2 = {};
1242
-
1243
- Object.defineProperty(DOMCollection$2, '__esModule', {
1244
- value: true
1245
- });
1246
- DOMCollection$2.test = DOMCollection$2.serialize = DOMCollection$2.default = void 0;
1247
-
1248
- var _collections$2 = collections;
1249
-
1250
- /**
1251
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1252
- *
1253
- * This source code is licensed under the MIT license found in the
1254
- * LICENSE file in the root directory of this source tree.
1255
- */
1256
-
1257
- /* eslint-disable local/ban-types-eventually */
1258
- const SPACE$1 = ' ';
1259
- const OBJECT_NAMES = ['DOMStringMap', 'NamedNodeMap'];
1260
- const ARRAY_REGEXP = /^(HTML\w*Collection|NodeList)$/;
1261
-
1262
- const testName = name =>
1263
- OBJECT_NAMES.indexOf(name) !== -1 || ARRAY_REGEXP.test(name);
1264
-
1265
- const test$4 = val =>
1266
- val &&
1267
- val.constructor &&
1268
- !!val.constructor.name &&
1269
- testName(val.constructor.name);
1270
-
1271
- DOMCollection$2.test = test$4;
1272
-
1273
- const isNamedNodeMap = collection =>
1274
- collection.constructor.name === 'NamedNodeMap';
1275
-
1276
- const serialize$5 = (collection, config, indentation, depth, refs, printer) => {
1277
- const name = collection.constructor.name;
1278
-
1279
- if (++depth > config.maxDepth) {
1280
- return '[' + name + ']';
1281
- }
1282
-
1283
- return (
1284
- (config.min ? '' : name + SPACE$1) +
1285
- (OBJECT_NAMES.indexOf(name) !== -1
1286
- ? '{' +
1287
- (0, _collections$2.printObjectProperties)(
1288
- isNamedNodeMap(collection)
1289
- ? Array.from(collection).reduce((props, attribute) => {
1290
- props[attribute.name] = attribute.value;
1291
- return props;
1292
- }, {})
1293
- : {...collection},
1294
- config,
1295
- indentation,
1296
- depth,
1297
- refs,
1298
- printer
1299
- ) +
1300
- '}'
1301
- : '[' +
1302
- (0, _collections$2.printListItems)(
1303
- Array.from(collection),
1304
- config,
1305
- indentation,
1306
- depth,
1307
- refs,
1308
- printer
1309
- ) +
1310
- ']')
1311
- );
1312
- };
1313
-
1314
- DOMCollection$2.serialize = serialize$5;
1315
- const plugin$4 = {
1316
- serialize: serialize$5,
1317
- test: test$4
1318
- };
1319
- var _default$5 = plugin$4;
1320
- DOMCollection$2.default = _default$5;
1321
-
1322
- var DOMElement$2 = {};
1323
-
1324
- var markup = {};
1325
-
1326
- var escapeHTML$1 = {};
1327
-
1328
- Object.defineProperty(escapeHTML$1, '__esModule', {
1329
- value: true
1330
- });
1331
- escapeHTML$1.default = escapeHTML;
1332
-
1333
- /**
1334
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1335
- *
1336
- * This source code is licensed under the MIT license found in the
1337
- * LICENSE file in the root directory of this source tree.
1338
- */
1339
- function escapeHTML(str) {
1340
- return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
1341
- }
1342
-
1343
- Object.defineProperty(markup, '__esModule', {
1344
- value: true
1345
- });
1346
- markup.printText =
1347
- markup.printProps =
1348
- markup.printElementAsLeaf =
1349
- markup.printElement =
1350
- markup.printComment =
1351
- markup.printChildren =
1352
- void 0;
1353
-
1354
- var _escapeHTML = _interopRequireDefault$1(escapeHTML$1);
1355
-
1356
- function _interopRequireDefault$1(obj) {
1357
- return obj && obj.__esModule ? obj : {default: obj};
1358
- }
1359
-
1360
- /**
1361
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1362
- *
1363
- * This source code is licensed under the MIT license found in the
1364
- * LICENSE file in the root directory of this source tree.
1365
- */
1366
- // Return empty string if keys is empty.
1367
- const printProps = (keys, props, config, indentation, depth, refs, printer) => {
1368
- const indentationNext = indentation + config.indent;
1369
- const colors = config.colors;
1370
- return keys
1371
- .map(key => {
1372
- const value = props[key];
1373
- let printed = printer(value, config, indentationNext, depth, refs);
1374
-
1375
- if (typeof value !== 'string') {
1376
- if (printed.indexOf('\n') !== -1) {
1377
- printed =
1378
- config.spacingOuter +
1379
- indentationNext +
1380
- printed +
1381
- config.spacingOuter +
1382
- indentation;
1383
- }
1384
-
1385
- printed = '{' + printed + '}';
1386
- }
1387
-
1388
- return (
1389
- config.spacingInner +
1390
- indentation +
1391
- colors.prop.open +
1392
- key +
1393
- colors.prop.close +
1394
- '=' +
1395
- colors.value.open +
1396
- printed +
1397
- colors.value.close
1398
- );
1399
- })
1400
- .join('');
1401
- }; // Return empty string if children is empty.
1402
-
1403
- markup.printProps = printProps;
1404
-
1405
- const printChildren = (children, config, indentation, depth, refs, printer) =>
1406
- children
1407
- .map(
1408
- child =>
1409
- config.spacingOuter +
1410
- indentation +
1411
- (typeof child === 'string'
1412
- ? printText(child, config)
1413
- : printer(child, config, indentation, depth, refs))
1414
- )
1415
- .join('');
1416
-
1417
- markup.printChildren = printChildren;
1418
-
1419
- const printText = (text, config) => {
1420
- const contentColor = config.colors.content;
1421
- return (
1422
- contentColor.open + (0, _escapeHTML.default)(text) + contentColor.close
1423
- );
1424
- };
1425
-
1426
- markup.printText = printText;
1427
-
1428
- const printComment = (comment, config) => {
1429
- const commentColor = config.colors.comment;
1430
- return (
1431
- commentColor.open +
1432
- '<!--' +
1433
- (0, _escapeHTML.default)(comment) +
1434
- '-->' +
1435
- commentColor.close
1436
- );
1437
- }; // Separate the functions to format props, children, and element,
1438
- // so a plugin could override a particular function, if needed.
1439
- // Too bad, so sad: the traditional (but unnecessary) space
1440
- // in a self-closing tagColor requires a second test of printedProps.
1441
-
1442
- markup.printComment = printComment;
1443
-
1444
- const printElement = (
1445
- type,
1446
- printedProps,
1447
- printedChildren,
1448
- config,
1449
- indentation
1450
- ) => {
1451
- const tagColor = config.colors.tag;
1452
- return (
1453
- tagColor.open +
1454
- '<' +
1455
- type +
1456
- (printedProps &&
1457
- tagColor.close +
1458
- printedProps +
1459
- config.spacingOuter +
1460
- indentation +
1461
- tagColor.open) +
1462
- (printedChildren
1463
- ? '>' +
1464
- tagColor.close +
1465
- printedChildren +
1466
- config.spacingOuter +
1467
- indentation +
1468
- tagColor.open +
1469
- '</' +
1470
- type
1471
- : (printedProps && !config.min ? '' : ' ') + '/') +
1472
- '>' +
1473
- tagColor.close
1474
- );
1475
- };
1476
-
1477
- markup.printElement = printElement;
1478
-
1479
- const printElementAsLeaf = (type, config) => {
1480
- const tagColor = config.colors.tag;
1481
- return (
1482
- tagColor.open +
1483
- '<' +
1484
- type +
1485
- tagColor.close +
1486
- ' …' +
1487
- tagColor.open +
1488
- ' />' +
1489
- tagColor.close
1490
- );
1491
- };
1492
-
1493
- markup.printElementAsLeaf = printElementAsLeaf;
1494
-
1495
- Object.defineProperty(DOMElement$2, '__esModule', {
1496
- value: true
1497
- });
1498
- DOMElement$2.test = DOMElement$2.serialize = DOMElement$2.default = void 0;
1499
-
1500
- var _markup$2 = markup;
1501
-
1502
- /**
1503
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1504
- *
1505
- * This source code is licensed under the MIT license found in the
1506
- * LICENSE file in the root directory of this source tree.
1507
- */
1508
- const ELEMENT_NODE = 1;
1509
- const TEXT_NODE = 3;
1510
- const COMMENT_NODE = 8;
1511
- const FRAGMENT_NODE = 11;
1512
- const ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/;
1513
-
1514
- const testHasAttribute = val => {
1515
- try {
1516
- return typeof val.hasAttribute === 'function' && val.hasAttribute('is');
1517
- } catch {
1518
- return false;
1519
- }
1520
- };
1521
-
1522
- const testNode = val => {
1523
- const constructorName = val.constructor.name;
1524
- const {nodeType, tagName} = val;
1525
- const isCustomElement =
1526
- (typeof tagName === 'string' && tagName.includes('-')) ||
1527
- testHasAttribute(val);
1528
- return (
1529
- (nodeType === ELEMENT_NODE &&
1530
- (ELEMENT_REGEXP.test(constructorName) || isCustomElement)) ||
1531
- (nodeType === TEXT_NODE && constructorName === 'Text') ||
1532
- (nodeType === COMMENT_NODE && constructorName === 'Comment') ||
1533
- (nodeType === FRAGMENT_NODE && constructorName === 'DocumentFragment')
1534
- );
1535
- };
1536
-
1537
- const test$3 = val => {
1538
- var _val$constructor;
1539
-
1540
- return (
1541
- (val === null || val === void 0
1542
- ? void 0
1543
- : (_val$constructor = val.constructor) === null ||
1544
- _val$constructor === void 0
1545
- ? void 0
1546
- : _val$constructor.name) && testNode(val)
1547
- );
1548
- };
1549
-
1550
- DOMElement$2.test = test$3;
1551
-
1552
- function nodeIsText(node) {
1553
- return node.nodeType === TEXT_NODE;
1554
- }
1555
-
1556
- function nodeIsComment(node) {
1557
- return node.nodeType === COMMENT_NODE;
1558
- }
1559
-
1560
- function nodeIsFragment(node) {
1561
- return node.nodeType === FRAGMENT_NODE;
1562
- }
1563
-
1564
- const serialize$4 = (node, config, indentation, depth, refs, printer) => {
1565
- if (nodeIsText(node)) {
1566
- return (0, _markup$2.printText)(node.data, config);
1567
- }
1568
-
1569
- if (nodeIsComment(node)) {
1570
- return (0, _markup$2.printComment)(node.data, config);
1571
- }
1572
-
1573
- const type = nodeIsFragment(node)
1574
- ? 'DocumentFragment'
1575
- : node.tagName.toLowerCase();
1576
-
1577
- if (++depth > config.maxDepth) {
1578
- return (0, _markup$2.printElementAsLeaf)(type, config);
1579
- }
1580
-
1581
- return (0, _markup$2.printElement)(
1582
- type,
1583
- (0, _markup$2.printProps)(
1584
- nodeIsFragment(node)
1585
- ? []
1586
- : Array.from(node.attributes)
1587
- .map(attr => attr.name)
1588
- .sort(),
1589
- nodeIsFragment(node)
1590
- ? {}
1591
- : Array.from(node.attributes).reduce((props, attribute) => {
1592
- props[attribute.name] = attribute.value;
1593
- return props;
1594
- }, {}),
1595
- config,
1596
- indentation + config.indent,
1597
- depth,
1598
- refs,
1599
- printer
1600
- ),
1601
- (0, _markup$2.printChildren)(
1602
- Array.prototype.slice.call(node.childNodes || node.children),
1603
- config,
1604
- indentation + config.indent,
1605
- depth,
1606
- refs,
1607
- printer
1608
- ),
1609
- config,
1610
- indentation
1611
- );
1612
- };
1613
-
1614
- DOMElement$2.serialize = serialize$4;
1615
- const plugin$3 = {
1616
- serialize: serialize$4,
1617
- test: test$3
1618
- };
1619
- var _default$4 = plugin$3;
1620
- DOMElement$2.default = _default$4;
1621
-
1622
- var Immutable$2 = {};
1623
-
1624
- Object.defineProperty(Immutable$2, '__esModule', {
1625
- value: true
1626
- });
1627
- Immutable$2.test = Immutable$2.serialize = Immutable$2.default = void 0;
1628
-
1629
- var _collections$1 = collections;
1630
-
1631
- /**
1632
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1633
- *
1634
- * This source code is licensed under the MIT license found in the
1635
- * LICENSE file in the root directory of this source tree.
1636
- */
1637
- // SENTINEL constants are from https://github.com/facebook/immutable-js
1638
- const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
1639
- const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
1640
- const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
1641
- const IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
1642
- const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
1643
- const IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
1644
-
1645
- const IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
1646
- const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
1647
- const IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
1648
-
1649
- const getImmutableName = name => 'Immutable.' + name;
1650
-
1651
- const printAsLeaf = name => '[' + name + ']';
1652
-
1653
- const SPACE = ' ';
1654
- const LAZY = '…'; // Seq is lazy if it calls a method like filter
1655
-
1656
- const printImmutableEntries = (
1657
- val,
1658
- config,
1659
- indentation,
1660
- depth,
1661
- refs,
1662
- printer,
1663
- type
1664
- ) =>
1665
- ++depth > config.maxDepth
1666
- ? printAsLeaf(getImmutableName(type))
1667
- : getImmutableName(type) +
1668
- SPACE +
1669
- '{' +
1670
- (0, _collections$1.printIteratorEntries)(
1671
- val.entries(),
1672
- config,
1673
- indentation,
1674
- depth,
1675
- refs,
1676
- printer
1677
- ) +
1678
- '}'; // Record has an entries method because it is a collection in immutable v3.
1679
- // Return an iterator for Immutable Record from version v3 or v4.
1680
-
1681
- function getRecordEntries(val) {
1682
- let i = 0;
1683
- return {
1684
- next() {
1685
- if (i < val._keys.length) {
1686
- const key = val._keys[i++];
1687
- return {
1688
- done: false,
1689
- value: [key, val.get(key)]
1690
- };
1691
- }
1692
-
1693
- return {
1694
- done: true,
1695
- value: undefined
1696
- };
1697
- }
1698
- };
1699
- }
1700
-
1701
- const printImmutableRecord = (
1702
- val,
1703
- config,
1704
- indentation,
1705
- depth,
1706
- refs,
1707
- printer
1708
- ) => {
1709
- // _name property is defined only for an Immutable Record instance
1710
- // which was constructed with a second optional descriptive name arg
1711
- const name = getImmutableName(val._name || 'Record');
1712
- return ++depth > config.maxDepth
1713
- ? printAsLeaf(name)
1714
- : name +
1715
- SPACE +
1716
- '{' +
1717
- (0, _collections$1.printIteratorEntries)(
1718
- getRecordEntries(val),
1719
- config,
1720
- indentation,
1721
- depth,
1722
- refs,
1723
- printer
1724
- ) +
1725
- '}';
1726
- };
1727
-
1728
- const printImmutableSeq = (val, config, indentation, depth, refs, printer) => {
1729
- const name = getImmutableName('Seq');
1730
-
1731
- if (++depth > config.maxDepth) {
1732
- return printAsLeaf(name);
1733
- }
1734
-
1735
- if (val[IS_KEYED_SENTINEL]) {
1736
- return (
1737
- name +
1738
- SPACE +
1739
- '{' + // from Immutable collection of entries or from ECMAScript object
1740
- (val._iter || val._object
1741
- ? (0, _collections$1.printIteratorEntries)(
1742
- val.entries(),
1743
- config,
1744
- indentation,
1745
- depth,
1746
- refs,
1747
- printer
1748
- )
1749
- : LAZY) +
1750
- '}'
1751
- );
1752
- }
1753
-
1754
- return (
1755
- name +
1756
- SPACE +
1757
- '[' +
1758
- (val._iter || // from Immutable collection of values
1759
- val._array || // from ECMAScript array
1760
- val._collection || // from ECMAScript collection in immutable v4
1761
- val._iterable // from ECMAScript collection in immutable v3
1762
- ? (0, _collections$1.printIteratorValues)(
1763
- val.values(),
1764
- config,
1765
- indentation,
1766
- depth,
1767
- refs,
1768
- printer
1769
- )
1770
- : LAZY) +
1771
- ']'
1772
- );
1773
- };
1774
-
1775
- const printImmutableValues = (
1776
- val,
1777
- config,
1778
- indentation,
1779
- depth,
1780
- refs,
1781
- printer,
1782
- type
1783
- ) =>
1784
- ++depth > config.maxDepth
1785
- ? printAsLeaf(getImmutableName(type))
1786
- : getImmutableName(type) +
1787
- SPACE +
1788
- '[' +
1789
- (0, _collections$1.printIteratorValues)(
1790
- val.values(),
1791
- config,
1792
- indentation,
1793
- depth,
1794
- refs,
1795
- printer
1796
- ) +
1797
- ']';
1798
-
1799
- const serialize$3 = (val, config, indentation, depth, refs, printer) => {
1800
- if (val[IS_MAP_SENTINEL]) {
1801
- return printImmutableEntries(
1802
- val,
1803
- config,
1804
- indentation,
1805
- depth,
1806
- refs,
1807
- printer,
1808
- val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map'
1809
- );
1810
- }
1811
-
1812
- if (val[IS_LIST_SENTINEL]) {
1813
- return printImmutableValues(
1814
- val,
1815
- config,
1816
- indentation,
1817
- depth,
1818
- refs,
1819
- printer,
1820
- 'List'
1821
- );
1822
- }
1823
-
1824
- if (val[IS_SET_SENTINEL]) {
1825
- return printImmutableValues(
1826
- val,
1827
- config,
1828
- indentation,
1829
- depth,
1830
- refs,
1831
- printer,
1832
- val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set'
1833
- );
1834
- }
1835
-
1836
- if (val[IS_STACK_SENTINEL]) {
1837
- return printImmutableValues(
1838
- val,
1839
- config,
1840
- indentation,
1841
- depth,
1842
- refs,
1843
- printer,
1844
- 'Stack'
1845
- );
1846
- }
1847
-
1848
- if (val[IS_SEQ_SENTINEL]) {
1849
- return printImmutableSeq(val, config, indentation, depth, refs, printer);
1850
- } // For compatibility with immutable v3 and v4, let record be the default.
1851
-
1852
- return printImmutableRecord(val, config, indentation, depth, refs, printer);
1853
- }; // Explicitly comparing sentinel properties to true avoids false positive
1854
- // when mock identity-obj-proxy returns the key as the value for any key.
1855
-
1856
- Immutable$2.serialize = serialize$3;
1857
-
1858
- const test$2 = val =>
1859
- val &&
1860
- (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
1861
-
1862
- Immutable$2.test = test$2;
1863
- const plugin$2 = {
1864
- serialize: serialize$3,
1865
- test: test$2
1866
- };
1867
- var _default$3 = plugin$2;
1868
- Immutable$2.default = _default$3;
1869
-
1870
- var ReactElement$2 = {};
1871
-
1872
- var reactIs = {exports: {}};
1873
-
1874
- var reactIs_production_min = {};
1875
-
1876
- /** @license React v17.0.2
1877
- * react-is.production.min.js
1878
- *
1879
- * Copyright (c) Facebook, Inc. and its affiliates.
1880
- *
1881
- * This source code is licensed under the MIT license found in the
1882
- * LICENSE file in the root directory of this source tree.
1883
- */
1884
- 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;
1885
- 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");}
1886
- 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;
1887
- 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};
1888
- 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};
1889
- reactIs_production_min.typeOf=y;
1890
-
1891
- var reactIs_development = {};
1892
-
1893
- /** @license React v17.0.2
1894
- * react-is.development.js
1895
- *
1896
- * Copyright (c) Facebook, Inc. and its affiliates.
1897
- *
1898
- * This source code is licensed under the MIT license found in the
1899
- * LICENSE file in the root directory of this source tree.
1900
- */
1901
-
1902
- if (process.env.NODE_ENV !== "production") {
1903
- (function() {
1904
-
1905
- // ATTENTION
1906
- // When adding new symbols to this file,
1907
- // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
1908
- // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
1909
- // nor polyfill, then a plain number is used for performance.
1910
- var REACT_ELEMENT_TYPE = 0xeac7;
1911
- var REACT_PORTAL_TYPE = 0xeaca;
1912
- var REACT_FRAGMENT_TYPE = 0xeacb;
1913
- var REACT_STRICT_MODE_TYPE = 0xeacc;
1914
- var REACT_PROFILER_TYPE = 0xead2;
1915
- var REACT_PROVIDER_TYPE = 0xeacd;
1916
- var REACT_CONTEXT_TYPE = 0xeace;
1917
- var REACT_FORWARD_REF_TYPE = 0xead0;
1918
- var REACT_SUSPENSE_TYPE = 0xead1;
1919
- var REACT_SUSPENSE_LIST_TYPE = 0xead8;
1920
- var REACT_MEMO_TYPE = 0xead3;
1921
- var REACT_LAZY_TYPE = 0xead4;
1922
- var REACT_BLOCK_TYPE = 0xead9;
1923
- var REACT_SERVER_BLOCK_TYPE = 0xeada;
1924
- var REACT_FUNDAMENTAL_TYPE = 0xead5;
1925
- var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
1926
- var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
1927
-
1928
- if (typeof Symbol === 'function' && Symbol.for) {
1929
- var symbolFor = Symbol.for;
1930
- REACT_ELEMENT_TYPE = symbolFor('react.element');
1931
- REACT_PORTAL_TYPE = symbolFor('react.portal');
1932
- REACT_FRAGMENT_TYPE = symbolFor('react.fragment');
1933
- REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
1934
- REACT_PROFILER_TYPE = symbolFor('react.profiler');
1935
- REACT_PROVIDER_TYPE = symbolFor('react.provider');
1936
- REACT_CONTEXT_TYPE = symbolFor('react.context');
1937
- REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
1938
- REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
1939
- REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
1940
- REACT_MEMO_TYPE = symbolFor('react.memo');
1941
- REACT_LAZY_TYPE = symbolFor('react.lazy');
1942
- REACT_BLOCK_TYPE = symbolFor('react.block');
1943
- REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
1944
- REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
1945
- symbolFor('react.scope');
1946
- symbolFor('react.opaque.id');
1947
- REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
1948
- symbolFor('react.offscreen');
1949
- REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
1950
- }
1951
-
1952
- // Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
1953
-
1954
- var enableScopeAPI = false; // Experimental Create Event Handle API.
1955
-
1956
- function isValidElementType(type) {
1957
- if (typeof type === 'string' || typeof type === 'function') {
1958
- return true;
1959
- } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
1960
-
1961
-
1962
- 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 ) {
1963
- return true;
1964
- }
1965
-
1966
- if (typeof type === 'object' && type !== null) {
1967
- 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) {
1968
- return true;
1969
- }
1970
- }
1971
-
1972
- return false;
1973
- }
1974
-
1975
- function typeOf(object) {
1976
- if (typeof object === 'object' && object !== null) {
1977
- var $$typeof = object.$$typeof;
1978
-
1979
- switch ($$typeof) {
1980
- case REACT_ELEMENT_TYPE:
1981
- var type = object.type;
1982
-
1983
- switch (type) {
1984
- case REACT_FRAGMENT_TYPE:
1985
- case REACT_PROFILER_TYPE:
1986
- case REACT_STRICT_MODE_TYPE:
1987
- case REACT_SUSPENSE_TYPE:
1988
- case REACT_SUSPENSE_LIST_TYPE:
1989
- return type;
1990
-
1991
- default:
1992
- var $$typeofType = type && type.$$typeof;
1993
-
1994
- switch ($$typeofType) {
1995
- case REACT_CONTEXT_TYPE:
1996
- case REACT_FORWARD_REF_TYPE:
1997
- case REACT_LAZY_TYPE:
1998
- case REACT_MEMO_TYPE:
1999
- case REACT_PROVIDER_TYPE:
2000
- return $$typeofType;
2001
-
2002
- default:
2003
- return $$typeof;
2004
- }
2005
-
2006
- }
2007
-
2008
- case REACT_PORTAL_TYPE:
2009
- return $$typeof;
2010
- }
2011
- }
2012
-
2013
- return undefined;
2014
- }
2015
- var ContextConsumer = REACT_CONTEXT_TYPE;
2016
- var ContextProvider = REACT_PROVIDER_TYPE;
2017
- var Element = REACT_ELEMENT_TYPE;
2018
- var ForwardRef = REACT_FORWARD_REF_TYPE;
2019
- var Fragment = REACT_FRAGMENT_TYPE;
2020
- var Lazy = REACT_LAZY_TYPE;
2021
- var Memo = REACT_MEMO_TYPE;
2022
- var Portal = REACT_PORTAL_TYPE;
2023
- var Profiler = REACT_PROFILER_TYPE;
2024
- var StrictMode = REACT_STRICT_MODE_TYPE;
2025
- var Suspense = REACT_SUSPENSE_TYPE;
2026
- var hasWarnedAboutDeprecatedIsAsyncMode = false;
2027
- var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
2028
-
2029
- function isAsyncMode(object) {
2030
- {
2031
- if (!hasWarnedAboutDeprecatedIsAsyncMode) {
2032
- hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
2033
-
2034
- console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
2035
- }
2036
- }
2037
-
2038
- return false;
2039
- }
2040
- function isConcurrentMode(object) {
2041
- {
2042
- if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
2043
- hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
2044
-
2045
- console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
2046
- }
2047
- }
2048
-
2049
- return false;
2050
- }
2051
- function isContextConsumer(object) {
2052
- return typeOf(object) === REACT_CONTEXT_TYPE;
2053
- }
2054
- function isContextProvider(object) {
2055
- return typeOf(object) === REACT_PROVIDER_TYPE;
2056
- }
2057
- function isElement(object) {
2058
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
2059
- }
2060
- function isForwardRef(object) {
2061
- return typeOf(object) === REACT_FORWARD_REF_TYPE;
2062
- }
2063
- function isFragment(object) {
2064
- return typeOf(object) === REACT_FRAGMENT_TYPE;
2065
- }
2066
- function isLazy(object) {
2067
- return typeOf(object) === REACT_LAZY_TYPE;
2068
- }
2069
- function isMemo(object) {
2070
- return typeOf(object) === REACT_MEMO_TYPE;
2071
- }
2072
- function isPortal(object) {
2073
- return typeOf(object) === REACT_PORTAL_TYPE;
2074
- }
2075
- function isProfiler(object) {
2076
- return typeOf(object) === REACT_PROFILER_TYPE;
2077
- }
2078
- function isStrictMode(object) {
2079
- return typeOf(object) === REACT_STRICT_MODE_TYPE;
2080
- }
2081
- function isSuspense(object) {
2082
- return typeOf(object) === REACT_SUSPENSE_TYPE;
2083
- }
2084
-
2085
- reactIs_development.ContextConsumer = ContextConsumer;
2086
- reactIs_development.ContextProvider = ContextProvider;
2087
- reactIs_development.Element = Element;
2088
- reactIs_development.ForwardRef = ForwardRef;
2089
- reactIs_development.Fragment = Fragment;
2090
- reactIs_development.Lazy = Lazy;
2091
- reactIs_development.Memo = Memo;
2092
- reactIs_development.Portal = Portal;
2093
- reactIs_development.Profiler = Profiler;
2094
- reactIs_development.StrictMode = StrictMode;
2095
- reactIs_development.Suspense = Suspense;
2096
- reactIs_development.isAsyncMode = isAsyncMode;
2097
- reactIs_development.isConcurrentMode = isConcurrentMode;
2098
- reactIs_development.isContextConsumer = isContextConsumer;
2099
- reactIs_development.isContextProvider = isContextProvider;
2100
- reactIs_development.isElement = isElement;
2101
- reactIs_development.isForwardRef = isForwardRef;
2102
- reactIs_development.isFragment = isFragment;
2103
- reactIs_development.isLazy = isLazy;
2104
- reactIs_development.isMemo = isMemo;
2105
- reactIs_development.isPortal = isPortal;
2106
- reactIs_development.isProfiler = isProfiler;
2107
- reactIs_development.isStrictMode = isStrictMode;
2108
- reactIs_development.isSuspense = isSuspense;
2109
- reactIs_development.isValidElementType = isValidElementType;
2110
- reactIs_development.typeOf = typeOf;
2111
- })();
2112
- }
2113
-
2114
- if (process.env.NODE_ENV === 'production') {
2115
- reactIs.exports = reactIs_production_min;
2116
- } else {
2117
- reactIs.exports = reactIs_development;
2118
- }
2119
-
2120
- Object.defineProperty(ReactElement$2, '__esModule', {
2121
- value: true
2122
- });
2123
- ReactElement$2.test = ReactElement$2.serialize = ReactElement$2.default = void 0;
2124
-
2125
- var ReactIs = _interopRequireWildcard(reactIs.exports);
2126
-
2127
- var _markup$1 = markup;
2128
-
2129
- function _getRequireWildcardCache(nodeInterop) {
2130
- if (typeof WeakMap !== 'function') return null;
2131
- var cacheBabelInterop = new WeakMap();
2132
- var cacheNodeInterop = new WeakMap();
2133
- return (_getRequireWildcardCache = function (nodeInterop) {
2134
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
2135
- })(nodeInterop);
2136
- }
2137
-
2138
- function _interopRequireWildcard(obj, nodeInterop) {
2139
- if (!nodeInterop && obj && obj.__esModule) {
2140
- return obj;
2141
- }
2142
- if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
2143
- return {default: obj};
2144
- }
2145
- var cache = _getRequireWildcardCache(nodeInterop);
2146
- if (cache && cache.has(obj)) {
2147
- return cache.get(obj);
2148
- }
2149
- var newObj = {};
2150
- var hasPropertyDescriptor =
2151
- Object.defineProperty && Object.getOwnPropertyDescriptor;
2152
- for (var key in obj) {
2153
- if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
2154
- var desc = hasPropertyDescriptor
2155
- ? Object.getOwnPropertyDescriptor(obj, key)
2156
- : null;
2157
- if (desc && (desc.get || desc.set)) {
2158
- Object.defineProperty(newObj, key, desc);
2159
- } else {
2160
- newObj[key] = obj[key];
2161
- }
2162
- }
2163
- }
2164
- newObj.default = obj;
2165
- if (cache) {
2166
- cache.set(obj, newObj);
2167
- }
2168
- return newObj;
2169
- }
2170
-
2171
- /**
2172
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2173
- *
2174
- * This source code is licensed under the MIT license found in the
2175
- * LICENSE file in the root directory of this source tree.
2176
- */
2177
- // Given element.props.children, or subtree during recursive traversal,
2178
- // return flattened array of children.
2179
- const getChildren = (arg, children = []) => {
2180
- if (Array.isArray(arg)) {
2181
- arg.forEach(item => {
2182
- getChildren(item, children);
2183
- });
2184
- } else if (arg != null && arg !== false) {
2185
- children.push(arg);
2186
- }
2187
-
2188
- return children;
2189
- };
2190
-
2191
- const getType = element => {
2192
- const type = element.type;
2193
-
2194
- if (typeof type === 'string') {
2195
- return type;
2196
- }
2197
-
2198
- if (typeof type === 'function') {
2199
- return type.displayName || type.name || 'Unknown';
2200
- }
2201
-
2202
- if (ReactIs.isFragment(element)) {
2203
- return 'React.Fragment';
2204
- }
2205
-
2206
- if (ReactIs.isSuspense(element)) {
2207
- return 'React.Suspense';
2208
- }
2209
-
2210
- if (typeof type === 'object' && type !== null) {
2211
- if (ReactIs.isContextProvider(element)) {
2212
- return 'Context.Provider';
2213
- }
2214
-
2215
- if (ReactIs.isContextConsumer(element)) {
2216
- return 'Context.Consumer';
2217
- }
2218
-
2219
- if (ReactIs.isForwardRef(element)) {
2220
- if (type.displayName) {
2221
- return type.displayName;
2222
- }
2223
-
2224
- const functionName = type.render.displayName || type.render.name || '';
2225
- return functionName !== ''
2226
- ? 'ForwardRef(' + functionName + ')'
2227
- : 'ForwardRef';
2228
- }
2229
-
2230
- if (ReactIs.isMemo(element)) {
2231
- const functionName =
2232
- type.displayName || type.type.displayName || type.type.name || '';
2233
- return functionName !== '' ? 'Memo(' + functionName + ')' : 'Memo';
2234
- }
2235
- }
2236
-
2237
- return 'UNDEFINED';
2238
- };
2239
-
2240
- const getPropKeys$1 = element => {
2241
- const {props} = element;
2242
- return Object.keys(props)
2243
- .filter(key => key !== 'children' && props[key] !== undefined)
2244
- .sort();
2245
- };
2246
-
2247
- const serialize$2 = (element, config, indentation, depth, refs, printer) =>
2248
- ++depth > config.maxDepth
2249
- ? (0, _markup$1.printElementAsLeaf)(getType(element), config)
2250
- : (0, _markup$1.printElement)(
2251
- getType(element),
2252
- (0, _markup$1.printProps)(
2253
- getPropKeys$1(element),
2254
- element.props,
2255
- config,
2256
- indentation + config.indent,
2257
- depth,
2258
- refs,
2259
- printer
2260
- ),
2261
- (0, _markup$1.printChildren)(
2262
- getChildren(element.props.children),
2263
- config,
2264
- indentation + config.indent,
2265
- depth,
2266
- refs,
2267
- printer
2268
- ),
2269
- config,
2270
- indentation
2271
- );
2272
-
2273
- ReactElement$2.serialize = serialize$2;
2274
-
2275
- const test$1 = val => val != null && ReactIs.isElement(val);
2276
-
2277
- ReactElement$2.test = test$1;
2278
- const plugin$1 = {
2279
- serialize: serialize$2,
2280
- test: test$1
2281
- };
2282
- var _default$2 = plugin$1;
2283
- ReactElement$2.default = _default$2;
2284
-
2285
- var ReactTestComponent$2 = {};
2286
-
2287
- Object.defineProperty(ReactTestComponent$2, '__esModule', {
2288
- value: true
2289
- });
2290
- ReactTestComponent$2.test = ReactTestComponent$2.serialize = ReactTestComponent$2.default = void 0;
2291
-
2292
- var _markup = markup;
2293
-
2294
- var global$2 = (function () {
2295
- if (typeof globalThis !== 'undefined') {
2296
- return globalThis;
2297
- } else if (typeof global$2 !== 'undefined') {
2298
- return global$2;
2299
- } else if (typeof self !== 'undefined') {
2300
- return self;
2301
- } else if (typeof window !== 'undefined') {
2302
- return window;
2303
- } else {
2304
- return Function('return this')();
2305
- }
2306
- })();
2307
-
2308
- var Symbol$1 = global$2['jest-symbol-do-not-touch'] || global$2.Symbol;
2309
- const testSymbol =
2310
- typeof Symbol$1 === 'function' && Symbol$1.for
2311
- ? Symbol$1.for('react.test.json')
2312
- : 0xea71357;
2313
-
2314
- const getPropKeys = object => {
2315
- const {props} = object;
2316
- return props
2317
- ? Object.keys(props)
2318
- .filter(key => props[key] !== undefined)
2319
- .sort()
2320
- : [];
2321
- };
2322
-
2323
- const serialize$1 = (object, config, indentation, depth, refs, printer) =>
2324
- ++depth > config.maxDepth
2325
- ? (0, _markup.printElementAsLeaf)(object.type, config)
2326
- : (0, _markup.printElement)(
2327
- object.type,
2328
- object.props
2329
- ? (0, _markup.printProps)(
2330
- getPropKeys(object),
2331
- object.props,
2332
- config,
2333
- indentation + config.indent,
2334
- depth,
2335
- refs,
2336
- printer
2337
- )
2338
- : '',
2339
- object.children
2340
- ? (0, _markup.printChildren)(
2341
- object.children,
2342
- config,
2343
- indentation + config.indent,
2344
- depth,
2345
- refs,
2346
- printer
2347
- )
2348
- : '',
2349
- config,
2350
- indentation
2351
- );
2352
-
2353
- ReactTestComponent$2.serialize = serialize$1;
2354
-
2355
- const test = val => val && val.$$typeof === testSymbol;
2356
-
2357
- ReactTestComponent$2.test = test;
2358
- const plugin = {
2359
- serialize: serialize$1,
2360
- test
2361
- };
2362
- var _default$1 = plugin;
2363
- ReactTestComponent$2.default = _default$1;
2364
-
2365
- Object.defineProperty(build, '__esModule', {
2366
- value: true
2367
- });
2368
- build.default = build.DEFAULT_OPTIONS = void 0;
2369
- var format_1 = build.format = format;
2370
- var plugins_1 = build.plugins = void 0;
2371
-
2372
- var _ansiStyles = _interopRequireDefault(ansiStyles.exports);
2373
-
2374
- var _collections = collections;
2375
-
2376
- var _AsymmetricMatcher = _interopRequireDefault(
2377
- AsymmetricMatcher$3
2378
- );
2379
-
2380
- var _ConvertAnsi = _interopRequireDefault(ConvertAnsi);
2381
-
2382
- var _DOMCollection = _interopRequireDefault(DOMCollection$2);
2383
-
2384
- var _DOMElement = _interopRequireDefault(DOMElement$2);
2385
-
2386
- var _Immutable = _interopRequireDefault(Immutable$2);
2387
-
2388
- var _ReactElement = _interopRequireDefault(ReactElement$2);
2389
-
2390
- var _ReactTestComponent = _interopRequireDefault(
2391
- ReactTestComponent$2
2392
- );
2393
-
2394
- function _interopRequireDefault(obj) {
2395
- return obj && obj.__esModule ? obj : {default: obj};
2396
- }
2397
-
2398
- /**
2399
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2400
- *
2401
- * This source code is licensed under the MIT license found in the
2402
- * LICENSE file in the root directory of this source tree.
2403
- */
2404
-
2405
- /* eslint-disable local/ban-types-eventually */
2406
- const toString = Object.prototype.toString;
2407
- const toISOString = Date.prototype.toISOString;
2408
- const errorToString = Error.prototype.toString;
2409
- const regExpToString = RegExp.prototype.toString;
2410
- /**
2411
- * Explicitly comparing typeof constructor to function avoids undefined as name
2412
- * when mock identity-obj-proxy returns the key as the value for any key.
2413
- */
2414
-
2415
- const getConstructorName = val =>
2416
- (typeof val.constructor === 'function' && val.constructor.name) || 'Object';
2417
- /* global window */
2418
-
2419
- /** Is val is equal to global window object? Works even if it does not exist :) */
2420
-
2421
- const isWindow = val => typeof window !== 'undefined' && val === window;
2422
-
2423
- const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
2424
- const NEWLINE_REGEXP = /\n/gi;
2425
-
2426
- class PrettyFormatPluginError extends Error {
2427
- constructor(message, stack) {
2428
- super(message);
2429
- this.stack = stack;
2430
- this.name = this.constructor.name;
2431
- }
2432
- }
2433
-
2434
- function isToStringedArrayType(toStringed) {
2435
- return (
2436
- toStringed === '[object Array]' ||
2437
- toStringed === '[object ArrayBuffer]' ||
2438
- toStringed === '[object DataView]' ||
2439
- toStringed === '[object Float32Array]' ||
2440
- toStringed === '[object Float64Array]' ||
2441
- toStringed === '[object Int8Array]' ||
2442
- toStringed === '[object Int16Array]' ||
2443
- toStringed === '[object Int32Array]' ||
2444
- toStringed === '[object Uint8Array]' ||
2445
- toStringed === '[object Uint8ClampedArray]' ||
2446
- toStringed === '[object Uint16Array]' ||
2447
- toStringed === '[object Uint32Array]'
2448
- );
2449
- }
2450
-
2451
- function printNumber(val) {
2452
- return Object.is(val, -0) ? '-0' : String(val);
2453
- }
2454
-
2455
- function printBigInt(val) {
2456
- return String(`${val}n`);
2457
- }
2458
-
2459
- function printFunction(val, printFunctionName) {
2460
- if (!printFunctionName) {
2461
- return '[Function]';
2462
- }
2463
-
2464
- return '[Function ' + (val.name || 'anonymous') + ']';
2465
- }
2466
-
2467
- function printSymbol(val) {
2468
- return String(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
2469
- }
2470
-
2471
- function printError(val) {
2472
- return '[' + errorToString.call(val) + ']';
2473
- }
2474
- /**
2475
- * The first port of call for printing an object, handles most of the
2476
- * data-types in JS.
2477
- */
2478
-
2479
- function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
2480
- if (val === true || val === false) {
2481
- return '' + val;
2482
- }
2483
-
2484
- if (val === undefined) {
2485
- return 'undefined';
2486
- }
2487
-
2488
- if (val === null) {
2489
- return 'null';
2490
- }
2491
-
2492
- const typeOf = typeof val;
2493
-
2494
- if (typeOf === 'number') {
2495
- return printNumber(val);
2496
- }
2497
-
2498
- if (typeOf === 'bigint') {
2499
- return printBigInt(val);
2500
- }
2501
-
2502
- if (typeOf === 'string') {
2503
- if (escapeString) {
2504
- return '"' + val.replace(/"|\\/g, '\\$&') + '"';
2505
- }
2506
-
2507
- return '"' + val + '"';
2508
- }
2509
-
2510
- if (typeOf === 'function') {
2511
- return printFunction(val, printFunctionName);
2512
- }
2513
-
2514
- if (typeOf === 'symbol') {
2515
- return printSymbol(val);
2516
- }
2517
-
2518
- const toStringed = toString.call(val);
2519
-
2520
- if (toStringed === '[object WeakMap]') {
2521
- return 'WeakMap {}';
2522
- }
2523
-
2524
- if (toStringed === '[object WeakSet]') {
2525
- return 'WeakSet {}';
2526
- }
2527
-
2528
- if (
2529
- toStringed === '[object Function]' ||
2530
- toStringed === '[object GeneratorFunction]'
2531
- ) {
2532
- return printFunction(val, printFunctionName);
2533
- }
2534
-
2535
- if (toStringed === '[object Symbol]') {
2536
- return printSymbol(val);
2537
- }
2538
-
2539
- if (toStringed === '[object Date]') {
2540
- return isNaN(+val) ? 'Date { NaN }' : toISOString.call(val);
2541
- }
2542
-
2543
- if (toStringed === '[object Error]') {
2544
- return printError(val);
2545
- }
2546
-
2547
- if (toStringed === '[object RegExp]') {
2548
- if (escapeRegex) {
2549
- // https://github.com/benjamingr/RegExp.escape/blob/main/polyfill.js
2550
- return regExpToString.call(val).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
2551
- }
2552
-
2553
- return regExpToString.call(val);
2554
- }
2555
-
2556
- if (val instanceof Error) {
2557
- return printError(val);
2558
- }
2559
-
2560
- return null;
2561
- }
2562
- /**
2563
- * Handles more complex objects ( such as objects with circular references.
2564
- * maps and sets etc )
2565
- */
2566
-
2567
- function printComplexValue(
2568
- val,
2569
- config,
2570
- indentation,
2571
- depth,
2572
- refs,
2573
- hasCalledToJSON
2574
- ) {
2575
- if (refs.indexOf(val) !== -1) {
2576
- return '[Circular]';
2577
- }
2578
-
2579
- refs = refs.slice();
2580
- refs.push(val);
2581
- const hitMaxDepth = ++depth > config.maxDepth;
2582
- const min = config.min;
2583
-
2584
- if (
2585
- config.callToJSON &&
2586
- !hitMaxDepth &&
2587
- val.toJSON &&
2588
- typeof val.toJSON === 'function' &&
2589
- !hasCalledToJSON
2590
- ) {
2591
- return printer(val.toJSON(), config, indentation, depth, refs, true);
2592
- }
2593
-
2594
- const toStringed = toString.call(val);
2595
-
2596
- if (toStringed === '[object Arguments]') {
2597
- return hitMaxDepth
2598
- ? '[Arguments]'
2599
- : (min ? '' : 'Arguments ') +
2600
- '[' +
2601
- (0, _collections.printListItems)(
2602
- val,
2603
- config,
2604
- indentation,
2605
- depth,
2606
- refs,
2607
- printer
2608
- ) +
2609
- ']';
2610
- }
2611
-
2612
- if (isToStringedArrayType(toStringed)) {
2613
- return hitMaxDepth
2614
- ? '[' + val.constructor.name + ']'
2615
- : (min
2616
- ? ''
2617
- : !config.printBasicPrototype && val.constructor.name === 'Array'
2618
- ? ''
2619
- : val.constructor.name + ' ') +
2620
- '[' +
2621
- (0, _collections.printListItems)(
2622
- val,
2623
- config,
2624
- indentation,
2625
- depth,
2626
- refs,
2627
- printer
2628
- ) +
2629
- ']';
2630
- }
2631
-
2632
- if (toStringed === '[object Map]') {
2633
- return hitMaxDepth
2634
- ? '[Map]'
2635
- : 'Map {' +
2636
- (0, _collections.printIteratorEntries)(
2637
- val.entries(),
2638
- config,
2639
- indentation,
2640
- depth,
2641
- refs,
2642
- printer,
2643
- ' => '
2644
- ) +
2645
- '}';
2646
- }
2647
-
2648
- if (toStringed === '[object Set]') {
2649
- return hitMaxDepth
2650
- ? '[Set]'
2651
- : 'Set {' +
2652
- (0, _collections.printIteratorValues)(
2653
- val.values(),
2654
- config,
2655
- indentation,
2656
- depth,
2657
- refs,
2658
- printer
2659
- ) +
2660
- '}';
2661
- } // Avoid failure to serialize global window object in jsdom test environment.
2662
- // For example, not even relevant if window is prop of React element.
2663
-
2664
- return hitMaxDepth || isWindow(val)
2665
- ? '[' + getConstructorName(val) + ']'
2666
- : (min
2667
- ? ''
2668
- : !config.printBasicPrototype && getConstructorName(val) === 'Object'
2669
- ? ''
2670
- : getConstructorName(val) + ' ') +
2671
- '{' +
2672
- (0, _collections.printObjectProperties)(
2673
- val,
2674
- config,
2675
- indentation,
2676
- depth,
2677
- refs,
2678
- printer
2679
- ) +
2680
- '}';
2681
- }
2682
-
2683
- function isNewPlugin(plugin) {
2684
- return plugin.serialize != null;
2685
- }
2686
-
2687
- function printPlugin(plugin, val, config, indentation, depth, refs) {
2688
- let printed;
2689
-
2690
- try {
2691
- printed = isNewPlugin(plugin)
2692
- ? plugin.serialize(val, config, indentation, depth, refs, printer)
2693
- : plugin.print(
2694
- val,
2695
- valChild => printer(valChild, config, indentation, depth, refs),
2696
- str => {
2697
- const indentationNext = indentation + config.indent;
2698
- return (
2699
- indentationNext +
2700
- str.replace(NEWLINE_REGEXP, '\n' + indentationNext)
2701
- );
2702
- },
2703
- {
2704
- edgeSpacing: config.spacingOuter,
2705
- min: config.min,
2706
- spacing: config.spacingInner
2707
- },
2708
- config.colors
2709
- );
2710
- } catch (error) {
2711
- throw new PrettyFormatPluginError(error.message, error.stack);
2712
- }
2713
-
2714
- if (typeof printed !== 'string') {
2715
- throw new Error(
2716
- `pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`
2717
- );
2718
- }
2719
-
2720
- return printed;
2721
- }
2722
-
2723
- function findPlugin(plugins, val) {
2724
- for (let p = 0; p < plugins.length; p++) {
2725
- try {
2726
- if (plugins[p].test(val)) {
2727
- return plugins[p];
2728
- }
2729
- } catch (error) {
2730
- throw new PrettyFormatPluginError(error.message, error.stack);
2731
- }
2732
- }
2733
-
2734
- return null;
2735
- }
2736
-
2737
- function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
2738
- const plugin = findPlugin(config.plugins, val);
2739
-
2740
- if (plugin !== null) {
2741
- return printPlugin(plugin, val, config, indentation, depth, refs);
2742
- }
2743
-
2744
- const basicResult = printBasicValue(
2745
- val,
2746
- config.printFunctionName,
2747
- config.escapeRegex,
2748
- config.escapeString
2749
- );
2750
-
2751
- if (basicResult !== null) {
2752
- return basicResult;
2753
- }
2754
-
2755
- return printComplexValue(
2756
- val,
2757
- config,
2758
- indentation,
2759
- depth,
2760
- refs,
2761
- hasCalledToJSON
2762
- );
2763
- }
2764
-
2765
- const DEFAULT_THEME = {
2766
- comment: 'gray',
2767
- content: 'reset',
2768
- prop: 'yellow',
2769
- tag: 'cyan',
2770
- value: 'green'
2771
- };
2772
- const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
2773
- const DEFAULT_OPTIONS = {
2774
- callToJSON: true,
2775
- compareKeys: undefined,
2776
- escapeRegex: false,
2777
- escapeString: true,
2778
- highlight: false,
2779
- indent: 2,
2780
- maxDepth: Infinity,
2781
- min: false,
2782
- plugins: [],
2783
- printBasicPrototype: true,
2784
- printFunctionName: true,
2785
- theme: DEFAULT_THEME
2786
- };
2787
- build.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
2788
-
2789
- function validateOptions(options) {
2790
- Object.keys(options).forEach(key => {
2791
- if (!DEFAULT_OPTIONS.hasOwnProperty(key)) {
2792
- throw new Error(`pretty-format: Unknown option "${key}".`);
2793
- }
2794
- });
2795
-
2796
- if (options.min && options.indent !== undefined && options.indent !== 0) {
2797
- throw new Error(
2798
- 'pretty-format: Options "min" and "indent" cannot be used together.'
2799
- );
2800
- }
2801
-
2802
- if (options.theme !== undefined) {
2803
- if (options.theme === null) {
2804
- throw new Error('pretty-format: Option "theme" must not be null.');
2805
- }
2806
-
2807
- if (typeof options.theme !== 'object') {
2808
- throw new Error(
2809
- `pretty-format: Option "theme" must be of type "object" but instead received "${typeof options.theme}".`
2810
- );
2811
- }
2812
- }
2813
- }
2814
-
2815
- const getColorsHighlight = options =>
2816
- DEFAULT_THEME_KEYS.reduce((colors, key) => {
2817
- const value =
2818
- options.theme && options.theme[key] !== undefined
2819
- ? options.theme[key]
2820
- : DEFAULT_THEME[key];
2821
- const color = value && _ansiStyles.default[value];
2822
-
2823
- if (
2824
- color &&
2825
- typeof color.close === 'string' &&
2826
- typeof color.open === 'string'
2827
- ) {
2828
- colors[key] = color;
2829
- } else {
2830
- throw new Error(
2831
- `pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`
2832
- );
2833
- }
2834
-
2835
- return colors;
2836
- }, Object.create(null));
2837
-
2838
- const getColorsEmpty = () =>
2839
- DEFAULT_THEME_KEYS.reduce((colors, key) => {
2840
- colors[key] = {
2841
- close: '',
2842
- open: ''
2843
- };
2844
- return colors;
2845
- }, Object.create(null));
2846
-
2847
- const getPrintFunctionName = options =>
2848
- options && options.printFunctionName !== undefined
2849
- ? options.printFunctionName
2850
- : DEFAULT_OPTIONS.printFunctionName;
2851
-
2852
- const getEscapeRegex = options =>
2853
- options && options.escapeRegex !== undefined
2854
- ? options.escapeRegex
2855
- : DEFAULT_OPTIONS.escapeRegex;
2856
-
2857
- const getEscapeString = options =>
2858
- options && options.escapeString !== undefined
2859
- ? options.escapeString
2860
- : DEFAULT_OPTIONS.escapeString;
2861
-
2862
- const getConfig = options => {
2863
- var _options$printBasicPr;
2864
-
2865
- return {
2866
- callToJSON:
2867
- options && options.callToJSON !== undefined
2868
- ? options.callToJSON
2869
- : DEFAULT_OPTIONS.callToJSON,
2870
- colors:
2871
- options && options.highlight
2872
- ? getColorsHighlight(options)
2873
- : getColorsEmpty(),
2874
- compareKeys:
2875
- options && typeof options.compareKeys === 'function'
2876
- ? options.compareKeys
2877
- : DEFAULT_OPTIONS.compareKeys,
2878
- escapeRegex: getEscapeRegex(options),
2879
- escapeString: getEscapeString(options),
2880
- indent:
2881
- options && options.min
2882
- ? ''
2883
- : createIndent(
2884
- options && options.indent !== undefined
2885
- ? options.indent
2886
- : DEFAULT_OPTIONS.indent
2887
- ),
2888
- maxDepth:
2889
- options && options.maxDepth !== undefined
2890
- ? options.maxDepth
2891
- : DEFAULT_OPTIONS.maxDepth,
2892
- min:
2893
- options && options.min !== undefined ? options.min : DEFAULT_OPTIONS.min,
2894
- plugins:
2895
- options && options.plugins !== undefined
2896
- ? options.plugins
2897
- : DEFAULT_OPTIONS.plugins,
2898
- printBasicPrototype:
2899
- (_options$printBasicPr =
2900
- options === null || options === void 0
2901
- ? void 0
2902
- : options.printBasicPrototype) !== null &&
2903
- _options$printBasicPr !== void 0
2904
- ? _options$printBasicPr
2905
- : true,
2906
- printFunctionName: getPrintFunctionName(options),
2907
- spacingInner: options && options.min ? ' ' : '\n',
2908
- spacingOuter: options && options.min ? '' : '\n'
2909
- };
2910
- };
2911
-
2912
- function createIndent(indent) {
2913
- return new Array(indent + 1).join(' ');
2914
- }
2915
- /**
2916
- * Returns a presentation string of your `val` object
2917
- * @param val any potential JavaScript object
2918
- * @param options Custom settings
2919
- */
2920
-
2921
- function format(val, options) {
2922
- if (options) {
2923
- validateOptions(options);
2924
-
2925
- if (options.plugins) {
2926
- const plugin = findPlugin(options.plugins, val);
2927
-
2928
- if (plugin !== null) {
2929
- return printPlugin(plugin, val, getConfig(options), '', 0, []);
2930
- }
2931
- }
2932
- }
2933
-
2934
- const basicResult = printBasicValue(
2935
- val,
2936
- getPrintFunctionName(options),
2937
- getEscapeRegex(options),
2938
- getEscapeString(options)
2939
- );
2940
-
2941
- if (basicResult !== null) {
2942
- return basicResult;
2943
- }
2944
-
2945
- return printComplexValue(val, getConfig(options), '', 0, []);
2946
- }
2947
-
2948
- const plugins = {
2949
- AsymmetricMatcher: _AsymmetricMatcher.default,
2950
- ConvertAnsi: _ConvertAnsi.default,
2951
- DOMCollection: _DOMCollection.default,
2952
- DOMElement: _DOMElement.default,
2953
- Immutable: _Immutable.default,
2954
- ReactElement: _ReactElement.default,
2955
- ReactTestComponent: _ReactTestComponent.default
2956
- };
2957
- plugins_1 = build.plugins = plugins;
2958
- var _default = format;
2959
- build.default = _default;
2960
-
2961
- const {
2962
- DOMCollection: DOMCollection$1,
2963
- DOMElement: DOMElement$1,
2964
- Immutable: Immutable$1,
2965
- ReactElement: ReactElement$1,
2966
- ReactTestComponent: ReactTestComponent$1,
2967
- AsymmetricMatcher: AsymmetricMatcher$2
2968
- } = plugins_1;
2969
- let PLUGINS$1 = [
2970
- ReactTestComponent$1,
2971
- ReactElement$1,
2972
- DOMElement$1,
2973
- DOMCollection$1,
2974
- Immutable$1,
2975
- AsymmetricMatcher$2
2976
- ];
2977
- const addSerializer = (plugin) => {
2978
- PLUGINS$1 = [plugin].concat(PLUGINS$1);
2979
- };
2980
- const getSerializers = () => PLUGINS$1;
2981
-
2982
- var __defProp$4 = Object.defineProperty;
2983
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
2984
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
2985
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
2986
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2987
- var __spreadValues$4 = (a, b) => {
2988
- for (var prop in b || (b = {}))
2989
- if (__hasOwnProp$4.call(b, prop))
2990
- __defNormalProp$4(a, prop, b[prop]);
2991
- if (__getOwnPropSymbols$4)
2992
- for (var prop of __getOwnPropSymbols$4(b)) {
2993
- if (__propIsEnum$4.call(b, prop))
2994
- __defNormalProp$4(a, prop, b[prop]);
2995
- }
2996
- return a;
2997
- };
2998
- const SNAPSHOT_VERSION = "1";
2999
- const writeSnapshotVersion = () => `// Vitest Snapshot v${SNAPSHOT_VERSION}`;
3000
- const testNameToKey = (testName, count) => `${testName} ${count}`;
3001
- const keyToTestName = (key) => {
3002
- if (!/ \d+$/.test(key))
3003
- throw new Error("Snapshot keys must end with a number.");
3004
- return key.replace(/ \d+$/, "");
3005
- };
3006
- const getSnapshotData = (snapshotPath, update) => {
3007
- const data = /* @__PURE__ */ Object.create(null);
3008
- let snapshotContents = "";
3009
- let dirty = false;
3010
- if (fs.existsSync(snapshotPath)) {
3011
- try {
3012
- snapshotContents = fs.readFileSync(snapshotPath, "utf8");
3013
- const populate = new Function("exports", snapshotContents);
3014
- populate(data);
3015
- } catch {
3016
- }
3017
- }
3018
- const isInvalid = snapshotContents;
3019
- if ((update === "all" || update === "new") && isInvalid)
3020
- dirty = true;
3021
- return { data, dirty };
3022
- };
3023
- const addExtraLineBreaks = (string) => string.includes("\n") ? `
3024
- ${string}
3025
- ` : string;
3026
- const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith("\n") && string.endsWith("\n") ? string.slice(1, -1) : string;
3027
- const escapeRegex = true;
3028
- const printFunctionName = false;
3029
- function serialize(val, indent = 2, formatOverrides = {}) {
3030
- return normalizeNewlines(format_1(val, __spreadValues$4({
3031
- escapeRegex,
3032
- indent,
3033
- plugins: getSerializers(),
3034
- printFunctionName
3035
- }, formatOverrides)));
3036
- }
3037
- function escapeBacktickString(str) {
3038
- return str.replace(/`|\\|\${/g, "\\$&");
3039
- }
3040
- function printBacktickString(str) {
3041
- return `\`${escapeBacktickString(str)}\``;
3042
- }
3043
- function ensureDirectoryExists(filePath) {
3044
- try {
3045
- fs.mkdirSync(index$1.join(index$1.dirname(filePath)), { recursive: true });
3046
- } catch {
3047
- }
3048
- }
3049
- function normalizeNewlines(string) {
3050
- return string.replace(/\r\n|\r/g, "\n");
3051
- }
3052
- async function saveSnapshotFile(snapshotData, snapshotPath) {
3053
- const snapshots = Object.keys(snapshotData).sort(naturalCompare$1).map((key) => `exports[${printBacktickString(key)}] = ${printBacktickString(normalizeNewlines(snapshotData[key]))};`);
3054
- ensureDirectoryExists(snapshotPath);
3055
- await promises.writeFile(snapshotPath, `${writeSnapshotVersion()}
3056
-
3057
- ${snapshots.join("\n\n")}
3058
- `, "utf-8");
3059
- }
3060
- function prepareExpected(expected) {
3061
- function findStartIndent() {
3062
- var _a;
3063
- const match = /^( +)}\s+$/m.exec(expected || "");
3064
- return ((_a = match == null ? void 0 : match[1]) == null ? void 0 : _a.length) || 0;
3065
- }
3066
- const startIdent = findStartIndent();
3067
- let expectedTrimmed = expected == null ? void 0 : expected.trim();
3068
- if (startIdent) {
3069
- expectedTrimmed = expectedTrimmed == null ? void 0 : expectedTrimmed.replace(new RegExp(`^${" ".repeat(startIdent)}`, "gm"), "").replace(/ +}$/, "}");
3070
- }
3071
- return expectedTrimmed;
3072
- }
3073
- function deepMergeArray(target = [], source = []) {
3074
- const mergedOutput = Array.from(target);
3075
- source.forEach((sourceElement, index) => {
3076
- const targetElement = mergedOutput[index];
3077
- if (Array.isArray(target[index])) {
3078
- mergedOutput[index] = deepMergeArray(target[index], sourceElement);
3079
- } else if (isObject(targetElement)) {
3080
- mergedOutput[index] = deepMergeSnapshot(target[index], sourceElement);
3081
- } else {
3082
- mergedOutput[index] = sourceElement;
771
+ function deepMergeArray(target = [], source = []) {
772
+ const mergedOutput = Array.from(target);
773
+ source.forEach((sourceElement, index) => {
774
+ const targetElement = mergedOutput[index];
775
+ if (Array.isArray(target[index])) {
776
+ mergedOutput[index] = deepMergeArray(target[index], sourceElement);
777
+ } else if (isObject(targetElement)) {
778
+ mergedOutput[index] = deepMergeSnapshot(target[index], sourceElement);
779
+ } else {
780
+ mergedOutput[index] = sourceElement;
3083
781
  }
3084
782
  });
3085
783
  return mergedOutput;
3086
784
  }
3087
785
  function deepMergeSnapshot(target, source) {
3088
786
  if (isObject(target) && isObject(source)) {
3089
- const mergedOutput = __spreadValues$4({}, target);
787
+ const mergedOutput = __spreadValues$3({}, target);
3090
788
  Object.keys(source).forEach((key) => {
3091
789
  if (isObject(source[key]) && !source[key].$$typeof) {
3092
790
  if (!(key in target))
@@ -3196,19 +894,19 @@ function stripSnapshotIndentation(inlineSnapshot) {
3196
894
  return inlineSnapshot;
3197
895
  }
3198
896
 
3199
- var __defProp$3 = Object.defineProperty;
3200
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
3201
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
3202
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
3203
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3204
- var __spreadValues$3 = (a, b) => {
897
+ var __defProp$2 = Object.defineProperty;
898
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
899
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
900
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
901
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
902
+ var __spreadValues$2 = (a, b) => {
3205
903
  for (var prop in b || (b = {}))
3206
- if (__hasOwnProp$3.call(b, prop))
3207
- __defNormalProp$3(a, prop, b[prop]);
3208
- if (__getOwnPropSymbols$3)
3209
- for (var prop of __getOwnPropSymbols$3(b)) {
3210
- if (__propIsEnum$3.call(b, prop))
3211
- __defNormalProp$3(a, prop, b[prop]);
904
+ if (__hasOwnProp$2.call(b, prop))
905
+ __defNormalProp$2(a, prop, b[prop]);
906
+ if (__getOwnPropSymbols$2)
907
+ for (var prop of __getOwnPropSymbols$2(b)) {
908
+ if (__propIsEnum$2.call(b, prop))
909
+ __defNormalProp$2(a, prop, b[prop]);
3212
910
  }
3213
911
  return a;
3214
912
  };
@@ -3228,7 +926,7 @@ class SnapshotState {
3228
926
  this.unmatched = 0;
3229
927
  this._updateSnapshot = options.updateSnapshot;
3230
928
  this.updated = 0;
3231
- this._snapshotFormat = __spreadValues$3({
929
+ this._snapshotFormat = __spreadValues$2({
3232
930
  printBasicPrototype: false
3233
931
  }, options.snapshotFormat);
3234
932
  }
@@ -3256,7 +954,7 @@ class SnapshotState {
3256
954
  throw new Error(`Vitest: Couldn't infer stack frame for inline snapshot.
3257
955
  ${JSON.stringify(stacks)}`);
3258
956
  }
3259
- this._inlineSnapshots.push(__spreadValues$3({
957
+ this._inlineSnapshots.push(__spreadValues$2({
3260
958
  snapshot: receivedSerialized
3261
959
  }, stack));
3262
960
  } else {
@@ -3512,127 +1210,6 @@ const SnapshotPlugin = (chai, utils) => {
3512
1210
  });
3513
1211
  };
3514
1212
 
3515
- var __defProp$2 = Object.defineProperty;
3516
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
3517
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
3518
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
3519
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3520
- var __spreadValues$2 = (a, b) => {
3521
- for (var prop in b || (b = {}))
3522
- if (__hasOwnProp$2.call(b, prop))
3523
- __defNormalProp$2(a, prop, b[prop]);
3524
- if (__getOwnPropSymbols$2)
3525
- for (var prop of __getOwnPropSymbols$2(b)) {
3526
- if (__propIsEnum$2.call(b, prop))
3527
- __defNormalProp$2(a, prop, b[prop]);
3528
- }
3529
- return a;
3530
- };
3531
- const EXPECTED_COLOR = c$1.green;
3532
- const RECEIVED_COLOR = c$1.red;
3533
- const INVERTED_COLOR = c$1.inverse;
3534
- const BOLD_WEIGHT = c$1.bold;
3535
- const DIM_COLOR = c$1.dim;
3536
- const {
3537
- AsymmetricMatcher: AsymmetricMatcher$1,
3538
- DOMCollection,
3539
- DOMElement,
3540
- Immutable,
3541
- ReactElement,
3542
- ReactTestComponent
3543
- } = plugins_1;
3544
- const PLUGINS = [
3545
- ReactTestComponent,
3546
- ReactElement,
3547
- DOMElement,
3548
- DOMCollection,
3549
- Immutable,
3550
- AsymmetricMatcher$1
3551
- ];
3552
- function matcherHint(matcherName, received = "received", expected = "expected", options = {}) {
3553
- const {
3554
- comment = "",
3555
- expectedColor = EXPECTED_COLOR,
3556
- isDirectExpectCall = false,
3557
- isNot = false,
3558
- promise = "",
3559
- receivedColor = RECEIVED_COLOR,
3560
- secondArgument = "",
3561
- secondArgumentColor = EXPECTED_COLOR
3562
- } = options;
3563
- let hint = "";
3564
- let dimString = "expect";
3565
- if (!isDirectExpectCall && received !== "") {
3566
- hint += DIM_COLOR(`${dimString}(`) + receivedColor(received);
3567
- dimString = ")";
3568
- }
3569
- if (promise !== "") {
3570
- hint += DIM_COLOR(`${dimString}.`) + promise;
3571
- dimString = "";
3572
- }
3573
- if (isNot) {
3574
- hint += `${DIM_COLOR(`${dimString}.`)}not`;
3575
- dimString = "";
3576
- }
3577
- if (matcherName.includes(".")) {
3578
- dimString += matcherName;
3579
- } else {
3580
- hint += DIM_COLOR(`${dimString}.`) + matcherName;
3581
- dimString = "";
3582
- }
3583
- if (expected === "") {
3584
- dimString += "()";
3585
- } else {
3586
- hint += DIM_COLOR(`${dimString}(`) + expectedColor(expected);
3587
- if (secondArgument)
3588
- hint += DIM_COLOR(", ") + secondArgumentColor(secondArgument);
3589
- dimString = ")";
3590
- }
3591
- if (comment !== "")
3592
- dimString += ` // ${comment}`;
3593
- if (dimString !== "")
3594
- hint += DIM_COLOR(dimString);
3595
- return hint;
3596
- }
3597
- const SPACE_SYMBOL = "\xB7";
3598
- const replaceTrailingSpaces = (text) => text.replace(/\s+$/gm, (spaces) => SPACE_SYMBOL.repeat(spaces.length));
3599
- const stringify = (object, maxDepth = 10, options) => {
3600
- const MAX_LENGTH = 1e4;
3601
- let result;
3602
- try {
3603
- result = format_1(object, __spreadValues$2({
3604
- maxDepth,
3605
- plugins: PLUGINS
3606
- }, options));
3607
- } catch {
3608
- result = format_1(object, __spreadValues$2({
3609
- callToJSON: false,
3610
- maxDepth,
3611
- plugins: PLUGINS
3612
- }, options));
3613
- }
3614
- return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(maxDepth / 2)) : result;
3615
- };
3616
- const printReceived = (object) => RECEIVED_COLOR(replaceTrailingSpaces(stringify(object)));
3617
- const printExpected = (value) => EXPECTED_COLOR(replaceTrailingSpaces(stringify(value)));
3618
- function diff(a, b, options) {
3619
- return unifiedDiff(stringify(a), stringify(b));
3620
- }
3621
-
3622
- var matcherUtils = /*#__PURE__*/Object.freeze({
3623
- __proto__: null,
3624
- EXPECTED_COLOR: EXPECTED_COLOR,
3625
- RECEIVED_COLOR: RECEIVED_COLOR,
3626
- INVERTED_COLOR: INVERTED_COLOR,
3627
- BOLD_WEIGHT: BOLD_WEIGHT,
3628
- DIM_COLOR: DIM_COLOR,
3629
- matcherHint: matcherHint,
3630
- stringify: stringify,
3631
- printReceived: printReceived,
3632
- printExpected: printExpected,
3633
- diff: diff
3634
- });
3635
-
3636
1213
  const MATCHERS_OBJECT = Symbol.for("matchers-object");
3637
1214
  if (!Object.prototype.hasOwnProperty.call(global, MATCHERS_OBJECT)) {
3638
1215
  const defaultState = {
@@ -3815,11 +1392,11 @@ const JestChaiExpect = (chai, utils) => {
3815
1392
  return `${i}th`;
3816
1393
  };
3817
1394
  const formatCalls = (spy, msg, actualCall) => {
3818
- msg += c$1.gray(`
1395
+ msg += c.gray(`
3819
1396
 
3820
1397
  Received:
3821
1398
  ${spy.mock.calls.map((callArg, i) => {
3822
- let methodCall = c$1.bold(` ${ordinalOf(i + 1)} ${spy.getMockName()} call:
1399
+ let methodCall = c.bold(` ${ordinalOf(i + 1)} ${spy.getMockName()} call:
3823
1400
 
3824
1401
  `);
3825
1402
  if (actualCall)
@@ -3829,9 +1406,9 @@ ${spy.mock.calls.map((callArg, i) => {
3829
1406
  methodCall += "\n";
3830
1407
  return methodCall;
3831
1408
  }).join("\n")}`);
3832
- msg += c$1.gray(`
1409
+ msg += c.gray(`
3833
1410
 
3834
- Number of calls: ${c$1.bold(spy.mock.calls.length)}
1411
+ Number of calls: ${c.bold(spy.mock.calls.length)}
3835
1412
  `);
3836
1413
  return msg;
3837
1414
  };
@@ -7112,7 +4689,7 @@ function isWatchMode() {
7112
4689
  var index = /*#__PURE__*/Object.freeze({
7113
4690
  __proto__: null,
7114
4691
  suite: suite,
7115
- test: test$7,
4692
+ test: test,
7116
4693
  describe: describe,
7117
4694
  it: it,
7118
4695
  runOnce: runOnce,
@@ -7131,4 +4708,4 @@ var index = /*#__PURE__*/Object.freeze({
7131
4708
  isWatchMode: isWatchMode
7132
4709
  });
7133
4710
 
7134
- export { isWatchMode as A, RealDate as R, setHooks as a, context as b, clearContext as c, defaultSuite as d, getSnapshotClient as e, setState as f, getHooks as g, getFn as h, index as i, getState as j, suite as k, describe as l, it as m, runOnce as n, isFirstRun as o, beforeAll as p, afterAll as q, resetRunOnceCounter as r, stringify as s, test$7 as t, beforeEach as u, vi as v, afterEach as w, expect as x, vitest as y, getRunningMode as z };
4711
+ export { RealDate as R, context as a, getSnapshotClient as b, clearContext as c, defaultSuite as d, setState as e, getFn as f, getHooks as g, getState as h, index as i, suite as j, describe as k, it as l, runOnce as m, isFirstRun as n, beforeAll as o, afterAll as p, beforeEach as q, resetRunOnceCounter as r, setHooks as s, test as t, afterEach as u, vi as v, expect as w, vitest as x, getRunningMode as y, isWatchMode as z };