@vitest/utils 0.34.4 → 0.34.5

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/dist/diff.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { CompareKeys } from 'pretty-format';
1
+ import { D as DiffOptions } from './types-f5c02aaf.js';
2
+ export { a as DiffOptionsColor } from './types-f5c02aaf.js';
3
+ import 'pretty-format';
2
4
 
3
5
  /**
4
6
  * Diff Match and Patch
@@ -52,35 +54,6 @@ declare class Diff {
52
54
  constructor(op: number, text: string);
53
55
  }
54
56
 
55
- /**
56
- * Copyright (c) Meta Platforms, Inc. and affiliates.
57
- *
58
- * This source code is licensed under the MIT license found in the
59
- * LICENSE file in the root directory of this source tree.
60
- */
61
-
62
- type DiffOptionsColor = (arg: string) => string;
63
- interface DiffOptions {
64
- aAnnotation?: string;
65
- aColor?: DiffOptionsColor;
66
- aIndicator?: string;
67
- bAnnotation?: string;
68
- bColor?: DiffOptionsColor;
69
- bIndicator?: string;
70
- changeColor?: DiffOptionsColor;
71
- changeLineTrailingSpaceColor?: DiffOptionsColor;
72
- commonColor?: DiffOptionsColor;
73
- commonIndicator?: string;
74
- commonLineTrailingSpaceColor?: DiffOptionsColor;
75
- contextLines?: number;
76
- emptyFirstOrLastLinePlaceholder?: string;
77
- expand?: boolean;
78
- includeChangeCounts?: boolean;
79
- omitAnnotationLines?: boolean;
80
- patchColor?: DiffOptionsColor;
81
- compareKeys?: CompareKeys;
82
- }
83
-
84
57
  /**
85
58
  * Copyright (c) Meta Platforms, Inc. and affiliates.
86
59
  *
@@ -117,4 +90,4 @@ declare function diffStringsRaw(a: string, b: string, cleanup: boolean): Array<D
117
90
  */
118
91
  declare function diff(a: any, b: any, options?: DiffOptions): string | null;
119
92
 
120
- export { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, DiffOptions, DiffOptionsColor, diff, diffLinesRaw, diffLinesUnified, diffLinesUnified2, diffStringsRaw, diffStringsUnified };
93
+ export { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, DiffOptions, diff, diffLinesRaw, diffLinesUnified, diffLinesUnified2, diffStringsRaw, diffStringsUnified };
package/dist/error.d.ts CHANGED
@@ -1,5 +1,8 @@
1
+ import { D as DiffOptions } from './types-f5c02aaf.js';
2
+ import 'pretty-format';
3
+
1
4
  declare function serializeError(val: any, seen?: WeakMap<object, any>): any;
2
- declare function processError(err: any): any;
5
+ declare function processError(err: any, diffOptions?: DiffOptions): any;
3
6
  declare function replaceAsymmetricMatcher(actual: any, expected: any, actualReplaced?: WeakSet<object>, expectedReplaced?: WeakSet<object>): {
4
7
  replacedActual: any;
5
8
  replacedExpected: any;
package/dist/error.js CHANGED
@@ -72,7 +72,7 @@ function serializeError(val, seen = /* @__PURE__ */ new WeakMap()) {
72
72
  function normalizeErrorMessage(message) {
73
73
  return message.replace(/__vite_ssr_import_\d+__\./g, "");
74
74
  }
75
- function processError(err) {
75
+ function processError(err, diffOptions) {
76
76
  if (!err || typeof err !== "object")
77
77
  return { message: err };
78
78
  if (err.stack)
@@ -83,7 +83,7 @@ function processError(err) {
83
83
  const clonedActual = deepClone(err.actual, { forceWritable: true });
84
84
  const clonedExpected = deepClone(err.expected, { forceWritable: true });
85
85
  const { replacedActual, replacedExpected } = replaceAsymmetricMatcher(clonedActual, clonedExpected);
86
- err.diff = diff(replacedExpected, replacedActual);
86
+ err.diff = diff(replacedExpected, replacedActual, diffOptions);
87
87
  }
88
88
  if (typeof err.expected !== "string")
89
89
  err.expected = stringify(err.expected, 10);
@@ -0,0 +1,32 @@
1
+ import { CompareKeys } from 'pretty-format';
2
+
3
+ /**
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ type DiffOptionsColor = (arg: string) => string;
11
+ interface DiffOptions {
12
+ aAnnotation?: string;
13
+ aColor?: DiffOptionsColor;
14
+ aIndicator?: string;
15
+ bAnnotation?: string;
16
+ bColor?: DiffOptionsColor;
17
+ bIndicator?: string;
18
+ changeColor?: DiffOptionsColor;
19
+ changeLineTrailingSpaceColor?: DiffOptionsColor;
20
+ commonColor?: DiffOptionsColor;
21
+ commonIndicator?: string;
22
+ commonLineTrailingSpaceColor?: DiffOptionsColor;
23
+ contextLines?: number;
24
+ emptyFirstOrLastLinePlaceholder?: string;
25
+ expand?: boolean;
26
+ includeChangeCounts?: boolean;
27
+ omitAnnotationLines?: boolean;
28
+ patchColor?: DiffOptionsColor;
29
+ compareKeys?: CompareKeys;
30
+ }
31
+
32
+ export { DiffOptions as D, DiffOptionsColor as a };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/utils",
3
3
  "type": "module",
4
- "version": "0.34.4",
4
+ "version": "0.34.5",
5
5
  "description": "Shared Vitest utility functions",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",