@vitest/utils 4.0.16 → 4.1.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.
Files changed (2) hide show
  1. package/dist/diff.js +14 -2
  2. package/package.json +2 -2
package/dist/diff.js CHANGED
@@ -2149,11 +2149,23 @@ function replaceAsymmetricMatcher(actual, expected, actualReplaced = new WeakSet
2149
2149
  const actualValue = actual[key];
2150
2150
  if (isAsymmetricMatcher(expectedValue)) {
2151
2151
  if (expectedValue.asymmetricMatch(actualValue)) {
2152
- actual[key] = expectedValue;
2152
+ // When matcher matches, replace expected with actual value
2153
+ // so they appear the same in the diff
2154
+ expected[key] = actualValue;
2155
+ } else if ("sample" in expectedValue && expectedValue.sample !== undefined && isReplaceable(actualValue, expectedValue.sample)) {
2156
+ // For container matchers (ArrayContaining, ObjectContaining), unwrap and recursively process
2157
+ // Matcher doesn't match: unwrap but keep structure to show mismatch
2158
+ const replaced = replaceAsymmetricMatcher(actualValue, expectedValue.sample, actualReplaced, expectedReplaced);
2159
+ actual[key] = replaced.replacedActual;
2160
+ expected[key] = replaced.replacedExpected;
2153
2161
  }
2154
2162
  } else if (isAsymmetricMatcher(actualValue)) {
2155
2163
  if (actualValue.asymmetricMatch(expectedValue)) {
2156
- expected[key] = actualValue;
2164
+ actual[key] = expectedValue;
2165
+ } else if ("sample" in actualValue && actualValue.sample !== undefined && isReplaceable(actualValue.sample, expectedValue)) {
2166
+ const replaced = replaceAsymmetricMatcher(actualValue.sample, expectedValue, actualReplaced, expectedReplaced);
2167
+ actual[key] = replaced.replacedActual;
2168
+ expected[key] = replaced.replacedExpected;
2157
2169
  }
2158
2170
  } else if (isReplaceable(actualValue, expectedValue)) {
2159
2171
  const replaced = replaceAsymmetricMatcher(actualValue, expectedValue, actualReplaced, expectedReplaced);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/utils",
3
3
  "type": "module",
4
- "version": "4.0.16",
4
+ "version": "4.1.0-beta.1",
5
5
  "description": "Shared Vitest utility functions",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -82,7 +82,7 @@
82
82
  ],
83
83
  "dependencies": {
84
84
  "tinyrainbow": "^3.0.3",
85
- "@vitest/pretty-format": "4.0.16"
85
+ "@vitest/pretty-format": "4.1.0-beta.1"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@jridgewell/trace-mapping": "0.3.31",