Skip to content

Commit

Permalink
fix: properly diff when using legacy UI with toRender matcher (#2432)
Browse files Browse the repository at this point in the history
This fixes two problems with diff outputs when using `toRender` with
legacy UI:
- Firstly we had flipped actual and expected causing confusing output
- Secondly we were diffing not just the content but also the rest of the
response object unnecessarily
  • Loading branch information
FrederikBolding authored May 27, 2024
1 parent 5e6db9d commit 00a9587
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/snaps-jest/src/matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ const toRenderLegacy: MatcherFunction<[expected: Component]> = function (
// This is typed as `string | null`, but in practice it's always a string.
// The function only returns `null` if both the expected and actual values
// are numbers, bigints, or booleans, which is never the case here.
const difference = diff(actual, expectedElement) as string;
const difference = diff(expectedElement, content) as string;

const message = pass
? () =>
Expand Down

0 comments on commit 00a9587

Please sign in to comment.