@vitest/browser 4.1.4 → 5.0.0-beta.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.
- package/context.d.ts +18 -0
- package/dist/client/.vite/manifest.json +15 -6
- package/dist/client/__vitest__/assets/index-BmuVn2L3.js +136 -0
- package/dist/client/__vitest__/assets/index-CxYquQyv.css +1 -0
- package/dist/client/__vitest__/index.html +2 -2
- package/dist/client/__vitest_browser__/{orchestrator-DM4mHHP0.js → orchestrator-pTEf6o0n.js} +25 -29
- package/dist/client/__vitest_browser__/rrweb-snapshot-xhvrgOHx.js +5476 -0
- package/dist/client/__vitest_browser__/{tester-DvOWMUmv.js → tester-CIKiUsoz.js} +164 -14
- package/dist/client/__vitest_browser__/{utils-DmkAiRYk.js → utils-BYUpz6v6.js} +132 -597
- package/dist/client/orchestrator.html +2 -2
- package/dist/client/tester/tester.html +2 -2
- package/dist/client/tester/trace.d.ts +53 -0
- package/dist/client.js +1 -0
- package/dist/context.js +148 -7
- package/dist/expect-element.js +30 -30
- package/dist/index-BlWsE3ij.js +5 -0
- package/dist/index.js +22 -1
- package/dist/locators.js +1 -1
- package/dist/state.js +1 -0
- package/dist/vendor-types.d.ts +131 -0
- package/dist/vendor-types.ts +1 -0
- package/package.json +11 -6
- package/dist/client/__vitest__/assets/index-Da0hb3oU.css +0 -1
- package/dist/client/__vitest__/assets/index-DflzHTY2.js +0 -94
- package/dist/index-D8jtZoIM.js +0 -5
|
@@ -135,7 +135,7 @@ function getKeysOfEnumerableProperties(object, compareKeys) {
|
|
|
135
135
|
}
|
|
136
136
|
return keys;
|
|
137
137
|
}
|
|
138
|
-
function printIteratorEntries(iterator, config, indentation, depth, refs, printer2, separator = ": ") {
|
|
138
|
+
function printIteratorEntries(iterator, config, indentation, depth, refs, printer2, separator = ": ", length) {
|
|
139
139
|
let result = "";
|
|
140
140
|
let width = 0;
|
|
141
141
|
let current = iterator.next();
|
|
@@ -145,7 +145,7 @@ function printIteratorEntries(iterator, config, indentation, depth, refs, printe
|
|
|
145
145
|
while (!current.done) {
|
|
146
146
|
result += indentationNext;
|
|
147
147
|
if (width++ === config.maxWidth) {
|
|
148
|
-
result += "…";
|
|
148
|
+
result += typeof length === "number" ? `…(${length - width + 1})` : "…";
|
|
149
149
|
break;
|
|
150
150
|
}
|
|
151
151
|
const name = printer2(current.value[0], config, indentationNext, depth, refs);
|
|
@@ -162,7 +162,7 @@ function printIteratorEntries(iterator, config, indentation, depth, refs, printe
|
|
|
162
162
|
}
|
|
163
163
|
return result;
|
|
164
164
|
}
|
|
165
|
-
function printIteratorValues(iterator, config, indentation, depth, refs, printer2) {
|
|
165
|
+
function printIteratorValues(iterator, config, indentation, depth, refs, printer2, length) {
|
|
166
166
|
let result = "";
|
|
167
167
|
let width = 0;
|
|
168
168
|
let current = iterator.next();
|
|
@@ -172,7 +172,7 @@ function printIteratorValues(iterator, config, indentation, depth, refs, printer
|
|
|
172
172
|
while (!current.done) {
|
|
173
173
|
result += indentationNext;
|
|
174
174
|
if (width++ === config.maxWidth) {
|
|
175
|
-
result += "…";
|
|
175
|
+
result += typeof length === "number" ? `…(${length - width + 1})` : "…";
|
|
176
176
|
break;
|
|
177
177
|
}
|
|
178
178
|
result += printer2(current.value, config, indentationNext, depth, refs);
|
|
@@ -198,7 +198,7 @@ function printListItems(list, config, indentation, depth, refs, printer2) {
|
|
|
198
198
|
for (let i2 = 0; i2 < length; i2++) {
|
|
199
199
|
result += indentationNext;
|
|
200
200
|
if (i2 === config.maxWidth) {
|
|
201
|
-
result +=
|
|
201
|
+
result += `…(${length - i2})`;
|
|
202
202
|
break;
|
|
203
203
|
}
|
|
204
204
|
if (isDataView(list) || i2 in list) {
|
|
@@ -214,17 +214,22 @@ function printListItems(list, config, indentation, depth, refs, printer2) {
|
|
|
214
214
|
}
|
|
215
215
|
return result;
|
|
216
216
|
}
|
|
217
|
-
function printObjectProperties(val, config, indentation, depth, refs, printer2) {
|
|
217
|
+
function printObjectProperties(val, config, indentation, depth, refs, printer2, compareKeysOverride = config.compareKeys) {
|
|
218
218
|
let result = "";
|
|
219
|
-
const keys = getKeysOfEnumerableProperties(val,
|
|
219
|
+
const keys = getKeysOfEnumerableProperties(val, compareKeysOverride);
|
|
220
220
|
if (keys.length > 0) {
|
|
221
221
|
result += config.spacingOuter;
|
|
222
222
|
const indentationNext = indentation + config.indent;
|
|
223
223
|
for (let i2 = 0; i2 < keys.length; i2++) {
|
|
224
|
+
result += indentationNext;
|
|
225
|
+
if (i2 === config.maxWidth) {
|
|
226
|
+
result += `…(${keys.length - i2})`;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
224
229
|
const key = keys[i2];
|
|
225
|
-
const name = printer2(key, config, indentationNext, depth, refs);
|
|
230
|
+
const name = !config.quoteKeys && isUnquotableKey(key) ? key : printer2(key, config, indentationNext, depth, refs);
|
|
226
231
|
const value = printer2(val[key], config, indentationNext, depth, refs);
|
|
227
|
-
result += `${
|
|
232
|
+
result += `${name}: ${value}`;
|
|
228
233
|
if (i2 < keys.length - 1) {
|
|
229
234
|
result += `,${config.spacingInner}`;
|
|
230
235
|
} else if (!config.min) {
|
|
@@ -235,6 +240,10 @@ function printObjectProperties(val, config, indentation, depth, refs, printer2)
|
|
|
235
240
|
}
|
|
236
241
|
return result;
|
|
237
242
|
}
|
|
243
|
+
const keyStrRegExp = /^[a-z_]\w*$/i;
|
|
244
|
+
function isUnquotableKey(key) {
|
|
245
|
+
return typeof key === "string" && key !== "__proto__" && keyStrRegExp.test(key);
|
|
246
|
+
}
|
|
238
247
|
const asymmetricMatcher = typeof Symbol === "function" && Symbol.for ? Symbol.for("jest.asymmetricMatcher") : 1267621;
|
|
239
248
|
const SPACE$2 = " ";
|
|
240
249
|
const serialize$5 = (val, config, indentation, depth, refs, printer2) => {
|
|
@@ -809,7 +818,7 @@ const plugin = {
|
|
|
809
818
|
serialize,
|
|
810
819
|
test
|
|
811
820
|
};
|
|
812
|
-
const toString
|
|
821
|
+
const toString = Object.prototype.toString;
|
|
813
822
|
const toISOString = Date.prototype.toISOString;
|
|
814
823
|
const errorToString = Error.prototype.toString;
|
|
815
824
|
const regExpToString = RegExp.prototype.toString;
|
|
@@ -849,7 +858,7 @@ function printSymbol(val) {
|
|
|
849
858
|
function printError(val) {
|
|
850
859
|
return `[${errorToString.call(val)}]`;
|
|
851
860
|
}
|
|
852
|
-
function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
|
|
861
|
+
function printBasicValue(val, printFunctionName, escapeRegex, escapeString, singleQuote) {
|
|
853
862
|
if (val === true || val === false) {
|
|
854
863
|
return `${val}`;
|
|
855
864
|
}
|
|
@@ -867,10 +876,12 @@ function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
|
|
|
867
876
|
return printBigInt(val);
|
|
868
877
|
}
|
|
869
878
|
if (typeOf === "string") {
|
|
879
|
+
const q = singleQuote ? "'" : '"';
|
|
870
880
|
if (escapeString) {
|
|
871
|
-
|
|
881
|
+
const escapePattern = singleQuote ? /['\\]/g : /["\\]/g;
|
|
882
|
+
return `${q}${val.replaceAll(escapePattern, "\\$&")}${q}`;
|
|
872
883
|
}
|
|
873
|
-
return
|
|
884
|
+
return `${q}${val}${q}`;
|
|
874
885
|
}
|
|
875
886
|
if (typeOf === "function") {
|
|
876
887
|
return printFunction(val, printFunctionName);
|
|
@@ -878,7 +889,7 @@ function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
|
|
|
878
889
|
if (typeOf === "symbol") {
|
|
879
890
|
return printSymbol(val);
|
|
880
891
|
}
|
|
881
|
-
const toStringed = toString
|
|
892
|
+
const toStringed = toString.call(val);
|
|
882
893
|
if (toStringed === "[object WeakMap]") {
|
|
883
894
|
return "WeakMap {}";
|
|
884
895
|
}
|
|
@@ -919,20 +930,20 @@ function printComplexValue(val, config, indentation, depth, refs, hasCalledToJSO
|
|
|
919
930
|
if (config.callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === "function" && !hasCalledToJSON) {
|
|
920
931
|
return printer(val.toJSON(), config, indentation, depth, refs, true);
|
|
921
932
|
}
|
|
922
|
-
const toStringed = toString
|
|
933
|
+
const toStringed = toString.call(val);
|
|
923
934
|
if (toStringed === "[object Arguments]") {
|
|
924
935
|
return hitMaxDepth ? "[Arguments]" : `${min ? "" : "Arguments "}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
|
|
925
936
|
}
|
|
926
937
|
if (isToStringedArrayType(toStringed)) {
|
|
927
|
-
return hitMaxDepth ? `[${val.constructor.name}]` : `${
|
|
938
|
+
return hitMaxDepth ? `[${val.constructor.name}]` : `${!config.printBasicPrototype && val.constructor.name === "Array" ? "" : `${val.constructor.name} `}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
|
|
928
939
|
}
|
|
929
940
|
if (toStringed === "[object Map]") {
|
|
930
|
-
return hitMaxDepth ? "[Map]" : `Map {${printIteratorEntries(val.entries(), config, indentation, depth, refs, printer, " => ")}}`;
|
|
941
|
+
return hitMaxDepth ? "[Map]" : `Map {${printIteratorEntries(val.entries(), config, indentation, depth, refs, printer, " => ", val.size)}}`;
|
|
931
942
|
}
|
|
932
943
|
if (toStringed === "[object Set]") {
|
|
933
|
-
return hitMaxDepth ? "[Set]" : `Set {${printIteratorValues(val.values(), config, indentation, depth, refs, printer)}}`;
|
|
944
|
+
return hitMaxDepth ? "[Set]" : `Set {${printIteratorValues(val.values(), config, indentation, depth, refs, printer, val.size)}}`;
|
|
934
945
|
}
|
|
935
|
-
return hitMaxDepth || isWindow(val) ? `[${getConstructorName(val)}]` : `${
|
|
946
|
+
return hitMaxDepth || isWindow(val) ? `[${getConstructorName(val)}]` : `${!config.printBasicPrototype && getConstructorName(val) === "Object" ? "" : `${getConstructorName(val)} `}{${printObjectProperties(val, config, indentation, depth, refs, printer)}}`;
|
|
936
947
|
}
|
|
937
948
|
function isNewPlugin(plugin2) {
|
|
938
949
|
return plugin2.serialize != null;
|
|
@@ -976,7 +987,7 @@ function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
|
|
|
976
987
|
if (plugin2 !== null) {
|
|
977
988
|
result = printPlugin(plugin2, val, config, indentation, depth, refs);
|
|
978
989
|
} else {
|
|
979
|
-
const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString);
|
|
990
|
+
const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString, config.singleQuote);
|
|
980
991
|
if (basicResult !== null) {
|
|
981
992
|
result = basicResult;
|
|
982
993
|
} else {
|
|
@@ -1013,7 +1024,11 @@ const DEFAULT_OPTIONS = {
|
|
|
1013
1024
|
printBasicPrototype: true,
|
|
1014
1025
|
printFunctionName: true,
|
|
1015
1026
|
printShadowRoot: true,
|
|
1016
|
-
theme: DEFAULT_THEME
|
|
1027
|
+
theme: DEFAULT_THEME,
|
|
1028
|
+
singleQuote: false,
|
|
1029
|
+
quoteKeys: true,
|
|
1030
|
+
spacingInner: "\n",
|
|
1031
|
+
spacingOuter: "\n"
|
|
1017
1032
|
};
|
|
1018
1033
|
function validateOptions(options) {
|
|
1019
1034
|
for (const key of Object.keys(options)) {
|
|
@@ -1067,11 +1082,13 @@ function getConfig$1(options) {
|
|
|
1067
1082
|
maxWidth: (options == null ? void 0 : options.maxWidth) ?? DEFAULT_OPTIONS.maxWidth,
|
|
1068
1083
|
min: (options == null ? void 0 : options.min) ?? DEFAULT_OPTIONS.min,
|
|
1069
1084
|
plugins: (options == null ? void 0 : options.plugins) ?? DEFAULT_OPTIONS.plugins,
|
|
1070
|
-
printBasicPrototype: (options == null ? void 0 : options.printBasicPrototype) ??
|
|
1085
|
+
printBasicPrototype: (options == null ? void 0 : options.printBasicPrototype) ?? !(options == null ? void 0 : options.min),
|
|
1071
1086
|
printFunctionName: getPrintFunctionName(options),
|
|
1072
1087
|
printShadowRoot: (options == null ? void 0 : options.printShadowRoot) ?? true,
|
|
1073
|
-
spacingInner: (options == null ? void 0 : options.min) ? " " : "\n",
|
|
1074
|
-
spacingOuter: (options == null ? void 0 : options.min) ? "" : "\n",
|
|
1088
|
+
spacingInner: (options == null ? void 0 : options.spacingInner) ?? ((options == null ? void 0 : options.min) ? " " : "\n"),
|
|
1089
|
+
spacingOuter: (options == null ? void 0 : options.spacingOuter) ?? ((options == null ? void 0 : options.min) ? "" : "\n"),
|
|
1090
|
+
singleQuote: (options == null ? void 0 : options.singleQuote) ?? DEFAULT_OPTIONS.singleQuote,
|
|
1091
|
+
quoteKeys: (options == null ? void 0 : options.quoteKeys) ?? DEFAULT_OPTIONS.quoteKeys,
|
|
1075
1092
|
maxOutputLength: (options == null ? void 0 : options.maxOutputLength) ?? DEFAULT_OPTIONS.maxOutputLength,
|
|
1076
1093
|
_outputLengthPerDepth: []
|
|
1077
1094
|
};
|
|
@@ -1082,18 +1099,17 @@ function createIndent(indent) {
|
|
|
1082
1099
|
function format$1(val, options) {
|
|
1083
1100
|
if (options) {
|
|
1084
1101
|
validateOptions(options);
|
|
1085
|
-
if (options.plugins) {
|
|
1086
|
-
const plugin2 = findPlugin(options.plugins, val);
|
|
1087
|
-
if (plugin2 !== null) {
|
|
1088
|
-
return printPlugin(plugin2, val, getConfig$1(options), "", 0, []);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
1102
|
}
|
|
1092
|
-
const
|
|
1103
|
+
const config = getConfig$1(options);
|
|
1104
|
+
const plugin2 = findPlugin(config.plugins, val);
|
|
1105
|
+
if (plugin2 !== null) {
|
|
1106
|
+
return printPlugin(plugin2, val, config, "", 0, []);
|
|
1107
|
+
}
|
|
1108
|
+
const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString, config.singleQuote);
|
|
1093
1109
|
if (basicResult !== null) {
|
|
1094
1110
|
return basicResult;
|
|
1095
1111
|
}
|
|
1096
|
-
return printComplexValue(val,
|
|
1112
|
+
return printComplexValue(val, config, "", 0, []);
|
|
1097
1113
|
}
|
|
1098
1114
|
const plugins = {
|
|
1099
1115
|
AsymmetricMatcher: plugin$5,
|
|
@@ -1103,523 +1119,6 @@ const plugins = {
|
|
|
1103
1119
|
ReactElement: plugin$1,
|
|
1104
1120
|
ReactTestComponent: plugin
|
|
1105
1121
|
};
|
|
1106
|
-
const ansiColors = {
|
|
1107
|
-
bold: ["1", "22"],
|
|
1108
|
-
dim: ["2", "22"],
|
|
1109
|
-
italic: ["3", "23"],
|
|
1110
|
-
underline: ["4", "24"],
|
|
1111
|
-
// 5 & 6 are blinking
|
|
1112
|
-
inverse: ["7", "27"],
|
|
1113
|
-
hidden: ["8", "28"],
|
|
1114
|
-
strike: ["9", "29"],
|
|
1115
|
-
// 10-20 are fonts
|
|
1116
|
-
// 21-29 are resets for 1-9
|
|
1117
|
-
black: ["30", "39"],
|
|
1118
|
-
red: ["31", "39"],
|
|
1119
|
-
green: ["32", "39"],
|
|
1120
|
-
yellow: ["33", "39"],
|
|
1121
|
-
blue: ["34", "39"],
|
|
1122
|
-
magenta: ["35", "39"],
|
|
1123
|
-
cyan: ["36", "39"],
|
|
1124
|
-
white: ["37", "39"],
|
|
1125
|
-
brightblack: ["30;1", "39"],
|
|
1126
|
-
brightred: ["31;1", "39"],
|
|
1127
|
-
brightgreen: ["32;1", "39"],
|
|
1128
|
-
brightyellow: ["33;1", "39"],
|
|
1129
|
-
brightblue: ["34;1", "39"],
|
|
1130
|
-
brightmagenta: ["35;1", "39"],
|
|
1131
|
-
brightcyan: ["36;1", "39"],
|
|
1132
|
-
brightwhite: ["37;1", "39"],
|
|
1133
|
-
grey: ["90", "39"]
|
|
1134
|
-
};
|
|
1135
|
-
const styles = {
|
|
1136
|
-
special: "cyan",
|
|
1137
|
-
number: "yellow",
|
|
1138
|
-
bigint: "yellow",
|
|
1139
|
-
boolean: "yellow",
|
|
1140
|
-
undefined: "grey",
|
|
1141
|
-
null: "bold",
|
|
1142
|
-
string: "green",
|
|
1143
|
-
symbol: "green",
|
|
1144
|
-
date: "magenta",
|
|
1145
|
-
regexp: "red"
|
|
1146
|
-
};
|
|
1147
|
-
const truncator = "…";
|
|
1148
|
-
function colorise(value, styleType) {
|
|
1149
|
-
const color = ansiColors[styles[styleType]] || ansiColors[styleType] || "";
|
|
1150
|
-
if (!color) {
|
|
1151
|
-
return String(value);
|
|
1152
|
-
}
|
|
1153
|
-
return `\x1B[${color[0]}m${String(value)}\x1B[${color[1]}m`;
|
|
1154
|
-
}
|
|
1155
|
-
function normaliseOptions({
|
|
1156
|
-
showHidden = false,
|
|
1157
|
-
depth = 2,
|
|
1158
|
-
colors = false,
|
|
1159
|
-
customInspect = true,
|
|
1160
|
-
showProxy = false,
|
|
1161
|
-
maxArrayLength = Infinity,
|
|
1162
|
-
breakLength = Infinity,
|
|
1163
|
-
seen = [],
|
|
1164
|
-
// eslint-disable-next-line no-shadow
|
|
1165
|
-
truncate: truncate2 = Infinity,
|
|
1166
|
-
stylize = String
|
|
1167
|
-
} = {}, inspect2) {
|
|
1168
|
-
const options = {
|
|
1169
|
-
showHidden: Boolean(showHidden),
|
|
1170
|
-
depth: Number(depth),
|
|
1171
|
-
colors: Boolean(colors),
|
|
1172
|
-
customInspect: Boolean(customInspect),
|
|
1173
|
-
showProxy: Boolean(showProxy),
|
|
1174
|
-
maxArrayLength: Number(maxArrayLength),
|
|
1175
|
-
breakLength: Number(breakLength),
|
|
1176
|
-
truncate: Number(truncate2),
|
|
1177
|
-
seen,
|
|
1178
|
-
inspect: inspect2,
|
|
1179
|
-
stylize
|
|
1180
|
-
};
|
|
1181
|
-
if (options.colors) {
|
|
1182
|
-
options.stylize = colorise;
|
|
1183
|
-
}
|
|
1184
|
-
return options;
|
|
1185
|
-
}
|
|
1186
|
-
function isHighSurrogate(char) {
|
|
1187
|
-
return char >= "\uD800" && char <= "\uDBFF";
|
|
1188
|
-
}
|
|
1189
|
-
function truncate(string, length, tail = truncator) {
|
|
1190
|
-
string = String(string);
|
|
1191
|
-
const tailLength = tail.length;
|
|
1192
|
-
const stringLength = string.length;
|
|
1193
|
-
if (tailLength > length && stringLength > tailLength) {
|
|
1194
|
-
return tail;
|
|
1195
|
-
}
|
|
1196
|
-
if (stringLength > length && stringLength > tailLength) {
|
|
1197
|
-
let end = length - tailLength;
|
|
1198
|
-
if (end > 0 && isHighSurrogate(string[end - 1])) {
|
|
1199
|
-
end = end - 1;
|
|
1200
|
-
}
|
|
1201
|
-
return `${string.slice(0, end)}${tail}`;
|
|
1202
|
-
}
|
|
1203
|
-
return string;
|
|
1204
|
-
}
|
|
1205
|
-
function inspectList(list, options, inspectItem, separator = ", ") {
|
|
1206
|
-
inspectItem = inspectItem || options.inspect;
|
|
1207
|
-
const size = list.length;
|
|
1208
|
-
if (size === 0)
|
|
1209
|
-
return "";
|
|
1210
|
-
const originalLength = options.truncate;
|
|
1211
|
-
let output = "";
|
|
1212
|
-
let peek = "";
|
|
1213
|
-
let truncated = "";
|
|
1214
|
-
for (let i2 = 0; i2 < size; i2 += 1) {
|
|
1215
|
-
const last = i2 + 1 === list.length;
|
|
1216
|
-
const secondToLast = i2 + 2 === list.length;
|
|
1217
|
-
truncated = `${truncator}(${list.length - i2})`;
|
|
1218
|
-
const value = list[i2];
|
|
1219
|
-
options.truncate = originalLength - output.length - (last ? 0 : separator.length);
|
|
1220
|
-
const string = peek || inspectItem(value, options) + (last ? "" : separator);
|
|
1221
|
-
const nextLength = output.length + string.length;
|
|
1222
|
-
const truncatedLength = nextLength + truncated.length;
|
|
1223
|
-
if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) {
|
|
1224
|
-
break;
|
|
1225
|
-
}
|
|
1226
|
-
if (!last && !secondToLast && truncatedLength > originalLength) {
|
|
1227
|
-
break;
|
|
1228
|
-
}
|
|
1229
|
-
peek = last ? "" : inspectItem(list[i2 + 1], options) + (secondToLast ? "" : separator);
|
|
1230
|
-
if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) {
|
|
1231
|
-
break;
|
|
1232
|
-
}
|
|
1233
|
-
output += string;
|
|
1234
|
-
if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
|
|
1235
|
-
truncated = `${truncator}(${list.length - i2 - 1})`;
|
|
1236
|
-
break;
|
|
1237
|
-
}
|
|
1238
|
-
truncated = "";
|
|
1239
|
-
}
|
|
1240
|
-
return `${output}${truncated}`;
|
|
1241
|
-
}
|
|
1242
|
-
function quoteComplexKey(key) {
|
|
1243
|
-
if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) {
|
|
1244
|
-
return key;
|
|
1245
|
-
}
|
|
1246
|
-
return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
|
|
1247
|
-
}
|
|
1248
|
-
function inspectProperty([key, value], options) {
|
|
1249
|
-
options.truncate -= 2;
|
|
1250
|
-
if (typeof key === "string") {
|
|
1251
|
-
key = quoteComplexKey(key);
|
|
1252
|
-
} else if (typeof key !== "number") {
|
|
1253
|
-
key = `[${options.inspect(key, options)}]`;
|
|
1254
|
-
}
|
|
1255
|
-
options.truncate -= key.length;
|
|
1256
|
-
value = options.inspect(value, options);
|
|
1257
|
-
return `${key}: ${value}`;
|
|
1258
|
-
}
|
|
1259
|
-
function inspectArray(array, options) {
|
|
1260
|
-
const nonIndexProperties = Object.keys(array).slice(array.length);
|
|
1261
|
-
if (!array.length && !nonIndexProperties.length)
|
|
1262
|
-
return "[]";
|
|
1263
|
-
options.truncate -= 4;
|
|
1264
|
-
const listContents = inspectList(array, options);
|
|
1265
|
-
options.truncate -= listContents.length;
|
|
1266
|
-
let propertyContents = "";
|
|
1267
|
-
if (nonIndexProperties.length) {
|
|
1268
|
-
propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
|
|
1269
|
-
}
|
|
1270
|
-
return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ""} ]`;
|
|
1271
|
-
}
|
|
1272
|
-
const getArrayName = (array) => {
|
|
1273
|
-
if (typeof Buffer === "function" && array instanceof Buffer) {
|
|
1274
|
-
return "Buffer";
|
|
1275
|
-
}
|
|
1276
|
-
if (array[Symbol.toStringTag]) {
|
|
1277
|
-
return array[Symbol.toStringTag];
|
|
1278
|
-
}
|
|
1279
|
-
return array.constructor.name;
|
|
1280
|
-
};
|
|
1281
|
-
function inspectTypedArray(array, options) {
|
|
1282
|
-
const name = getArrayName(array);
|
|
1283
|
-
options.truncate -= name.length + 4;
|
|
1284
|
-
const nonIndexProperties = Object.keys(array).slice(array.length);
|
|
1285
|
-
if (!array.length && !nonIndexProperties.length)
|
|
1286
|
-
return `${name}[]`;
|
|
1287
|
-
let output = "";
|
|
1288
|
-
for (let i2 = 0; i2 < array.length; i2++) {
|
|
1289
|
-
const string = `${options.stylize(truncate(array[i2], options.truncate), "number")}${i2 === array.length - 1 ? "" : ", "}`;
|
|
1290
|
-
options.truncate -= string.length;
|
|
1291
|
-
if (array[i2] !== array.length && options.truncate <= 3) {
|
|
1292
|
-
output += `${truncator}(${array.length - array[i2] + 1})`;
|
|
1293
|
-
break;
|
|
1294
|
-
}
|
|
1295
|
-
output += string;
|
|
1296
|
-
}
|
|
1297
|
-
let propertyContents = "";
|
|
1298
|
-
if (nonIndexProperties.length) {
|
|
1299
|
-
propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
|
|
1300
|
-
}
|
|
1301
|
-
return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ""} ]`;
|
|
1302
|
-
}
|
|
1303
|
-
function inspectDate(dateObject, options) {
|
|
1304
|
-
const stringRepresentation = dateObject.toJSON();
|
|
1305
|
-
if (stringRepresentation === null) {
|
|
1306
|
-
return "Invalid Date";
|
|
1307
|
-
}
|
|
1308
|
-
const split = stringRepresentation.split("T");
|
|
1309
|
-
const date = split[0];
|
|
1310
|
-
return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, "date");
|
|
1311
|
-
}
|
|
1312
|
-
function inspectFunction(func, options) {
|
|
1313
|
-
const functionType = func[Symbol.toStringTag] || "Function";
|
|
1314
|
-
const name = func.name;
|
|
1315
|
-
if (!name) {
|
|
1316
|
-
return options.stylize(`[${functionType}]`, "special");
|
|
1317
|
-
}
|
|
1318
|
-
return options.stylize(`[${functionType} ${truncate(name, options.truncate - 11)}]`, "special");
|
|
1319
|
-
}
|
|
1320
|
-
function inspectMapEntry([key, value], options) {
|
|
1321
|
-
options.truncate -= 4;
|
|
1322
|
-
key = options.inspect(key, options);
|
|
1323
|
-
options.truncate -= key.length;
|
|
1324
|
-
value = options.inspect(value, options);
|
|
1325
|
-
return `${key} => ${value}`;
|
|
1326
|
-
}
|
|
1327
|
-
function mapToEntries(map) {
|
|
1328
|
-
const entries = [];
|
|
1329
|
-
map.forEach((value, key) => {
|
|
1330
|
-
entries.push([key, value]);
|
|
1331
|
-
});
|
|
1332
|
-
return entries;
|
|
1333
|
-
}
|
|
1334
|
-
function inspectMap(map, options) {
|
|
1335
|
-
if (map.size === 0)
|
|
1336
|
-
return "Map{}";
|
|
1337
|
-
options.truncate -= 7;
|
|
1338
|
-
return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`;
|
|
1339
|
-
}
|
|
1340
|
-
const isNaN = Number.isNaN || ((i2) => i2 !== i2);
|
|
1341
|
-
function inspectNumber(number, options) {
|
|
1342
|
-
if (isNaN(number)) {
|
|
1343
|
-
return options.stylize("NaN", "number");
|
|
1344
|
-
}
|
|
1345
|
-
if (number === Infinity) {
|
|
1346
|
-
return options.stylize("Infinity", "number");
|
|
1347
|
-
}
|
|
1348
|
-
if (number === -Infinity) {
|
|
1349
|
-
return options.stylize("-Infinity", "number");
|
|
1350
|
-
}
|
|
1351
|
-
if (number === 0) {
|
|
1352
|
-
return options.stylize(1 / number === Infinity ? "+0" : "-0", "number");
|
|
1353
|
-
}
|
|
1354
|
-
return options.stylize(truncate(String(number), options.truncate), "number");
|
|
1355
|
-
}
|
|
1356
|
-
function inspectBigInt(number, options) {
|
|
1357
|
-
let nums = truncate(number.toString(), options.truncate - 1);
|
|
1358
|
-
if (nums !== truncator)
|
|
1359
|
-
nums += "n";
|
|
1360
|
-
return options.stylize(nums, "bigint");
|
|
1361
|
-
}
|
|
1362
|
-
function inspectRegExp(value, options) {
|
|
1363
|
-
const flags = value.toString().split("/")[2];
|
|
1364
|
-
const sourceLength = options.truncate - (2 + flags.length);
|
|
1365
|
-
const source = value.source;
|
|
1366
|
-
return options.stylize(`/${truncate(source, sourceLength)}/${flags}`, "regexp");
|
|
1367
|
-
}
|
|
1368
|
-
function arrayFromSet(set) {
|
|
1369
|
-
const values = [];
|
|
1370
|
-
set.forEach((value) => {
|
|
1371
|
-
values.push(value);
|
|
1372
|
-
});
|
|
1373
|
-
return values;
|
|
1374
|
-
}
|
|
1375
|
-
function inspectSet(set, options) {
|
|
1376
|
-
if (set.size === 0)
|
|
1377
|
-
return "Set{}";
|
|
1378
|
-
options.truncate -= 7;
|
|
1379
|
-
return `Set{ ${inspectList(arrayFromSet(set), options)} }`;
|
|
1380
|
-
}
|
|
1381
|
-
const stringEscapeChars = new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", "g");
|
|
1382
|
-
const escapeCharacters = {
|
|
1383
|
-
"\b": "\\b",
|
|
1384
|
-
" ": "\\t",
|
|
1385
|
-
"\n": "\\n",
|
|
1386
|
-
"\f": "\\f",
|
|
1387
|
-
"\r": "\\r",
|
|
1388
|
-
"'": "\\'",
|
|
1389
|
-
"\\": "\\\\"
|
|
1390
|
-
};
|
|
1391
|
-
const hex = 16;
|
|
1392
|
-
function escape(char) {
|
|
1393
|
-
return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-4)}`;
|
|
1394
|
-
}
|
|
1395
|
-
function inspectString(string, options) {
|
|
1396
|
-
if (stringEscapeChars.test(string)) {
|
|
1397
|
-
string = string.replace(stringEscapeChars, escape);
|
|
1398
|
-
}
|
|
1399
|
-
return options.stylize(`'${truncate(string, options.truncate - 2)}'`, "string");
|
|
1400
|
-
}
|
|
1401
|
-
function inspectSymbol(value) {
|
|
1402
|
-
if ("description" in Symbol.prototype) {
|
|
1403
|
-
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
1404
|
-
}
|
|
1405
|
-
return value.toString();
|
|
1406
|
-
}
|
|
1407
|
-
const getPromiseValue = () => "Promise{…}";
|
|
1408
|
-
function inspectObject$1(object, options) {
|
|
1409
|
-
const properties = Object.getOwnPropertyNames(object);
|
|
1410
|
-
const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
|
|
1411
|
-
if (properties.length === 0 && symbols.length === 0) {
|
|
1412
|
-
return "{}";
|
|
1413
|
-
}
|
|
1414
|
-
options.truncate -= 4;
|
|
1415
|
-
options.seen = options.seen || [];
|
|
1416
|
-
if (options.seen.includes(object)) {
|
|
1417
|
-
return "[Circular]";
|
|
1418
|
-
}
|
|
1419
|
-
options.seen.push(object);
|
|
1420
|
-
const propertyContents = inspectList(properties.map((key) => [key, object[key]]), options, inspectProperty);
|
|
1421
|
-
const symbolContents = inspectList(symbols.map((key) => [key, object[key]]), options, inspectProperty);
|
|
1422
|
-
options.seen.pop();
|
|
1423
|
-
let sep = "";
|
|
1424
|
-
if (propertyContents && symbolContents) {
|
|
1425
|
-
sep = ", ";
|
|
1426
|
-
}
|
|
1427
|
-
return `{ ${propertyContents}${sep}${symbolContents} }`;
|
|
1428
|
-
}
|
|
1429
|
-
const toStringTag = typeof Symbol !== "undefined" && Symbol.toStringTag ? Symbol.toStringTag : false;
|
|
1430
|
-
function inspectClass(value, options) {
|
|
1431
|
-
let name = "";
|
|
1432
|
-
if (toStringTag && toStringTag in value) {
|
|
1433
|
-
name = value[toStringTag];
|
|
1434
|
-
}
|
|
1435
|
-
name = name || value.constructor.name;
|
|
1436
|
-
if (!name || name === "_class") {
|
|
1437
|
-
name = "<Anonymous Class>";
|
|
1438
|
-
}
|
|
1439
|
-
options.truncate -= name.length;
|
|
1440
|
-
return `${name}${inspectObject$1(value, options)}`;
|
|
1441
|
-
}
|
|
1442
|
-
function inspectArguments(args, options) {
|
|
1443
|
-
if (args.length === 0)
|
|
1444
|
-
return "Arguments[]";
|
|
1445
|
-
options.truncate -= 13;
|
|
1446
|
-
return `Arguments[ ${inspectList(args, options)} ]`;
|
|
1447
|
-
}
|
|
1448
|
-
const errorKeys = [
|
|
1449
|
-
"stack",
|
|
1450
|
-
"line",
|
|
1451
|
-
"column",
|
|
1452
|
-
"name",
|
|
1453
|
-
"message",
|
|
1454
|
-
"fileName",
|
|
1455
|
-
"lineNumber",
|
|
1456
|
-
"columnNumber",
|
|
1457
|
-
"number",
|
|
1458
|
-
"description",
|
|
1459
|
-
"cause"
|
|
1460
|
-
];
|
|
1461
|
-
function inspectObject(error, options) {
|
|
1462
|
-
const properties = Object.getOwnPropertyNames(error).filter((key) => errorKeys.indexOf(key) === -1);
|
|
1463
|
-
const name = error.name;
|
|
1464
|
-
options.truncate -= name.length;
|
|
1465
|
-
let message = "";
|
|
1466
|
-
if (typeof error.message === "string") {
|
|
1467
|
-
message = truncate(error.message, options.truncate);
|
|
1468
|
-
} else {
|
|
1469
|
-
properties.unshift("message");
|
|
1470
|
-
}
|
|
1471
|
-
message = message ? `: ${message}` : "";
|
|
1472
|
-
options.truncate -= message.length + 5;
|
|
1473
|
-
options.seen = options.seen || [];
|
|
1474
|
-
if (options.seen.includes(error)) {
|
|
1475
|
-
return "[Circular]";
|
|
1476
|
-
}
|
|
1477
|
-
options.seen.push(error);
|
|
1478
|
-
const propertyContents = inspectList(properties.map((key) => [key, error[key]]), options, inspectProperty);
|
|
1479
|
-
return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ""}`;
|
|
1480
|
-
}
|
|
1481
|
-
function inspectAttribute([key, value], options) {
|
|
1482
|
-
options.truncate -= 3;
|
|
1483
|
-
if (!value) {
|
|
1484
|
-
return `${options.stylize(String(key), "yellow")}`;
|
|
1485
|
-
}
|
|
1486
|
-
return `${options.stylize(String(key), "yellow")}=${options.stylize(`"${value}"`, "string")}`;
|
|
1487
|
-
}
|
|
1488
|
-
function inspectNodeCollection(collection, options) {
|
|
1489
|
-
return inspectList(collection, options, inspectNode, "\n");
|
|
1490
|
-
}
|
|
1491
|
-
function inspectNode(node, options) {
|
|
1492
|
-
switch (node.nodeType) {
|
|
1493
|
-
case 1:
|
|
1494
|
-
return inspectHTML(node, options);
|
|
1495
|
-
case 3:
|
|
1496
|
-
return options.inspect(node.data, options);
|
|
1497
|
-
default:
|
|
1498
|
-
return options.inspect(node, options);
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
function inspectHTML(element, options) {
|
|
1502
|
-
const properties = element.getAttributeNames();
|
|
1503
|
-
const name = element.tagName.toLowerCase();
|
|
1504
|
-
const head = options.stylize(`<${name}`, "special");
|
|
1505
|
-
const headClose = options.stylize(`>`, "special");
|
|
1506
|
-
const tail = options.stylize(`</${name}>`, "special");
|
|
1507
|
-
options.truncate -= name.length * 2 + 5;
|
|
1508
|
-
let propertyContents = "";
|
|
1509
|
-
if (properties.length > 0) {
|
|
1510
|
-
propertyContents += " ";
|
|
1511
|
-
propertyContents += inspectList(properties.map((key) => [key, element.getAttribute(key)]), options, inspectAttribute, " ");
|
|
1512
|
-
}
|
|
1513
|
-
options.truncate -= propertyContents.length;
|
|
1514
|
-
const truncate2 = options.truncate;
|
|
1515
|
-
let children = inspectNodeCollection(element.children, options);
|
|
1516
|
-
if (children && children.length > truncate2) {
|
|
1517
|
-
children = `${truncator}(${element.children.length})`;
|
|
1518
|
-
}
|
|
1519
|
-
return `${head}${propertyContents}${headClose}${children}${tail}`;
|
|
1520
|
-
}
|
|
1521
|
-
const symbolsSupported = typeof Symbol === "function" && typeof Symbol.for === "function";
|
|
1522
|
-
const chaiInspect = symbolsSupported ? Symbol.for("chai/inspect") : "@@chai/inspect";
|
|
1523
|
-
const nodeInspect = Symbol.for("nodejs.util.inspect.custom");
|
|
1524
|
-
const constructorMap = /* @__PURE__ */ new WeakMap();
|
|
1525
|
-
const stringTagMap = {};
|
|
1526
|
-
const baseTypesMap = {
|
|
1527
|
-
undefined: (value, options) => options.stylize("undefined", "undefined"),
|
|
1528
|
-
null: (value, options) => options.stylize("null", "null"),
|
|
1529
|
-
boolean: (value, options) => options.stylize(String(value), "boolean"),
|
|
1530
|
-
Boolean: (value, options) => options.stylize(String(value), "boolean"),
|
|
1531
|
-
number: inspectNumber,
|
|
1532
|
-
Number: inspectNumber,
|
|
1533
|
-
bigint: inspectBigInt,
|
|
1534
|
-
BigInt: inspectBigInt,
|
|
1535
|
-
string: inspectString,
|
|
1536
|
-
String: inspectString,
|
|
1537
|
-
function: inspectFunction,
|
|
1538
|
-
Function: inspectFunction,
|
|
1539
|
-
symbol: inspectSymbol,
|
|
1540
|
-
// A Symbol polyfill will return `Symbol` not `symbol` from typedetect
|
|
1541
|
-
Symbol: inspectSymbol,
|
|
1542
|
-
Array: inspectArray,
|
|
1543
|
-
Date: inspectDate,
|
|
1544
|
-
Map: inspectMap,
|
|
1545
|
-
Set: inspectSet,
|
|
1546
|
-
RegExp: inspectRegExp,
|
|
1547
|
-
Promise: getPromiseValue,
|
|
1548
|
-
// WeakSet, WeakMap are totally opaque to us
|
|
1549
|
-
WeakSet: (value, options) => options.stylize("WeakSet{…}", "special"),
|
|
1550
|
-
WeakMap: (value, options) => options.stylize("WeakMap{…}", "special"),
|
|
1551
|
-
Arguments: inspectArguments,
|
|
1552
|
-
Int8Array: inspectTypedArray,
|
|
1553
|
-
Uint8Array: inspectTypedArray,
|
|
1554
|
-
Uint8ClampedArray: inspectTypedArray,
|
|
1555
|
-
Int16Array: inspectTypedArray,
|
|
1556
|
-
Uint16Array: inspectTypedArray,
|
|
1557
|
-
Int32Array: inspectTypedArray,
|
|
1558
|
-
Uint32Array: inspectTypedArray,
|
|
1559
|
-
Float32Array: inspectTypedArray,
|
|
1560
|
-
Float64Array: inspectTypedArray,
|
|
1561
|
-
Generator: () => "",
|
|
1562
|
-
DataView: () => "",
|
|
1563
|
-
ArrayBuffer: () => "",
|
|
1564
|
-
Error: inspectObject,
|
|
1565
|
-
HTMLCollection: inspectNodeCollection,
|
|
1566
|
-
NodeList: inspectNodeCollection
|
|
1567
|
-
};
|
|
1568
|
-
const inspectCustom = (value, options, type, inspectFn) => {
|
|
1569
|
-
if (chaiInspect in value && typeof value[chaiInspect] === "function") {
|
|
1570
|
-
return value[chaiInspect](options);
|
|
1571
|
-
}
|
|
1572
|
-
if (nodeInspect in value && typeof value[nodeInspect] === "function") {
|
|
1573
|
-
return value[nodeInspect](options.depth, options, inspectFn);
|
|
1574
|
-
}
|
|
1575
|
-
if ("inspect" in value && typeof value.inspect === "function") {
|
|
1576
|
-
return value.inspect(options.depth, options);
|
|
1577
|
-
}
|
|
1578
|
-
if ("constructor" in value && constructorMap.has(value.constructor)) {
|
|
1579
|
-
return constructorMap.get(value.constructor)(value, options);
|
|
1580
|
-
}
|
|
1581
|
-
if (stringTagMap[type]) {
|
|
1582
|
-
return stringTagMap[type](value, options);
|
|
1583
|
-
}
|
|
1584
|
-
return "";
|
|
1585
|
-
};
|
|
1586
|
-
const toString = Object.prototype.toString;
|
|
1587
|
-
function inspect$1(value, opts = {}) {
|
|
1588
|
-
const options = normaliseOptions(opts, inspect$1);
|
|
1589
|
-
const { customInspect } = options;
|
|
1590
|
-
let type = value === null ? "null" : typeof value;
|
|
1591
|
-
if (type === "object") {
|
|
1592
|
-
type = toString.call(value).slice(8, -1);
|
|
1593
|
-
}
|
|
1594
|
-
if (type in baseTypesMap) {
|
|
1595
|
-
return baseTypesMap[type](value, options);
|
|
1596
|
-
}
|
|
1597
|
-
if (customInspect && value) {
|
|
1598
|
-
const output = inspectCustom(value, options, type, inspect$1);
|
|
1599
|
-
if (output) {
|
|
1600
|
-
if (typeof output === "string")
|
|
1601
|
-
return output;
|
|
1602
|
-
return inspect$1(output, options);
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
const proto = value ? Object.getPrototypeOf(value) : false;
|
|
1606
|
-
if (proto === Object.prototype || proto === null) {
|
|
1607
|
-
return inspectObject$1(value, options);
|
|
1608
|
-
}
|
|
1609
|
-
if (value && typeof HTMLElement === "function" && value instanceof HTMLElement) {
|
|
1610
|
-
return inspectHTML(value, options);
|
|
1611
|
-
}
|
|
1612
|
-
if ("constructor" in value) {
|
|
1613
|
-
if (value.constructor !== Object) {
|
|
1614
|
-
return inspectClass(value, options);
|
|
1615
|
-
}
|
|
1616
|
-
return inspectObject$1(value, options);
|
|
1617
|
-
}
|
|
1618
|
-
if (value === Object(value)) {
|
|
1619
|
-
return inspectObject$1(value, options);
|
|
1620
|
-
}
|
|
1621
|
-
return options.stylize(String(value), type);
|
|
1622
|
-
}
|
|
1623
1122
|
const { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent } = plugins;
|
|
1624
1123
|
const PLUGINS = [
|
|
1625
1124
|
ReactTestComponent,
|
|
@@ -1681,23 +1180,12 @@ function createNodeFilterFromSelector(selector) {
|
|
|
1681
1180
|
};
|
|
1682
1181
|
}
|
|
1683
1182
|
const formatRegExp = /%[sdjifoOc%]/g;
|
|
1684
|
-
function
|
|
1685
|
-
const formatArg = (item
|
|
1686
|
-
if (options.prettifyObject) {
|
|
1687
|
-
return stringify(item, void 0, {
|
|
1688
|
-
printBasicPrototype: false,
|
|
1689
|
-
escapeString: false
|
|
1690
|
-
});
|
|
1691
|
-
}
|
|
1692
|
-
return inspect(item, inspecOptions);
|
|
1693
|
-
};
|
|
1183
|
+
function format(args, options = {}) {
|
|
1184
|
+
const formatArg = (item) => inspect(item, options);
|
|
1694
1185
|
if (typeof args[0] !== "string") {
|
|
1695
1186
|
const objects = [];
|
|
1696
1187
|
for (let i3 = 0; i3 < args.length; i3++) {
|
|
1697
|
-
objects.push(formatArg(args[i3]
|
|
1698
|
-
depth: 0,
|
|
1699
|
-
colors: false
|
|
1700
|
-
}));
|
|
1188
|
+
objects.push(formatArg(args[i3]));
|
|
1701
1189
|
}
|
|
1702
1190
|
return objects.join(" ");
|
|
1703
1191
|
}
|
|
@@ -1724,10 +1212,7 @@ function baseFormat(args, options = {}) {
|
|
|
1724
1212
|
if (typeof value.toString === "function" && value.toString !== Object.prototype.toString) {
|
|
1725
1213
|
return value.toString();
|
|
1726
1214
|
}
|
|
1727
|
-
return formatArg(value
|
|
1728
|
-
depth: 0,
|
|
1729
|
-
colors: false
|
|
1730
|
-
});
|
|
1215
|
+
return formatArg(value);
|
|
1731
1216
|
}
|
|
1732
1217
|
return String(value);
|
|
1733
1218
|
}
|
|
@@ -1751,10 +1236,6 @@ function baseFormat(args, options = {}) {
|
|
|
1751
1236
|
case "%f":
|
|
1752
1237
|
return Number.parseFloat(String(args[i2++])).toString();
|
|
1753
1238
|
case "%o":
|
|
1754
|
-
return formatArg(args[i2++], {
|
|
1755
|
-
showHidden: true,
|
|
1756
|
-
showProxy: true
|
|
1757
|
-
});
|
|
1758
1239
|
case "%O":
|
|
1759
1240
|
return formatArg(args[i2++]);
|
|
1760
1241
|
case "%c": {
|
|
@@ -1784,36 +1265,85 @@ function baseFormat(args, options = {}) {
|
|
|
1784
1265
|
}
|
|
1785
1266
|
return str;
|
|
1786
1267
|
}
|
|
1787
|
-
function
|
|
1788
|
-
|
|
1268
|
+
function inspect(obj, options) {
|
|
1269
|
+
const { truncate, multiline, ...stringifyOptions } = options ?? {};
|
|
1270
|
+
const prettyFormatOptions = {
|
|
1271
|
+
singleQuote: true,
|
|
1272
|
+
quoteKeys: false,
|
|
1273
|
+
min: true,
|
|
1274
|
+
spacingInner: " ",
|
|
1275
|
+
spacingOuter: " ",
|
|
1276
|
+
printBasicPrototype: false,
|
|
1277
|
+
compareKeys: null,
|
|
1278
|
+
...multiline ? {
|
|
1279
|
+
min: false,
|
|
1280
|
+
spacingInner: void 0,
|
|
1281
|
+
spacingOuter: void 0
|
|
1282
|
+
} : {}
|
|
1283
|
+
};
|
|
1284
|
+
const threshold = truncate ?? 0;
|
|
1285
|
+
const formatted = stringify(obj, void 0, {
|
|
1286
|
+
...prettyFormatOptions,
|
|
1287
|
+
...stringifyOptions,
|
|
1288
|
+
maxLength: threshold || void 0
|
|
1289
|
+
});
|
|
1290
|
+
if (threshold === 0 || formatted.length <= threshold) {
|
|
1291
|
+
return formatted;
|
|
1292
|
+
}
|
|
1293
|
+
const type = Object.prototype.toString.call(obj);
|
|
1294
|
+
if (typeof obj === "string") {
|
|
1295
|
+
let end = threshold - 1;
|
|
1296
|
+
if (end > 0 && isHighSurrogate(formatted[end - 1])) {
|
|
1297
|
+
end = end - 1;
|
|
1298
|
+
}
|
|
1299
|
+
return `'${formatted.slice(1, end)}…'`;
|
|
1300
|
+
}
|
|
1301
|
+
if (type === "[object Array]" || type === "[object Object]" || type === "[object Set]" || type === "[object Map]") {
|
|
1302
|
+
return stringifyByMaxWidth(obj, threshold, {
|
|
1303
|
+
...prettyFormatOptions,
|
|
1304
|
+
...stringifyOptions,
|
|
1305
|
+
maxDepth: 1
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
return stringify(obj, void 0, {
|
|
1309
|
+
...prettyFormatOptions,
|
|
1310
|
+
...stringifyOptions,
|
|
1311
|
+
maxDepth: 0
|
|
1312
|
+
});
|
|
1789
1313
|
}
|
|
1790
|
-
function
|
|
1791
|
-
if (
|
|
1792
|
-
|
|
1314
|
+
function truncateString(string, maxLength) {
|
|
1315
|
+
if (string.length <= maxLength) {
|
|
1316
|
+
return string;
|
|
1793
1317
|
}
|
|
1794
|
-
|
|
1318
|
+
let end = maxLength - 1;
|
|
1319
|
+
if (isHighSurrogate(string[end - 1])) {
|
|
1320
|
+
end = end - 1;
|
|
1321
|
+
}
|
|
1322
|
+
return `${string.slice(0, end)}…`;
|
|
1795
1323
|
}
|
|
1796
|
-
function
|
|
1797
|
-
|
|
1798
|
-
|
|
1324
|
+
function stringifyByMaxWidth(object, threshold, options) {
|
|
1325
|
+
function evaluate(x) {
|
|
1326
|
+
return stringify(object, void 0, {
|
|
1327
|
+
...options,
|
|
1328
|
+
maxWidth: x
|
|
1329
|
+
});
|
|
1799
1330
|
}
|
|
1800
|
-
const
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
} else if (type === "[object Object]") {
|
|
1809
|
-
const keys = Object.keys(obj);
|
|
1810
|
-
const kstr = keys.length > 2 ? `${keys.splice(0, 2).join(", ")}, ...` : keys.join(", ");
|
|
1811
|
-
return `{ Object (${kstr}) }`;
|
|
1331
|
+
const opt = binarySearch(0, threshold, (x) => evaluate(x).length <= threshold);
|
|
1332
|
+
return evaluate(opt);
|
|
1333
|
+
}
|
|
1334
|
+
function binarySearch(x0, x1, f) {
|
|
1335
|
+
while (x0 + 1 < x1) {
|
|
1336
|
+
const x = Math.floor((x0 + x1) / 2);
|
|
1337
|
+
if (f(x)) {
|
|
1338
|
+
x0 = x;
|
|
1812
1339
|
} else {
|
|
1813
|
-
|
|
1340
|
+
x1 = x;
|
|
1814
1341
|
}
|
|
1815
1342
|
}
|
|
1816
|
-
return
|
|
1343
|
+
return x0;
|
|
1344
|
+
}
|
|
1345
|
+
function isHighSurrogate(char) {
|
|
1346
|
+
return char >= "\uD800" && char <= "\uDBFF";
|
|
1817
1347
|
}
|
|
1818
1348
|
function assertTypes(value, name, types) {
|
|
1819
1349
|
const receivedType = typeof value;
|
|
@@ -3445,17 +2975,20 @@ function formatTitle(template, items, idx) {
|
|
|
3445
2975
|
}
|
|
3446
2976
|
});
|
|
3447
2977
|
}
|
|
2978
|
+
const inspectOptions = { truncate: runner.config.taskTitleValueFormatTruncate };
|
|
3448
2979
|
const isObjectItem = isObject(items[0]);
|
|
3449
2980
|
function formatAttribute(s) {
|
|
3450
2981
|
return s.replace(/\$([$\w.]+)/g, (_, key) => {
|
|
3451
|
-
var _a, _b;
|
|
3452
2982
|
const isArrayKey = /^\d+$/.test(key);
|
|
3453
2983
|
if (!isObjectItem && !isArrayKey) {
|
|
3454
2984
|
return `$${key}`;
|
|
3455
2985
|
}
|
|
3456
2986
|
const arrayElement = isArrayKey ? objectAttr(items, key) : void 0;
|
|
3457
2987
|
const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
|
|
3458
|
-
|
|
2988
|
+
if (typeof value === "string") {
|
|
2989
|
+
return truncateString(value, inspectOptions.truncate);
|
|
2990
|
+
}
|
|
2991
|
+
return inspect(value, inspectOptions);
|
|
3459
2992
|
});
|
|
3460
2993
|
}
|
|
3461
2994
|
let output = "";
|
|
@@ -3466,7 +2999,7 @@ function formatTitle(template, items, idx) {
|
|
|
3466
2999
|
// format "%"
|
|
3467
3000
|
(match) => {
|
|
3468
3001
|
if (i2 < count) {
|
|
3469
|
-
output += format(match[0], items[i2++]);
|
|
3002
|
+
output += format([match[0], items[i2++]], inspectOptions);
|
|
3470
3003
|
} else {
|
|
3471
3004
|
output += match[0];
|
|
3472
3005
|
}
|
|
@@ -3817,6 +3350,7 @@ const moduleRunner = {
|
|
|
3817
3350
|
return importId(id);
|
|
3818
3351
|
}
|
|
3819
3352
|
};
|
|
3353
|
+
const now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
3820
3354
|
function getConfig() {
|
|
3821
3355
|
return (/* @__PURE__ */ getBrowserState()).config;
|
|
3822
3356
|
}
|
|
@@ -3840,5 +3374,6 @@ export {
|
|
|
3840
3374
|
getTestName as e,
|
|
3841
3375
|
getBrowserState as g,
|
|
3842
3376
|
moduleRunner as m,
|
|
3377
|
+
now as n,
|
|
3843
3378
|
relative as r
|
|
3844
3379
|
};
|