vitest 5.0.0-beta.6 → 5.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE.md +165 -1
  2. package/dist/browser.d.ts +27 -14
  3. package/dist/browser.js +11 -14
  4. package/dist/chunks/{artifact.BNnEI1sJ.js → artifact.DC5WoEgy.js} +1305 -8
  5. package/dist/chunks/{base.BKfXyFN7.js → base.B0fUxpj9.js} +17 -13
  6. package/dist/chunks/{browser.d.DoM6vBOs.d.ts → browser.d.BFOby8YL.d.ts} +3 -3
  7. package/dist/chunks/{cac.DKrA6qEB.js → cac.B41kXwyU.js} +20 -22
  8. package/dist/chunks/check.Cz_-YojU.js +15 -0
  9. package/dist/chunks/cli-api.bqNN5viV.js +519 -0
  10. package/dist/chunks/{config.d.CKWK3nld.d.ts → config.d.DsC1jkby.d.ts} +871 -25
  11. package/dist/chunks/{console.DjVIMaXT.js → console.omGxyKMT.js} +5 -5
  12. package/dist/chunks/{coverage.CTzCuANN.js → coverage.BVb1JqW7.js} +7 -2
  13. package/dist/chunks/coverage.BfSEMtie.js +26 -0
  14. package/dist/chunks/coverage.d.ByaAMV4A.d.ts +88 -0
  15. package/dist/chunks/{creator.C4nK7Krt.js → creator.BzMFaPC-.js} +53 -29
  16. package/dist/chunks/{defaults.B_pFOTYy.js → defaults.BJUmAuaO.js} +2 -1
  17. package/dist/chunks/display.CYwyMF4S.js +192 -0
  18. package/dist/chunks/{env.BKKtU2WC.js → env.DzFJjrmK.js} +1 -1
  19. package/dist/chunks/{environment.d.CrsxCzP1.d.ts → environment.d.4-rzQgpt.d.ts} +1 -1
  20. package/dist/chunks/globals.sd6Qutmc.js +28 -0
  21. package/dist/chunks/{cli-api.cZcvaUFI.js → index.5krd73UD.js} +15958 -14627
  22. package/dist/chunks/{index.D6NDM5O1.js → index.CLtI1k_4.js} +135 -101
  23. package/dist/chunks/{index.DNRmy2jU.js → index.DxR-nMjO.js} +42 -4
  24. package/dist/chunks/index.DzTmMrSM.js +940 -0
  25. package/dist/chunks/{index.B4UTDegh.js → index.JaztIWgW.js} +5 -4
  26. package/dist/chunks/{init-forks.BG4bCDny.js → init-forks.CXzT841o.js} +1 -1
  27. package/dist/chunks/{init-threads.DLtIP5Qq.js → init-threads.Ch-Bw5j3.js} +1 -1
  28. package/dist/chunks/{init.DTAQFCjl.js → init.CfiYZpFg.js} +40 -24
  29. package/dist/chunks/{native.DPzPHdi5.js → native.BUCvPRKp.js} +3 -4
  30. package/dist/chunks/{nativeModuleMocker.BKtCThoO.js → nativeModuleMocker.Uot80PXb.js} +2 -3
  31. package/dist/chunks/{index.CesbTg1C.js → nativeModuleRunner.BDnwGb8g.js} +39 -3
  32. package/dist/chunks/{node.C9I1sbE9.js → node.BPMnm_Q2.js} +1 -1
  33. package/dist/chunks/offset.Dy-5Fdfn.js +24 -0
  34. package/dist/chunks/pathe.M-eThtNZ.CbK_Vbae.js +489 -0
  35. package/dist/chunks/{plugin.d.Bpge8Jye.d.ts → plugin.d.BOjbmxWW.d.ts} +1719 -1549
  36. package/dist/chunks/{plugins.DrsmdUE2.js → plugins.CsoX-42X.js} +1 -1
  37. package/dist/chunks/resolver.CERfsKE-.js +48 -0
  38. package/dist/chunks/{rpc.d.C6-dGZ2f.d.ts → rpc.d.BeasqWpO.d.ts} +14 -1
  39. package/dist/chunks/{rpc.DZEh5xnQ.js → rpc.iNjF664v.js} +2 -2
  40. package/dist/chunks/setup-common.vxjAyUtK.js +36 -0
  41. package/dist/chunks/setup.DasACXvo.js +5409 -0
  42. package/dist/chunks/source-map.DZdIqpIJ.js +1776 -0
  43. package/dist/chunks/spy.B8mHA9qu.js +422 -0
  44. package/dist/chunks/{task-utils.d.mMDXJF_I.d.ts → task-utils.d.BKHiHxSN.d.ts} +1 -2
  45. package/dist/chunks/tinyrainbow.Ht9iggcq.js +95 -0
  46. package/dist/chunks/{utils.DKODp04v.js → utils.CO-iLyCr.js} +41 -42
  47. package/dist/chunks/{vm.CeHWcIrU.js → vm.DoQh8CN9.js} +110 -11
  48. package/dist/chunks/{worker.d.JES7ffPK.d.ts → worker.d.s_RdeZtI.d.ts} +14 -11
  49. package/dist/cli.js +4 -5
  50. package/dist/config.cjs +1 -0
  51. package/dist/config.d.ts +19 -17
  52. package/dist/config.js +2 -2
  53. package/dist/index.d.ts +14 -29
  54. package/dist/index.js +11 -16
  55. package/dist/module-evaluator.d.ts +40 -8
  56. package/dist/module-evaluator.js +66 -22
  57. package/dist/node.d.ts +210 -82
  58. package/dist/node.js +29 -66
  59. package/dist/runtime.d.ts +5 -10
  60. package/dist/runtime.js +4 -5
  61. package/dist/spy.js +1 -1
  62. package/dist/task-utils.js +1 -2
  63. package/dist/worker.d.ts +5 -10
  64. package/dist/worker.js +24 -36
  65. package/dist/workers/forks.js +21 -33
  66. package/dist/workers/runVmTests.js +15 -20
  67. package/dist/workers/threads.js +21 -33
  68. package/dist/workers/vmForks.js +13 -15
  69. package/dist/workers/vmThreads.js +13 -15
  70. package/package.json +15 -15
  71. package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -6
  72. package/dist/chunks/coverage.d.CCNrKR65.d.ts +0 -43
  73. package/dist/chunks/globals.CzUA1xn8.js +0 -33
  74. package/dist/chunks/index.Djaij2xr.js +0 -6960
  75. package/dist/chunks/nativeModuleRunner.WlMdOB52.js +0 -36
  76. package/dist/chunks/setup-common.ZNdeu5wa.js +0 -64
@@ -1,9 +1,1306 @@
1
- import { processError } from '@vitest/utils/error';
2
- import { isObject, filterOutComments, ordinal, createDefer, assertTypes, toArray, isNegativeNaN, unique, objectAttr, shuffle } from '@vitest/utils/helpers';
3
- import { getSafeTimers } from '@vitest/utils/timers';
1
+ import { f as format, p as plugins } from './index.DzTmMrSM.js';
2
+ import { y } from './tinyrainbow.Ht9iggcq.js';
3
+ import { s as stringify, f as format$1, a as formatRegExp, t as truncateString, i as inspect } from './display.CYwyMF4S.js';
4
+ import { q as deepClone, u as getOwnProperties, g as getType$1, v as isObject, w as filterOutComments, x as ordinal, e as createDefer, y as assertTypes, z as isNegativeNaN, t as toArray, A as unique, B as objectAttr } from './pathe.M-eThtNZ.CbK_Vbae.js';
5
+ import { e as diffSequences, b as serializeValue, f as parseSingleStack, a as getSafeTimers } from './source-map.DZdIqpIJ.js';
4
6
  import { createTaskName, createFileTask, calculateSuiteHash, interpretTaskModes, someTasksAreOnly, hasTests, hasFailed } from '../task-utils.js';
5
- import { format, formatRegExp, truncateString, inspect } from '@vitest/utils/display';
6
- import { parseSingleStack } from '@vitest/utils/source-map';
7
+
8
+ const RealDate = Date;
9
+ function random(seed) {
10
+ const x = Math.sin(seed++) * 1e4;
11
+ return x - Math.floor(x);
12
+ }
13
+ function shuffle(array, seed = RealDate.now()) {
14
+ let length = array.length;
15
+ while (length) {
16
+ const index = Math.floor(random(seed) * length--);
17
+ const previous = array[length];
18
+ array[length] = array[index];
19
+ array[index] = previous;
20
+ ++seed;
21
+ }
22
+ return array;
23
+ }
24
+
25
+ /**
26
+ * Diff Match and Patch
27
+ * Copyright 2018 The diff-match-patch Authors.
28
+ * https://github.com/google/diff-match-patch
29
+ *
30
+ * Licensed under the Apache License, Version 2.0 (the "License");
31
+ * you may not use this file except in compliance with the License.
32
+ * You may obtain a copy of the License at
33
+ *
34
+ * http://www.apache.org/licenses/LICENSE-2.0
35
+ *
36
+ * Unless required by applicable law or agreed to in writing, software
37
+ * distributed under the License is distributed on an "AS IS" BASIS,
38
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39
+ * See the License for the specific language governing permissions and
40
+ * limitations under the License.
41
+ */
42
+ /**
43
+ * @fileoverview Computes the difference between two texts to create a patch.
44
+ * Applies the patch onto another text, allowing for errors.
45
+ * @author fraser@google.com (Neil Fraser)
46
+ */
47
+ /**
48
+ * CHANGES by pedrottimark to diff_match_patch_uncompressed.ts file:
49
+ *
50
+ * 1. Delete anything not needed to use diff_cleanupSemantic method
51
+ * 2. Convert from prototype properties to var declarations
52
+ * 3. Convert Diff to class from constructor and prototype
53
+ * 4. Add type annotations for arguments and return values
54
+ * 5. Add exports
55
+ */
56
+ /**
57
+ * The data structure representing a diff is an array of tuples:
58
+ * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
59
+ * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
60
+ */
61
+ const DIFF_DELETE = -1;
62
+ const DIFF_INSERT = 1;
63
+ const DIFF_EQUAL = 0;
64
+ /**
65
+ * Class representing one diff tuple.
66
+ * Attempts to look like a two-element array (which is what this used to be).
67
+ * @param {number} op Operation, one of: DIFF_DELETE, DIFF_INSERT, DIFF_EQUAL.
68
+ * @param {string} text Text to be deleted, inserted, or retained.
69
+ * @constructor
70
+ */
71
+ class Diff {
72
+ 0;
73
+ 1;
74
+ constructor(op, text) {
75
+ this[0] = op;
76
+ this[1] = text;
77
+ }
78
+ }
79
+ /**
80
+ * Determine the common prefix of two strings.
81
+ * @param {string} text1 First string.
82
+ * @param {string} text2 Second string.
83
+ * @return {number} The number of characters common to the start of each
84
+ * string.
85
+ */
86
+ function diff_commonPrefix(text1, text2) {
87
+ // Quick check for common null cases.
88
+ if (!text1 || !text2 || text1.charAt(0) !== text2.charAt(0)) return 0;
89
+ // Binary search.
90
+ // Performance analysis: https://neil.fraser.name/news/2007/10/09/
91
+ let pointermin = 0;
92
+ let pointermax = Math.min(text1.length, text2.length);
93
+ let pointermid = pointermax;
94
+ let pointerstart = 0;
95
+ while (pointermin < pointermid) {
96
+ if (text1.substring(pointerstart, pointermid) === text2.substring(pointerstart, pointermid)) {
97
+ pointermin = pointermid;
98
+ pointerstart = pointermin;
99
+ } else pointermax = pointermid;
100
+ pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
101
+ }
102
+ return pointermid;
103
+ }
104
+ /**
105
+ * Determine the common suffix of two strings.
106
+ * @param {string} text1 First string.
107
+ * @param {string} text2 Second string.
108
+ * @return {number} The number of characters common to the end of each string.
109
+ */
110
+ function diff_commonSuffix(text1, text2) {
111
+ // Quick check for common null cases.
112
+ if (!text1 || !text2 || text1.charAt(text1.length - 1) !== text2.charAt(text2.length - 1)) return 0;
113
+ // Binary search.
114
+ // Performance analysis: https://neil.fraser.name/news/2007/10/09/
115
+ let pointermin = 0;
116
+ let pointermax = Math.min(text1.length, text2.length);
117
+ let pointermid = pointermax;
118
+ let pointerend = 0;
119
+ while (pointermin < pointermid) {
120
+ if (text1.substring(text1.length - pointermid, text1.length - pointerend) === text2.substring(text2.length - pointermid, text2.length - pointerend)) {
121
+ pointermin = pointermid;
122
+ pointerend = pointermin;
123
+ } else pointermax = pointermid;
124
+ pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
125
+ }
126
+ return pointermid;
127
+ }
128
+ /**
129
+ * Determine if the suffix of one string is the prefix of another.
130
+ * @param {string} text1 First string.
131
+ * @param {string} text2 Second string.
132
+ * @return {number} The number of characters common to the end of the first
133
+ * string and the start of the second string.
134
+ * @private
135
+ */
136
+ function diff_commonOverlap_(text1, text2) {
137
+ // Cache the text lengths to prevent multiple calls.
138
+ const text1_length = text1.length;
139
+ const text2_length = text2.length;
140
+ // Eliminate the null case.
141
+ if (text1_length === 0 || text2_length === 0) return 0;
142
+ // Truncate the longer string.
143
+ if (text1_length > text2_length) text1 = text1.substring(text1_length - text2_length);
144
+ else if (text1_length < text2_length) text2 = text2.substring(0, text1_length);
145
+ const text_length = Math.min(text1_length, text2_length);
146
+ // Quick check for the worst case.
147
+ if (text1 === text2) return text_length;
148
+ // Start by looking for a single character match
149
+ // and increase length until no match is found.
150
+ // Performance analysis: https://neil.fraser.name/news/2010/11/04/
151
+ let best = 0;
152
+ let length = 1;
153
+ while (true) {
154
+ const pattern = text1.substring(text_length - length);
155
+ const found = text2.indexOf(pattern);
156
+ if (found === -1) return best;
157
+ length += found;
158
+ if (found === 0 || text1.substring(text_length - length) === text2.substring(0, length)) {
159
+ best = length;
160
+ length++;
161
+ }
162
+ }
163
+ }
164
+ /**
165
+ * Reduce the number of edits by eliminating semantically trivial equalities.
166
+ * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
167
+ */
168
+ function diff_cleanupSemantic(diffs) {
169
+ let changes = false;
170
+ const equalities = [];
171
+ let equalitiesLength = 0;
172
+ /** @type {?string} */
173
+ let lastEquality = null;
174
+ // Always equal to diffs[equalities[equalitiesLength - 1]][1]
175
+ let pointer = 0;
176
+ // Number of characters that changed prior to the equality.
177
+ let length_insertions1 = 0;
178
+ let length_deletions1 = 0;
179
+ // Number of characters that changed after the equality.
180
+ let length_insertions2 = 0;
181
+ let length_deletions2 = 0;
182
+ while (pointer < diffs.length) {
183
+ if (diffs[pointer][0] === DIFF_EQUAL) {
184
+ // Equality found.
185
+ equalities[equalitiesLength++] = pointer;
186
+ length_insertions1 = length_insertions2;
187
+ length_deletions1 = length_deletions2;
188
+ length_insertions2 = 0;
189
+ length_deletions2 = 0;
190
+ lastEquality = diffs[pointer][1];
191
+ } else {
192
+ // An insertion or deletion.
193
+ if (diffs[pointer][0] === DIFF_INSERT) length_insertions2 += diffs[pointer][1].length;
194
+ else length_deletions2 += diffs[pointer][1].length;
195
+ // Eliminate an equality that is smaller or equal to the edits on both
196
+ // sides of it.
197
+ if (lastEquality && lastEquality.length <= Math.max(length_insertions1, length_deletions1) && lastEquality.length <= Math.max(length_insertions2, length_deletions2)) {
198
+ // Duplicate record.
199
+ diffs.splice(equalities[equalitiesLength - 1], 0, new Diff(DIFF_DELETE, lastEquality));
200
+ // Change second copy to insert.
201
+ diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;
202
+ // Throw away the equality we just deleted.
203
+ equalitiesLength--;
204
+ // Throw away the previous equality (it needs to be reevaluated).
205
+ equalitiesLength--;
206
+ pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;
207
+ length_insertions1 = 0;
208
+ length_deletions1 = 0;
209
+ length_insertions2 = 0;
210
+ length_deletions2 = 0;
211
+ lastEquality = null;
212
+ changes = true;
213
+ }
214
+ }
215
+ pointer++;
216
+ }
217
+ // Normalize the diff.
218
+ if (changes) diff_cleanupMerge(diffs);
219
+ diff_cleanupSemanticLossless(diffs);
220
+ // Find any overlaps between deletions and insertions.
221
+ // e.g: <del>abcxxx</del><ins>xxxdef</ins>
222
+ // -> <del>abc</del>xxx<ins>def</ins>
223
+ // e.g: <del>xxxabc</del><ins>defxxx</ins>
224
+ // -> <ins>def</ins>xxx<del>abc</del>
225
+ // Only extract an overlap if it is as big as the edit ahead or behind it.
226
+ pointer = 1;
227
+ while (pointer < diffs.length) {
228
+ if (diffs[pointer - 1][0] === DIFF_DELETE && diffs[pointer][0] === DIFF_INSERT) {
229
+ const deletion = diffs[pointer - 1][1];
230
+ const insertion = diffs[pointer][1];
231
+ const overlap_length1 = diff_commonOverlap_(deletion, insertion);
232
+ const overlap_length2 = diff_commonOverlap_(insertion, deletion);
233
+ if (overlap_length1 >= overlap_length2) {
234
+ if (overlap_length1 >= deletion.length / 2 || overlap_length1 >= insertion.length / 2) {
235
+ // Overlap found. Insert an equality and trim the surrounding edits.
236
+ diffs.splice(pointer, 0, new Diff(DIFF_EQUAL, insertion.substring(0, overlap_length1)));
237
+ diffs[pointer - 1][1] = deletion.substring(0, deletion.length - overlap_length1);
238
+ diffs[pointer + 1][1] = insertion.substring(overlap_length1);
239
+ pointer++;
240
+ }
241
+ } else if (overlap_length2 >= deletion.length / 2 || overlap_length2 >= insertion.length / 2) {
242
+ // Reverse overlap found.
243
+ // Insert an equality and swap and trim the surrounding edits.
244
+ diffs.splice(pointer, 0, new Diff(DIFF_EQUAL, deletion.substring(0, overlap_length2)));
245
+ diffs[pointer - 1][0] = DIFF_INSERT;
246
+ diffs[pointer - 1][1] = insertion.substring(0, insertion.length - overlap_length2);
247
+ diffs[pointer + 1][0] = DIFF_DELETE;
248
+ diffs[pointer + 1][1] = deletion.substring(overlap_length2);
249
+ pointer++;
250
+ }
251
+ pointer++;
252
+ }
253
+ pointer++;
254
+ }
255
+ }
256
+ // Define some regex patterns for matching boundaries.
257
+ const nonAlphaNumericRegex_ = /[^a-z0-9]/i;
258
+ const whitespaceRegex_ = /\s/;
259
+ const linebreakRegex_ = /[\r\n]/;
260
+ const blanklineEndRegex_ = /\n\r?\n$/;
261
+ const blanklineStartRegex_ = /^\r?\n\r?\n/;
262
+ /**
263
+ * Look for single edits surrounded on both sides by equalities
264
+ * which can be shifted sideways to align the edit to a word boundary.
265
+ * e.g: The c<ins>at c</ins>ame. -> The <ins>cat </ins>came.
266
+ * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
267
+ */
268
+ function diff_cleanupSemanticLossless(diffs) {
269
+ let pointer = 1;
270
+ // Intentionally ignore the first and last element (don't need checking).
271
+ while (pointer < diffs.length - 1) {
272
+ if (diffs[pointer - 1][0] === DIFF_EQUAL && diffs[pointer + 1][0] === DIFF_EQUAL) {
273
+ // This is a single edit surrounded by equalities.
274
+ let equality1 = diffs[pointer - 1][1];
275
+ let edit = diffs[pointer][1];
276
+ let equality2 = diffs[pointer + 1][1];
277
+ // First, shift the edit as far left as possible.
278
+ const commonOffset = diff_commonSuffix(equality1, edit);
279
+ if (commonOffset) {
280
+ const commonString = edit.substring(edit.length - commonOffset);
281
+ equality1 = equality1.substring(0, equality1.length - commonOffset);
282
+ edit = commonString + edit.substring(0, edit.length - commonOffset);
283
+ equality2 = commonString + equality2;
284
+ }
285
+ // Second, step character by character right, looking for the best fit.
286
+ let bestEquality1 = equality1;
287
+ let bestEdit = edit;
288
+ let bestEquality2 = equality2;
289
+ let bestScore = diff_cleanupSemanticScore_(equality1, edit) + diff_cleanupSemanticScore_(edit, equality2);
290
+ while (edit.charAt(0) === equality2.charAt(0)) {
291
+ equality1 += edit.charAt(0);
292
+ edit = edit.substring(1) + equality2.charAt(0);
293
+ equality2 = equality2.substring(1);
294
+ const score = diff_cleanupSemanticScore_(equality1, edit) + diff_cleanupSemanticScore_(edit, equality2);
295
+ // The >= encourages trailing rather than leading whitespace on edits.
296
+ if (score >= bestScore) {
297
+ bestScore = score;
298
+ bestEquality1 = equality1;
299
+ bestEdit = edit;
300
+ bestEquality2 = equality2;
301
+ }
302
+ }
303
+ if (diffs[pointer - 1][1] !== bestEquality1) {
304
+ // We have an improvement, save it back to the diff.
305
+ if (bestEquality1) diffs[pointer - 1][1] = bestEquality1;
306
+ else {
307
+ diffs.splice(pointer - 1, 1);
308
+ pointer--;
309
+ }
310
+ diffs[pointer][1] = bestEdit;
311
+ if (bestEquality2) diffs[pointer + 1][1] = bestEquality2;
312
+ else {
313
+ diffs.splice(pointer + 1, 1);
314
+ pointer--;
315
+ }
316
+ }
317
+ }
318
+ pointer++;
319
+ }
320
+ }
321
+ /**
322
+ * Reorder and merge like edit sections. Merge equalities.
323
+ * Any edit section can move as long as it doesn't cross an equality.
324
+ * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
325
+ */
326
+ function diff_cleanupMerge(diffs) {
327
+ // Add a dummy entry at the end.
328
+ diffs.push(new Diff(DIFF_EQUAL, ""));
329
+ let pointer = 0;
330
+ let count_delete = 0;
331
+ let count_insert = 0;
332
+ let text_delete = "";
333
+ let text_insert = "";
334
+ let commonlength;
335
+ while (pointer < diffs.length) switch (diffs[pointer][0]) {
336
+ case DIFF_INSERT:
337
+ count_insert++;
338
+ text_insert += diffs[pointer][1];
339
+ pointer++;
340
+ break;
341
+ case DIFF_DELETE:
342
+ count_delete++;
343
+ text_delete += diffs[pointer][1];
344
+ pointer++;
345
+ break;
346
+ case DIFF_EQUAL:
347
+ // Upon reaching an equality, check for prior redundancies.
348
+ if (count_delete + count_insert > 1) {
349
+ if (count_delete !== 0 && count_insert !== 0) {
350
+ // Factor out any common prefixes.
351
+ commonlength = diff_commonPrefix(text_insert, text_delete);
352
+ if (commonlength !== 0) {
353
+ if (pointer - count_delete - count_insert > 0 && diffs[pointer - count_delete - count_insert - 1][0] === DIFF_EQUAL) diffs[pointer - count_delete - count_insert - 1][1] += text_insert.substring(0, commonlength);
354
+ else {
355
+ diffs.splice(0, 0, new Diff(DIFF_EQUAL, text_insert.substring(0, commonlength)));
356
+ pointer++;
357
+ }
358
+ text_insert = text_insert.substring(commonlength);
359
+ text_delete = text_delete.substring(commonlength);
360
+ }
361
+ // Factor out any common suffixes.
362
+ commonlength = diff_commonSuffix(text_insert, text_delete);
363
+ if (commonlength !== 0) {
364
+ diffs[pointer][1] = text_insert.substring(text_insert.length - commonlength) + diffs[pointer][1];
365
+ text_insert = text_insert.substring(0, text_insert.length - commonlength);
366
+ text_delete = text_delete.substring(0, text_delete.length - commonlength);
367
+ }
368
+ }
369
+ // Delete the offending records and add the merged ones.
370
+ pointer -= count_delete + count_insert;
371
+ diffs.splice(pointer, count_delete + count_insert);
372
+ if (text_delete.length) {
373
+ diffs.splice(pointer, 0, new Diff(DIFF_DELETE, text_delete));
374
+ pointer++;
375
+ }
376
+ if (text_insert.length) {
377
+ diffs.splice(pointer, 0, new Diff(DIFF_INSERT, text_insert));
378
+ pointer++;
379
+ }
380
+ pointer++;
381
+ } else if (pointer !== 0 && diffs[pointer - 1][0] === DIFF_EQUAL) {
382
+ // Merge this equality with the previous one.
383
+ diffs[pointer - 1][1] += diffs[pointer][1];
384
+ diffs.splice(pointer, 1);
385
+ } else pointer++;
386
+ count_insert = 0;
387
+ count_delete = 0;
388
+ text_delete = "";
389
+ text_insert = "";
390
+ break;
391
+ }
392
+ if (diffs.at(-1)?.[1] === "") diffs.pop();
393
+ // Second pass: look for single edits surrounded on both sides by equalities
394
+ // which can be shifted sideways to eliminate an equality.
395
+ // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
396
+ let changes = false;
397
+ pointer = 1;
398
+ // Intentionally ignore the first and last element (don't need checking).
399
+ while (pointer < diffs.length - 1) {
400
+ if (diffs[pointer - 1][0] === DIFF_EQUAL && diffs[pointer + 1][0] === DIFF_EQUAL) {
401
+ // This is a single edit surrounded by equalities.
402
+ if (diffs[pointer][1].substring(diffs[pointer][1].length - diffs[pointer - 1][1].length) === diffs[pointer - 1][1]) {
403
+ // Shift the edit over the previous equality.
404
+ diffs[pointer][1] = diffs[pointer - 1][1] + diffs[pointer][1].substring(0, diffs[pointer][1].length - diffs[pointer - 1][1].length);
405
+ diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
406
+ diffs.splice(pointer - 1, 1);
407
+ changes = true;
408
+ } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) === diffs[pointer + 1][1]) {
409
+ // Shift the edit over the next equality.
410
+ diffs[pointer - 1][1] += diffs[pointer + 1][1];
411
+ diffs[pointer][1] = diffs[pointer][1].substring(diffs[pointer + 1][1].length) + diffs[pointer + 1][1];
412
+ diffs.splice(pointer + 1, 1);
413
+ changes = true;
414
+ }
415
+ }
416
+ pointer++;
417
+ }
418
+ // If shifts were made, the diff needs reordering and another shift sweep.
419
+ if (changes) diff_cleanupMerge(diffs);
420
+ }
421
+ /**
422
+ * Given two strings, compute a score representing whether the internal
423
+ * boundary falls on logical boundaries.
424
+ * Scores range from 6 (best) to 0 (worst).
425
+ * Closure, but does not reference any external variables.
426
+ * @param {string} one First string.
427
+ * @param {string} two Second string.
428
+ * @return {number} The score.
429
+ * @private
430
+ */
431
+ function diff_cleanupSemanticScore_(one, two) {
432
+ if (!one || !two)
433
+ // Edges are the best.
434
+ return 6;
435
+ // Each port of this function behaves slightly differently due to
436
+ // subtle differences in each language's definition of things like
437
+ // 'whitespace'. Since this function's purpose is largely cosmetic,
438
+ // the choice has been made to use each language's native features
439
+ // rather than force total conformity.
440
+ const char1 = one.charAt(one.length - 1);
441
+ const char2 = two.charAt(0);
442
+ const nonAlphaNumeric1 = char1.match(nonAlphaNumericRegex_);
443
+ const nonAlphaNumeric2 = char2.match(nonAlphaNumericRegex_);
444
+ const whitespace1 = nonAlphaNumeric1 && char1.match(whitespaceRegex_);
445
+ const whitespace2 = nonAlphaNumeric2 && char2.match(whitespaceRegex_);
446
+ const lineBreak1 = whitespace1 && char1.match(linebreakRegex_);
447
+ const lineBreak2 = whitespace2 && char2.match(linebreakRegex_);
448
+ const blankLine1 = lineBreak1 && one.match(blanklineEndRegex_);
449
+ const blankLine2 = lineBreak2 && two.match(blanklineStartRegex_);
450
+ if (blankLine1 || blankLine2)
451
+ // Five points for blank lines.
452
+ return 5;
453
+ else if (lineBreak1 || lineBreak2)
454
+ // Four points for line breaks.
455
+ return 4;
456
+ else if (nonAlphaNumeric1 && !whitespace1 && whitespace2)
457
+ // Three points for end of sentences.
458
+ return 3;
459
+ else if (whitespace1 || whitespace2)
460
+ // Two points for whitespace.
461
+ return 2;
462
+ else if (nonAlphaNumeric1 || nonAlphaNumeric2)
463
+ // One point for non-alphanumeric.
464
+ return 1;
465
+ return 0;
466
+ }
467
+
468
+ /**
469
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
470
+ *
471
+ * This source code is licensed under the MIT license found in the
472
+ * LICENSE file in the root directory of this source tree.
473
+ */
474
+ const NO_DIFF_MESSAGE = "Compared values have no visual difference.";
475
+ const SIMILAR_MESSAGE = "Compared values serialize to the same structure.\nPrinting internal object structure without calling `toJSON` instead.";
476
+
477
+ function formatTrailingSpaces(line, trailingSpaceFormatter) {
478
+ return line.replace(/\s+$/, (match) => trailingSpaceFormatter(match));
479
+ }
480
+ function printDiffLine(line, isFirstOrLast, color, indicator, trailingSpaceFormatter, emptyFirstOrLastLinePlaceholder) {
481
+ return line.length !== 0 ? color(`${indicator} ${formatTrailingSpaces(line, trailingSpaceFormatter)}`) : indicator !== " " ? color(indicator) : isFirstOrLast && emptyFirstOrLastLinePlaceholder.length !== 0 ? color(`${indicator} ${emptyFirstOrLastLinePlaceholder}`) : "";
482
+ }
483
+ function printDeleteLine(line, isFirstOrLast, { aColor, aIndicator, changeLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder }) {
484
+ return printDiffLine(line, isFirstOrLast, aColor, aIndicator, changeLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder);
485
+ }
486
+ function printInsertLine(line, isFirstOrLast, { bColor, bIndicator, changeLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder }) {
487
+ return printDiffLine(line, isFirstOrLast, bColor, bIndicator, changeLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder);
488
+ }
489
+ function printCommonLine(line, isFirstOrLast, { commonColor, commonIndicator, commonLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder }) {
490
+ return printDiffLine(line, isFirstOrLast, commonColor, commonIndicator, commonLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder);
491
+ }
492
+ // In GNU diff format, indexes are one-based instead of zero-based.
493
+ function createPatchMark(aStart, aEnd, bStart, bEnd, { patchColor }) {
494
+ return patchColor(`@@ -${aStart + 1},${aEnd - aStart} +${bStart + 1},${bEnd - bStart} @@`);
495
+ }
496
+ // jest --no-expand
497
+ //
498
+ // Given array of aligned strings with inverse highlight formatting,
499
+ // return joined lines with diff formatting (and patch marks, if needed).
500
+ function joinAlignedDiffsNoExpand(diffs, options) {
501
+ const iLength = diffs.length;
502
+ const nContextLines = options.contextLines;
503
+ const nContextLines2 = nContextLines + nContextLines;
504
+ // First pass: count output lines and see if it has patches.
505
+ let jLength = iLength;
506
+ let hasExcessAtStartOrEnd = false;
507
+ let nExcessesBetweenChanges = 0;
508
+ let i = 0;
509
+ while (i !== iLength) {
510
+ const iStart = i;
511
+ while (i !== iLength && diffs[i][0] === DIFF_EQUAL) i += 1;
512
+ if (iStart !== i) if (iStart === 0) {
513
+ // at start
514
+ if (i > nContextLines) {
515
+ jLength -= i - nContextLines;
516
+ hasExcessAtStartOrEnd = true;
517
+ }
518
+ } else if (i === iLength) {
519
+ // at end
520
+ const n = i - iStart;
521
+ if (n > nContextLines) {
522
+ jLength -= n - nContextLines;
523
+ hasExcessAtStartOrEnd = true;
524
+ }
525
+ } else {
526
+ // between changes
527
+ const n = i - iStart;
528
+ if (n > nContextLines2) {
529
+ jLength -= n - nContextLines2;
530
+ nExcessesBetweenChanges += 1;
531
+ }
532
+ }
533
+ while (i !== iLength && diffs[i][0] !== DIFF_EQUAL) i += 1;
534
+ }
535
+ const hasPatch = nExcessesBetweenChanges !== 0 || hasExcessAtStartOrEnd;
536
+ if (nExcessesBetweenChanges !== 0) jLength += nExcessesBetweenChanges + 1;
537
+ else if (hasExcessAtStartOrEnd) jLength += 1;
538
+ const jLast = jLength - 1;
539
+ const lines = [];
540
+ let jPatchMark = 0;
541
+ if (hasPatch) lines.push("");
542
+ // Indexes of expected or received lines in current patch:
543
+ let aStart = 0;
544
+ let bStart = 0;
545
+ let aEnd = 0;
546
+ let bEnd = 0;
547
+ const pushCommonLine = (line) => {
548
+ const j = lines.length;
549
+ lines.push(printCommonLine(line, j === 0 || j === jLast, options));
550
+ aEnd += 1;
551
+ bEnd += 1;
552
+ };
553
+ const pushDeleteLine = (line) => {
554
+ const j = lines.length;
555
+ lines.push(printDeleteLine(line, j === 0 || j === jLast, options));
556
+ aEnd += 1;
557
+ };
558
+ const pushInsertLine = (line) => {
559
+ const j = lines.length;
560
+ lines.push(printInsertLine(line, j === 0 || j === jLast, options));
561
+ bEnd += 1;
562
+ };
563
+ // Second pass: push lines with diff formatting (and patch marks, if needed).
564
+ i = 0;
565
+ while (i !== iLength) {
566
+ let iStart = i;
567
+ while (i !== iLength && diffs[i][0] === DIFF_EQUAL) i += 1;
568
+ if (iStart !== i) if (iStart === 0) {
569
+ // at beginning
570
+ if (i > nContextLines) {
571
+ iStart = i - nContextLines;
572
+ aStart = iStart;
573
+ bStart = iStart;
574
+ aEnd = aStart;
575
+ bEnd = bStart;
576
+ }
577
+ for (let iCommon = iStart; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
578
+ } else if (i === iLength) {
579
+ // at end
580
+ const iEnd = i - iStart > nContextLines ? iStart + nContextLines : i;
581
+ for (let iCommon = iStart; iCommon !== iEnd; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
582
+ } else {
583
+ // between changes
584
+ const nCommon = i - iStart;
585
+ if (nCommon > nContextLines2) {
586
+ const iEnd = iStart + nContextLines;
587
+ for (let iCommon = iStart; iCommon !== iEnd; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
588
+ lines[jPatchMark] = createPatchMark(aStart, aEnd, bStart, bEnd, options);
589
+ jPatchMark = lines.length;
590
+ lines.push("");
591
+ const nOmit = nCommon - nContextLines2;
592
+ aStart = aEnd + nOmit;
593
+ bStart = bEnd + nOmit;
594
+ aEnd = aStart;
595
+ bEnd = bStart;
596
+ for (let iCommon = i - nContextLines; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
597
+ } else for (let iCommon = iStart; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
598
+ }
599
+ while (i !== iLength && diffs[i][0] === DIFF_DELETE) {
600
+ pushDeleteLine(diffs[i][1]);
601
+ i += 1;
602
+ }
603
+ while (i !== iLength && diffs[i][0] === DIFF_INSERT) {
604
+ pushInsertLine(diffs[i][1]);
605
+ i += 1;
606
+ }
607
+ }
608
+ if (hasPatch) lines[jPatchMark] = createPatchMark(aStart, aEnd, bStart, bEnd, options);
609
+ return lines.join("\n");
610
+ }
611
+ // jest --expand
612
+ //
613
+ // Given array of aligned strings with inverse highlight formatting,
614
+ // return joined lines with diff formatting.
615
+ function joinAlignedDiffsExpand(diffs, options) {
616
+ return diffs.map((diff, i, diffs) => {
617
+ const line = diff[1];
618
+ const isFirstOrLast = i === 0 || i === diffs.length - 1;
619
+ switch (diff[0]) {
620
+ case DIFF_DELETE: return printDeleteLine(line, isFirstOrLast, options);
621
+ case DIFF_INSERT: return printInsertLine(line, isFirstOrLast, options);
622
+ default: return printCommonLine(line, isFirstOrLast, options);
623
+ }
624
+ }).join("\n");
625
+ }
626
+
627
+ const noColor = (string) => string;
628
+ const DIFF_CONTEXT_DEFAULT = 5;
629
+ const DIFF_TRUNCATE_THRESHOLD_DEFAULT = 0;
630
+ function getDefaultOptions() {
631
+ return {
632
+ aAnnotation: "Expected",
633
+ aColor: y.green,
634
+ aIndicator: "-",
635
+ bAnnotation: "Received",
636
+ bColor: y.red,
637
+ bIndicator: "+",
638
+ changeColor: y.inverse,
639
+ changeLineTrailingSpaceColor: noColor,
640
+ commonColor: y.dim,
641
+ commonIndicator: " ",
642
+ commonLineTrailingSpaceColor: noColor,
643
+ compareKeys: void 0,
644
+ contextLines: DIFF_CONTEXT_DEFAULT,
645
+ emptyFirstOrLastLinePlaceholder: "",
646
+ expand: false,
647
+ includeChangeCounts: false,
648
+ omitAnnotationLines: false,
649
+ patchColor: y.yellow,
650
+ printBasicPrototype: false,
651
+ truncateThreshold: DIFF_TRUNCATE_THRESHOLD_DEFAULT,
652
+ truncateAnnotation: "... Diff result is truncated",
653
+ truncateAnnotationColor: noColor
654
+ };
655
+ }
656
+ function getCompareKeys(compareKeys) {
657
+ return compareKeys && typeof compareKeys === "function" ? compareKeys : void 0;
658
+ }
659
+ function getContextLines(contextLines) {
660
+ return typeof contextLines === "number" && Number.isSafeInteger(contextLines) && contextLines >= 0 ? contextLines : DIFF_CONTEXT_DEFAULT;
661
+ }
662
+ // Pure function returns options with all properties.
663
+ function normalizeDiffOptions(options = {}) {
664
+ return {
665
+ ...getDefaultOptions(),
666
+ ...options,
667
+ compareKeys: getCompareKeys(options.compareKeys),
668
+ contextLines: getContextLines(options.contextLines)
669
+ };
670
+ }
671
+
672
+ function isEmptyString(lines) {
673
+ return lines.length === 1 && lines[0].length === 0;
674
+ }
675
+ function countChanges(diffs) {
676
+ let a = 0;
677
+ let b = 0;
678
+ diffs.forEach((diff) => {
679
+ switch (diff[0]) {
680
+ case DIFF_DELETE:
681
+ a += 1;
682
+ break;
683
+ case DIFF_INSERT:
684
+ b += 1;
685
+ break;
686
+ }
687
+ });
688
+ return {
689
+ a,
690
+ b
691
+ };
692
+ }
693
+ function printAnnotation({ aAnnotation, aColor, aIndicator, bAnnotation, bColor, bIndicator, includeChangeCounts, omitAnnotationLines }, changeCounts) {
694
+ if (omitAnnotationLines) return "";
695
+ let aRest = "";
696
+ let bRest = "";
697
+ if (includeChangeCounts) {
698
+ const aCount = String(changeCounts.a);
699
+ const bCount = String(changeCounts.b);
700
+ // Padding right aligns the ends of the annotations.
701
+ const baAnnotationLengthDiff = bAnnotation.length - aAnnotation.length;
702
+ const aAnnotationPadding = " ".repeat(Math.max(0, baAnnotationLengthDiff));
703
+ const bAnnotationPadding = " ".repeat(Math.max(0, -baAnnotationLengthDiff));
704
+ // Padding left aligns the ends of the counts.
705
+ const baCountLengthDiff = bCount.length - aCount.length;
706
+ const aCountPadding = " ".repeat(Math.max(0, baCountLengthDiff));
707
+ const bCountPadding = " ".repeat(Math.max(0, -baCountLengthDiff));
708
+ aRest = `${aAnnotationPadding} ${aIndicator} ${aCountPadding}${aCount}`;
709
+ bRest = `${bAnnotationPadding} ${bIndicator} ${bCountPadding}${bCount}`;
710
+ }
711
+ const a = `${aIndicator} ${aAnnotation}${aRest}`;
712
+ const b = `${bIndicator} ${bAnnotation}${bRest}`;
713
+ return `${aColor(a)}\n${bColor(b)}\n\n`;
714
+ }
715
+ function printDiffLines(diffs, truncated, options) {
716
+ return printAnnotation(options, countChanges(diffs)) + (options.expand ? joinAlignedDiffsExpand(diffs, options) : joinAlignedDiffsNoExpand(diffs, options)) + (truncated ? options.truncateAnnotationColor(`\n${options.truncateAnnotation}`) : "");
717
+ }
718
+ // Compare two arrays of strings line-by-line. Format as comparison lines.
719
+ function diffLinesUnified(aLines, bLines, options) {
720
+ const normalizedOptions = normalizeDiffOptions(options);
721
+ const [diffs, truncated] = diffLinesRaw(isEmptyString(aLines) ? [] : aLines, isEmptyString(bLines) ? [] : bLines, normalizedOptions);
722
+ return printDiffLines(diffs, truncated, normalizedOptions);
723
+ }
724
+ // Given two pairs of arrays of strings:
725
+ // Compare the pair of comparison arrays line-by-line.
726
+ // Format the corresponding lines in the pair of displayable arrays.
727
+ function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCompare, options) {
728
+ if (isEmptyString(aLinesDisplay) && isEmptyString(aLinesCompare)) {
729
+ aLinesDisplay = [];
730
+ aLinesCompare = [];
731
+ }
732
+ if (isEmptyString(bLinesDisplay) && isEmptyString(bLinesCompare)) {
733
+ bLinesDisplay = [];
734
+ bLinesCompare = [];
735
+ }
736
+ if (aLinesDisplay.length !== aLinesCompare.length || bLinesDisplay.length !== bLinesCompare.length)
737
+ // Fall back to diff of display lines.
738
+ return diffLinesUnified(aLinesDisplay, bLinesDisplay, options);
739
+ const [diffs, truncated] = diffLinesRaw(aLinesCompare, bLinesCompare, options);
740
+ // Replace comparison lines with displayable lines.
741
+ let aIndex = 0;
742
+ let bIndex = 0;
743
+ diffs.forEach((diff) => {
744
+ switch (diff[0]) {
745
+ case DIFF_DELETE:
746
+ diff[1] = aLinesDisplay[aIndex];
747
+ aIndex += 1;
748
+ break;
749
+ case DIFF_INSERT:
750
+ diff[1] = bLinesDisplay[bIndex];
751
+ bIndex += 1;
752
+ break;
753
+ default:
754
+ diff[1] = bLinesDisplay[bIndex];
755
+ aIndex += 1;
756
+ bIndex += 1;
757
+ }
758
+ });
759
+ return printDiffLines(diffs, truncated, normalizeDiffOptions(options));
760
+ }
761
+ // Compare two arrays of strings line-by-line.
762
+ function diffLinesRaw(aLines, bLines, options) {
763
+ const truncate = options?.truncateThreshold ?? false;
764
+ const truncateThreshold = Math.max(Math.floor(options?.truncateThreshold ?? 0), 0);
765
+ const aLength = truncate ? Math.min(aLines.length, truncateThreshold) : aLines.length;
766
+ const bLength = truncate ? Math.min(bLines.length, truncateThreshold) : bLines.length;
767
+ const truncated = aLength !== aLines.length || bLength !== bLines.length;
768
+ const isCommon = (aIndex, bIndex) => aLines[aIndex] === bLines[bIndex];
769
+ const diffs = [];
770
+ let aIndex = 0;
771
+ let bIndex = 0;
772
+ const foundSubsequence = (nCommon, aCommon, bCommon) => {
773
+ for (; aIndex !== aCommon; aIndex += 1) diffs.push(new Diff(DIFF_DELETE, aLines[aIndex]));
774
+ for (; bIndex !== bCommon; bIndex += 1) diffs.push(new Diff(DIFF_INSERT, bLines[bIndex]));
775
+ for (; nCommon !== 0; nCommon -= 1, aIndex += 1, bIndex += 1) diffs.push(new Diff(DIFF_EQUAL, bLines[bIndex]));
776
+ };
777
+ diffSequences(aLength, bLength, isCommon, foundSubsequence);
778
+ // After the last common subsequence, push remaining change items.
779
+ for (; aIndex !== aLength; aIndex += 1) diffs.push(new Diff(DIFF_DELETE, aLines[aIndex]));
780
+ for (; bIndex !== bLength; bIndex += 1) diffs.push(new Diff(DIFF_INSERT, bLines[bIndex]));
781
+ return [diffs, truncated];
782
+ }
783
+
784
+ // get the type of a value with handling the edge cases like `typeof []`
785
+ // and `typeof null`
786
+ function getType(value) {
787
+ if (value === void 0) return "undefined";
788
+ else if (value === null) return "null";
789
+ else if (Array.isArray(value)) return "array";
790
+ else if (typeof value === "boolean") return "boolean";
791
+ else if (typeof value === "function") return "function";
792
+ else if (typeof value === "number") return "number";
793
+ else if (typeof value === "string") return "string";
794
+ else if (typeof value === "bigint") return "bigint";
795
+ else if (typeof value === "object") {
796
+ if (value != null) {
797
+ if (value.constructor === RegExp) return "regexp";
798
+ else if (value.constructor === Map) return "map";
799
+ else if (value.constructor === Set) return "set";
800
+ else if (value.constructor === Date) return "date";
801
+ }
802
+ return "object";
803
+ } else if (typeof value === "symbol") return "symbol";
804
+ throw new Error(`value of unknown type: ${value}`);
805
+ }
806
+
807
+ // platforms compatible
808
+ function getNewLineSymbol(string) {
809
+ return string.includes("\r\n") ? "\r\n" : "\n";
810
+ }
811
+ function diffStrings(a, b, options) {
812
+ const truncate = options?.truncateThreshold ?? false;
813
+ const truncateThreshold = Math.max(Math.floor(options?.truncateThreshold ?? 0), 0);
814
+ let aLength = a.length;
815
+ let bLength = b.length;
816
+ if (truncate) {
817
+ const aMultipleLines = a.includes("\n");
818
+ const bMultipleLines = b.includes("\n");
819
+ const aNewLineSymbol = getNewLineSymbol(a);
820
+ const bNewLineSymbol = getNewLineSymbol(b);
821
+ // multiple-lines string expects a newline to be appended at the end
822
+ const _a = aMultipleLines ? `${a.split(aNewLineSymbol, truncateThreshold).join(aNewLineSymbol)}\n` : a;
823
+ const _b = bMultipleLines ? `${b.split(bNewLineSymbol, truncateThreshold).join(bNewLineSymbol)}\n` : b;
824
+ aLength = _a.length;
825
+ bLength = _b.length;
826
+ }
827
+ const truncated = aLength !== a.length || bLength !== b.length;
828
+ const isCommon = (aIndex, bIndex) => a[aIndex] === b[bIndex];
829
+ let aIndex = 0;
830
+ let bIndex = 0;
831
+ const diffs = [];
832
+ const foundSubsequence = (nCommon, aCommon, bCommon) => {
833
+ if (aIndex !== aCommon) diffs.push(new Diff(DIFF_DELETE, a.slice(aIndex, aCommon)));
834
+ if (bIndex !== bCommon) diffs.push(new Diff(DIFF_INSERT, b.slice(bIndex, bCommon)));
835
+ aIndex = aCommon + nCommon;
836
+ bIndex = bCommon + nCommon;
837
+ diffs.push(new Diff(DIFF_EQUAL, b.slice(bCommon, bIndex)));
838
+ };
839
+ diffSequences(aLength, bLength, isCommon, foundSubsequence);
840
+ // After the last common subsequence, push remaining change items.
841
+ if (aIndex !== aLength) diffs.push(new Diff(DIFF_DELETE, a.slice(aIndex)));
842
+ if (bIndex !== bLength) diffs.push(new Diff(DIFF_INSERT, b.slice(bIndex)));
843
+ return [diffs, truncated];
844
+ }
845
+
846
+ // Given change op and array of diffs, return concatenated string:
847
+ // * include common strings
848
+ // * include change strings which have argument op with changeColor
849
+ // * exclude change strings which have opposite op
850
+ function concatenateRelevantDiffs(op, diffs, changeColor) {
851
+ return diffs.reduce((reduced, diff) => reduced + (diff[0] === DIFF_EQUAL ? diff[1] : diff[0] === op && diff[1].length !== 0 ? changeColor(diff[1]) : ""), "");
852
+ }
853
+ // Encapsulate change lines until either a common newline or the end.
854
+ class ChangeBuffer {
855
+ op;
856
+ line;
857
+ lines;
858
+ changeColor;
859
+ constructor(op, changeColor) {
860
+ this.op = op;
861
+ this.line = [];
862
+ this.lines = [];
863
+ this.changeColor = changeColor;
864
+ }
865
+ pushSubstring(substring) {
866
+ this.pushDiff(new Diff(this.op, substring));
867
+ }
868
+ pushLine() {
869
+ // Assume call only if line has at least one diff,
870
+ // therefore an empty line must have a diff which has an empty string.
871
+ // If line has multiple diffs, then assume it has a common diff,
872
+ // therefore change diffs have change color;
873
+ // otherwise then it has line color only.
874
+ this.lines.push(this.line.length !== 1 ? new Diff(this.op, concatenateRelevantDiffs(this.op, this.line, this.changeColor)) : this.line[0][0] === this.op ? this.line[0] : new Diff(this.op, this.line[0][1]));
875
+ this.line.length = 0;
876
+ }
877
+ isLineEmpty() {
878
+ return this.line.length === 0;
879
+ }
880
+ // Minor input to buffer.
881
+ pushDiff(diff) {
882
+ this.line.push(diff);
883
+ }
884
+ // Main input to buffer.
885
+ align(diff) {
886
+ const string = diff[1];
887
+ if (string.includes("\n")) {
888
+ const substrings = string.split("\n");
889
+ const iLast = substrings.length - 1;
890
+ substrings.forEach((substring, i) => {
891
+ if (i < iLast) {
892
+ // The first substring completes the current change line.
893
+ // A middle substring is a change line.
894
+ this.pushSubstring(substring);
895
+ this.pushLine();
896
+ } else if (substring.length !== 0)
897
+ // The last substring starts a change line, if it is not empty.
898
+ // Important: This non-empty condition also automatically omits
899
+ // the newline appended to the end of expected and received strings.
900
+ this.pushSubstring(substring);
901
+ });
902
+ } else
903
+ // Append non-multiline string to current change line.
904
+ this.pushDiff(diff);
905
+ }
906
+ // Output from buffer.
907
+ moveLinesTo(lines) {
908
+ if (!this.isLineEmpty()) this.pushLine();
909
+ lines.push(...this.lines);
910
+ this.lines.length = 0;
911
+ }
912
+ }
913
+ // Encapsulate common and change lines.
914
+ class CommonBuffer {
915
+ deleteBuffer;
916
+ insertBuffer;
917
+ lines;
918
+ constructor(deleteBuffer, insertBuffer) {
919
+ this.deleteBuffer = deleteBuffer;
920
+ this.insertBuffer = insertBuffer;
921
+ this.lines = [];
922
+ }
923
+ pushDiffCommonLine(diff) {
924
+ this.lines.push(diff);
925
+ }
926
+ pushDiffChangeLines(diff) {
927
+ const isDiffEmpty = diff[1].length === 0;
928
+ // An empty diff string is redundant, unless a change line is empty.
929
+ if (!isDiffEmpty || this.deleteBuffer.isLineEmpty()) this.deleteBuffer.pushDiff(diff);
930
+ if (!isDiffEmpty || this.insertBuffer.isLineEmpty()) this.insertBuffer.pushDiff(diff);
931
+ }
932
+ flushChangeLines() {
933
+ this.deleteBuffer.moveLinesTo(this.lines);
934
+ this.insertBuffer.moveLinesTo(this.lines);
935
+ }
936
+ // Input to buffer.
937
+ align(diff) {
938
+ const op = diff[0];
939
+ const string = diff[1];
940
+ if (string.includes("\n")) {
941
+ const substrings = string.split("\n");
942
+ const iLast = substrings.length - 1;
943
+ substrings.forEach((substring, i) => {
944
+ if (i === 0) {
945
+ const subdiff = new Diff(op, substring);
946
+ if (this.deleteBuffer.isLineEmpty() && this.insertBuffer.isLineEmpty()) {
947
+ // If both current change lines are empty,
948
+ // then the first substring is a common line.
949
+ this.flushChangeLines();
950
+ this.pushDiffCommonLine(subdiff);
951
+ } else {
952
+ // If either current change line is non-empty,
953
+ // then the first substring completes the change lines.
954
+ this.pushDiffChangeLines(subdiff);
955
+ this.flushChangeLines();
956
+ }
957
+ } else if (i < iLast)
958
+ // A middle substring is a common line.
959
+ this.pushDiffCommonLine(new Diff(op, substring));
960
+ else if (substring.length !== 0)
961
+ // The last substring starts a change line, if it is not empty.
962
+ // Important: This non-empty condition also automatically omits
963
+ // the newline appended to the end of expected and received strings.
964
+ this.pushDiffChangeLines(new Diff(op, substring));
965
+ });
966
+ } else
967
+ // Append non-multiline string to current change lines.
968
+ // Important: It cannot be at the end following empty change lines,
969
+ // because newline appended to the end of expected and received strings.
970
+ this.pushDiffChangeLines(diff);
971
+ }
972
+ // Output from buffer.
973
+ getLines() {
974
+ this.flushChangeLines();
975
+ return this.lines;
976
+ }
977
+ }
978
+ // Given diffs from expected and received strings,
979
+ // return new array of diffs split or joined into lines.
980
+ //
981
+ // To correctly align a change line at the end, the algorithm:
982
+ // * assumes that a newline was appended to the strings
983
+ // * omits the last newline from the output array
984
+ //
985
+ // Assume the function is not called:
986
+ // * if either expected or received is empty string
987
+ // * if neither expected nor received is multiline string
988
+ function getAlignedDiffs(diffs, changeColor) {
989
+ const deleteBuffer = new ChangeBuffer(DIFF_DELETE, changeColor);
990
+ const insertBuffer = new ChangeBuffer(DIFF_INSERT, changeColor);
991
+ const commonBuffer = new CommonBuffer(deleteBuffer, insertBuffer);
992
+ diffs.forEach((diff) => {
993
+ switch (diff[0]) {
994
+ case DIFF_DELETE:
995
+ deleteBuffer.align(diff);
996
+ break;
997
+ case DIFF_INSERT:
998
+ insertBuffer.align(diff);
999
+ break;
1000
+ default: commonBuffer.align(diff);
1001
+ }
1002
+ });
1003
+ return commonBuffer.getLines();
1004
+ }
1005
+
1006
+ function hasCommonDiff(diffs, isMultiline) {
1007
+ if (isMultiline) {
1008
+ // Important: Ignore common newline that was appended to multiline strings!
1009
+ const iLast = diffs.length - 1;
1010
+ return diffs.some((diff, i) => diff[0] === DIFF_EQUAL && (i !== iLast || diff[1] !== "\n"));
1011
+ }
1012
+ return diffs.some((diff) => diff[0] === DIFF_EQUAL);
1013
+ }
1014
+ // Compare two strings character-by-character.
1015
+ // Format as comparison lines in which changed substrings have inverse colors.
1016
+ function diffStringsUnified(a, b, options) {
1017
+ if (a !== b && a.length !== 0 && b.length !== 0) {
1018
+ const isMultiline = a.includes("\n") || b.includes("\n");
1019
+ // getAlignedDiffs assumes that a newline was appended to the strings.
1020
+ const [diffs, truncated] = diffStringsRaw(isMultiline ? `${a}\n` : a, isMultiline ? `${b}\n` : b, true, options);
1021
+ if (hasCommonDiff(diffs, isMultiline)) {
1022
+ const optionsNormalized = normalizeDiffOptions(options);
1023
+ return printDiffLines(getAlignedDiffs(diffs, optionsNormalized.changeColor), truncated, optionsNormalized);
1024
+ }
1025
+ }
1026
+ // Fall back to line-by-line diff.
1027
+ return diffLinesUnified(a.split("\n"), b.split("\n"), options);
1028
+ }
1029
+ // Compare two strings character-by-character.
1030
+ // Optionally clean up small common substrings, also known as chaff.
1031
+ function diffStringsRaw(a, b, cleanup, options) {
1032
+ const [diffs, truncated] = diffStrings(a, b, options);
1033
+ diff_cleanupSemantic(diffs);
1034
+ return [diffs, truncated];
1035
+ }
1036
+
1037
+ function getCommonMessage(message, options) {
1038
+ const { commonColor } = normalizeDiffOptions(options);
1039
+ return commonColor(message);
1040
+ }
1041
+ const { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent } = plugins;
1042
+ const PLUGINS = [
1043
+ ReactTestComponent,
1044
+ ReactElement,
1045
+ DOMElement,
1046
+ DOMCollection,
1047
+ Immutable,
1048
+ AsymmetricMatcher,
1049
+ plugins.Error
1050
+ ];
1051
+ const FORMAT_OPTIONS = {
1052
+ maxDepth: 20,
1053
+ plugins: PLUGINS
1054
+ };
1055
+ const FALLBACK_FORMAT_OPTIONS = {
1056
+ callToJSON: false,
1057
+ maxDepth: 8,
1058
+ plugins: PLUGINS
1059
+ };
1060
+ const DEFAULT_MEMORIZE = (_, v) => v;
1061
+ // Generate a string that will highlight the difference between two values
1062
+ // with green and red. (similar to how github does code diffing)
1063
+ /**
1064
+ * @param a Expected value
1065
+ * @param b Received value
1066
+ * @param options Diff options
1067
+ * @returns {string | null} a string diff
1068
+ */
1069
+ function diff(a, b, options, memorize = DEFAULT_MEMORIZE) {
1070
+ if (Object.is(a, b)) return "";
1071
+ const aType = getType(a);
1072
+ let expectedType = aType;
1073
+ let omitDifference = false;
1074
+ if (aType === "object" && typeof a.asymmetricMatch === "function") {
1075
+ if (a.$$typeof !== Symbol.for("jest.asymmetricMatcher"))
1076
+ // Do not know expected type of user-defined asymmetric matcher.
1077
+ return;
1078
+ if (typeof a.getExpectedType !== "function")
1079
+ // For example, expect.anything() matches either null or undefined
1080
+ return;
1081
+ expectedType = a.getExpectedType();
1082
+ // Primitive types boolean and number omit difference below.
1083
+ // For example, omit difference for expect.stringMatching(regexp)
1084
+ omitDifference = expectedType === "string";
1085
+ }
1086
+ if (expectedType !== getType(b)) {
1087
+ const { aAnnotation, aColor, aIndicator, bAnnotation, bColor, bIndicator } = normalizeDiffOptions(options);
1088
+ const formatOptions = getFormatOptions(FALLBACK_FORMAT_OPTIONS, options);
1089
+ let aDisplay = format(a, formatOptions);
1090
+ let bDisplay = format(b, formatOptions);
1091
+ // even if prettyFormat prints successfully big objects,
1092
+ // large string can choke later on (concatenation? RPC?),
1093
+ // so truncate it to a reasonable length here.
1094
+ // (For example, playwright's ElementHandle can become about 200_000_000 length string)
1095
+ const MAX_LENGTH = 1e5;
1096
+ function truncate(s) {
1097
+ return s.length <= MAX_LENGTH ? s : `${s.slice(0, MAX_LENGTH)}...`;
1098
+ }
1099
+ aDisplay = memorize("expected", truncate(aDisplay));
1100
+ bDisplay = memorize("actual", truncate(bDisplay));
1101
+ return `${`${aColor(`${aIndicator} ${aAnnotation}:`)}\n${aDisplay}`}\n\n${`${bColor(`${bIndicator} ${bAnnotation}:`)}\n${bDisplay}`}`;
1102
+ }
1103
+ if (omitDifference) return;
1104
+ switch (aType) {
1105
+ case "string": return diffLinesUnified(a.split("\n"), b.split("\n"), options);
1106
+ case "boolean":
1107
+ case "number": return comparePrimitive(a, b, options, memorize);
1108
+ case "map": return compareObjects(sortMap(a), sortMap(b), options, memorize);
1109
+ case "set": return compareObjects(sortSet(a), sortSet(b), options, memorize);
1110
+ default: return compareObjects(a, b, options, memorize);
1111
+ }
1112
+ }
1113
+ function createMemorize(memory) {
1114
+ return (pointer, stringifiedValue) => {
1115
+ memory[pointer] = stringifiedValue;
1116
+ return stringifiedValue;
1117
+ };
1118
+ }
1119
+ function comparePrimitive(a, b, options, memorize = DEFAULT_MEMORIZE) {
1120
+ const aFormat = memorize("expected", format(a, FORMAT_OPTIONS));
1121
+ const bFormat = memorize("actual", format(b, FORMAT_OPTIONS));
1122
+ return aFormat === bFormat ? "" : diffLinesUnified(aFormat.split("\n"), bFormat.split("\n"), options);
1123
+ }
1124
+ function sortMap(map) {
1125
+ return new Map(Array.from(map.entries()).sort());
1126
+ }
1127
+ function sortSet(set) {
1128
+ return new Set(Array.from(set.values()).sort());
1129
+ }
1130
+ function compareObjects(a, b, options, memorize = DEFAULT_MEMORIZE) {
1131
+ let difference;
1132
+ let hasThrown = false;
1133
+ try {
1134
+ difference = getObjectsDifference(a, b, getFormatOptions(FORMAT_OPTIONS, options), options, memorize);
1135
+ } catch {
1136
+ hasThrown = true;
1137
+ }
1138
+ const noDiffMessage = getCommonMessage(NO_DIFF_MESSAGE, options);
1139
+ // If the comparison yields no results, compare again but this time
1140
+ // without calling `toJSON`. It's also possible that toJSON might throw.
1141
+ if (difference === void 0 || difference === noDiffMessage) {
1142
+ difference = getObjectsDifference(a, b, getFormatOptions(FALLBACK_FORMAT_OPTIONS, options), options, memorize);
1143
+ if (difference !== noDiffMessage && !hasThrown) difference = `${getCommonMessage(SIMILAR_MESSAGE, options)}\n\n${difference}`;
1144
+ }
1145
+ return difference;
1146
+ }
1147
+ function getDefaultFormatOptions(options) {
1148
+ return getFormatOptions(FORMAT_OPTIONS, options);
1149
+ }
1150
+ function getFormatOptions(formatOptions, options) {
1151
+ const { compareKeys, printBasicPrototype, maxDepth } = normalizeDiffOptions(options);
1152
+ return {
1153
+ ...formatOptions,
1154
+ compareKeys,
1155
+ printBasicPrototype,
1156
+ maxDepth: maxDepth ?? formatOptions.maxDepth
1157
+ };
1158
+ }
1159
+ function getObjectsDifference(a, b, formatOptions, options, memorize = DEFAULT_MEMORIZE) {
1160
+ const formatOptionsZeroIndent = {
1161
+ ...formatOptions,
1162
+ indent: 0
1163
+ };
1164
+ const aCompare = format(a, formatOptionsZeroIndent);
1165
+ const bCompare = format(b, formatOptionsZeroIndent);
1166
+ if (aCompare === bCompare) return getCommonMessage(NO_DIFF_MESSAGE, options);
1167
+ else {
1168
+ const aDisplay = memorize("expected", format(a, formatOptions));
1169
+ const bDisplay = memorize("actual", format(b, formatOptions));
1170
+ return diffLinesUnified2(aDisplay.split("\n"), bDisplay.split("\n"), aCompare.split("\n"), bCompare.split("\n"), options);
1171
+ }
1172
+ }
1173
+ const MAX_DIFF_STRING_LENGTH = 2e4;
1174
+ function isAsymmetricMatcher(data) {
1175
+ return getType$1(data) === "Object" && typeof data.asymmetricMatch === "function";
1176
+ }
1177
+ function isReplaceable(obj1, obj2) {
1178
+ const obj1Type = getType$1(obj1);
1179
+ return obj1Type === getType$1(obj2) && (obj1Type === "Object" || obj1Type === "Array");
1180
+ }
1181
+ function printDiffOrStringify(received, expected, options, memory) {
1182
+ const { aAnnotation, bAnnotation } = normalizeDiffOptions(options);
1183
+ if (typeof expected === "string" && typeof received === "string" && expected.length > 0 && received.length > 0 && expected.length <= MAX_DIFF_STRING_LENGTH && received.length <= MAX_DIFF_STRING_LENGTH && expected !== received) {
1184
+ if (expected.includes("\n") || received.includes("\n")) return diffStringsUnified(expected, received, options);
1185
+ const [diffs] = diffStringsRaw(expected, received);
1186
+ const hasCommonDiff = diffs.some((diff) => diff[0] === DIFF_EQUAL);
1187
+ const printLabel = getLabelPrinter(aAnnotation, bAnnotation);
1188
+ return `${printLabel(aAnnotation) + printExpected(getCommonAndChangedSubstrings(diffs, DIFF_DELETE, hasCommonDiff))}\n${printLabel(bAnnotation) + printReceived(getCommonAndChangedSubstrings(diffs, DIFF_INSERT, hasCommonDiff))}`;
1189
+ }
1190
+ // if (isLineDiffable(expected, received)) {
1191
+ const clonedExpected = deepClone(expected, { forceWritable: true });
1192
+ const { replacedExpected, replacedActual } = replaceAsymmetricMatcher(deepClone(received, { forceWritable: true }), clonedExpected);
1193
+ return diff(replacedExpected, replacedActual, options, memory ? createMemorize(memory) : DEFAULT_MEMORIZE);
1194
+ // }
1195
+ // const printLabel = getLabelPrinter(aAnnotation, bAnnotation)
1196
+ // const expectedLine = printLabel(aAnnotation) + printExpected(expected)
1197
+ // const receivedLine
1198
+ // = printLabel(bAnnotation)
1199
+ // + (stringify(expected) === stringify(received)
1200
+ // ? 'serializes to the same string'
1201
+ // : printReceived(received))
1202
+ // return `${expectedLine}\n${receivedLine}`
1203
+ }
1204
+ function replaceAsymmetricMatcher(actual, expected, actualReplaced = /* @__PURE__ */ new WeakSet(), expectedReplaced = /* @__PURE__ */ new WeakSet()) {
1205
+ // handle asymmetric Error.cause diff
1206
+ if (actual instanceof Error && expected instanceof Error && typeof actual.cause !== "undefined" && typeof expected.cause === "undefined") {
1207
+ delete actual.cause;
1208
+ return {
1209
+ replacedActual: actual,
1210
+ replacedExpected: expected
1211
+ };
1212
+ }
1213
+ if (!isReplaceable(actual, expected)) return {
1214
+ replacedActual: actual,
1215
+ replacedExpected: expected
1216
+ };
1217
+ if (actualReplaced.has(actual) || expectedReplaced.has(expected)) return {
1218
+ replacedActual: actual,
1219
+ replacedExpected: expected
1220
+ };
1221
+ actualReplaced.add(actual);
1222
+ expectedReplaced.add(expected);
1223
+ getOwnProperties(expected).forEach((key) => {
1224
+ const expectedValue = expected[key];
1225
+ const actualValue = actual[key];
1226
+ if (isAsymmetricMatcher(expectedValue)) {
1227
+ if (expectedValue.asymmetricMatch(actualValue))
1228
+ // When matcher matches, replace expected with actual value
1229
+ // so they appear the same in the diff
1230
+ expected[key] = actualValue;
1231
+ else if ("sample" in expectedValue && expectedValue.sample !== void 0 && isReplaceable(actualValue, expectedValue.sample)) {
1232
+ // For container matchers (ArrayContaining, ObjectContaining), unwrap and recursively process
1233
+ // Matcher doesn't match: unwrap but keep structure to show mismatch
1234
+ const replaced = replaceAsymmetricMatcher(actualValue, expectedValue.sample, actualReplaced, expectedReplaced);
1235
+ actual[key] = replaced.replacedActual;
1236
+ expected[key] = replaced.replacedExpected;
1237
+ }
1238
+ } else if (isAsymmetricMatcher(actualValue)) {
1239
+ if (actualValue.asymmetricMatch(expectedValue)) actual[key] = expectedValue;
1240
+ else if ("sample" in actualValue && actualValue.sample !== void 0 && isReplaceable(actualValue.sample, expectedValue)) {
1241
+ const replaced = replaceAsymmetricMatcher(actualValue.sample, expectedValue, actualReplaced, expectedReplaced);
1242
+ actual[key] = replaced.replacedActual;
1243
+ expected[key] = replaced.replacedExpected;
1244
+ }
1245
+ } else if (isReplaceable(actualValue, expectedValue)) {
1246
+ const replaced = replaceAsymmetricMatcher(actualValue, expectedValue, actualReplaced, expectedReplaced);
1247
+ actual[key] = replaced.replacedActual;
1248
+ expected[key] = replaced.replacedExpected;
1249
+ }
1250
+ });
1251
+ return {
1252
+ replacedActual: actual,
1253
+ replacedExpected: expected
1254
+ };
1255
+ }
1256
+ function getLabelPrinter(...strings) {
1257
+ const maxLength = strings.reduce((max, string) => string.length > max ? string.length : max, 0);
1258
+ return (string) => `${string}: ${" ".repeat(maxLength - string.length)}`;
1259
+ }
1260
+ const SPACE_SYMBOL = "·";
1261
+ function replaceTrailingSpaces(text) {
1262
+ return text.replace(/\s+$/gm, (spaces) => SPACE_SYMBOL.repeat(spaces.length));
1263
+ }
1264
+ function printReceived(object) {
1265
+ return y.red(replaceTrailingSpaces(stringify(object)));
1266
+ }
1267
+ function printExpected(value) {
1268
+ return y.green(replaceTrailingSpaces(stringify(value)));
1269
+ }
1270
+ function getCommonAndChangedSubstrings(diffs, op, hasCommonDiff) {
1271
+ return diffs.reduce((reduced, diff) => reduced + (diff[0] === DIFF_EQUAL ? diff[1] : diff[0] === op ? hasCommonDiff ? y.inverse(diff[1]) : diff[1] : ""), "");
1272
+ }
1273
+
1274
+ function processError(_err, diffOptions, seen = /* @__PURE__ */ new WeakSet()) {
1275
+ if (!_err || typeof _err !== "object") return { message: String(_err) };
1276
+ const err = _err;
1277
+ if (err.showDiff || err.showDiff === void 0 && err.expected !== void 0 && err.actual !== void 0) {
1278
+ const options = {
1279
+ ...diffOptions,
1280
+ ...err.diffOptions
1281
+ };
1282
+ err.diff = printDiffOrStringify(err.actual, err.expected, options, err);
1283
+ err.expected = prettifyValue(err.expected, options);
1284
+ err.actual = prettifyValue(err.actual, options);
1285
+ }
1286
+ // some Error implementations may not allow rewriting cause
1287
+ // in most cases, the assignment will lead to "err.cause = err.cause"
1288
+ try {
1289
+ if (!seen.has(err) && typeof err.cause === "object") {
1290
+ seen.add(err);
1291
+ err.cause = processError(err.cause, diffOptions, seen);
1292
+ }
1293
+ } catch {}
1294
+ try {
1295
+ return serializeValue(err);
1296
+ } catch (e) {
1297
+ return serializeValue(/* @__PURE__ */ new Error(`Failed to fully serialize error: ${e?.message}\nInner error message: ${err?.message}`));
1298
+ }
1299
+ }
1300
+ function prettifyValue(value, options) {
1301
+ if (typeof value !== "string") return format(value, getDefaultFormatOptions(options));
1302
+ return value;
1303
+ }
7
1304
 
8
1305
  let _test;
9
1306
  function setCurrentTest(test) {
@@ -1680,7 +2977,7 @@ function formatTitle(template, items, idx) {
1680
2977
  const inspectOptions = { truncate: runner.config.taskTitleValueFormatTruncate };
1681
2978
  const isObjectItem = isObject(items[0]);
1682
2979
  function formatAttribute(s) {
1683
- return s.replace(/\$([$\w.]+)/g, (_, key) => {
2980
+ return s.replace(/\$([$\p{ID_Continue}.]+)/gu, (_, key) => {
1684
2981
  const isArrayKey = /^\d+$/.test(key);
1685
2982
  if (!isObjectItem && !isArrayKey) return `$${key}`;
1686
2983
  const arrayElement = isArrayKey ? objectAttr(items, key) : void 0;
@@ -1697,7 +2994,7 @@ function formatTitle(template, items, idx) {
1697
2994
  formatRegExp,
1698
2995
  // format "%"
1699
2996
  (match) => {
1700
- if (i < count) output += format([match[0], items[i++]], inspectOptions);
2997
+ if (i < count) output += format$1([match[0], items[i++]], inspectOptions);
1701
2998
  else output += match[0];
1702
2999
  },
1703
3000
  // format "$"
@@ -2767,4 +4064,4 @@ function manageArtifactAttachment(attachment) {
2767
4064
  if (attachment.body != null) attachment.bodyEncoding ??= "base64";
2768
4065
  }
2769
4066
 
2770
- export { TestSyntaxError as T, getCurrentSuite as a, createChainable as b, createTaskCollector as c, getHooks as d, getFn as e, afterAll as f, getCurrentTest as g, afterEach as h, aroundAll as i, aroundEach as j, beforeAll as k, beforeEach as l, matchesTags as m, describe as n, it as o, publicCollect as p, onTestFailed as q, onTestFinished as r, startTests as s, recordArtifact as t, suite as u, test as v, validateTags as w, limitConcurrency as x, createTagsFilter as y };
4067
+ export { limitConcurrency as A, shuffle as B, createTagsFilter as C, TestSyntaxError as T, processError as a, printDiffOrStringify as b, createTaskCollector as c, diff as d, getCurrentSuite as e, createChainable as f, getCurrentTest as g, getHooks as h, getFn as i, afterAll as j, afterEach as k, aroundAll as l, matchesTags as m, aroundEach as n, beforeAll as o, publicCollect as p, beforeEach as q, describe as r, startTests as s, it as t, onTestFailed as u, onTestFinished as v, recordArtifact as w, suite as x, test as y, validateTags as z };