Skip to content

Commit

Permalink
jest-snapshot: Fix regression in diff for jest-snapshot-seriali… (#9419)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrottimark authored and SimenB committed Jan 16, 2020
1 parent 17f6c83 commit c8c4c4e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/jest-snapshot/src/printSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,18 @@ export const printSnapshotAndReceived = (
const aLines2 = a.split('\n');
const bLines2 = b.split('\n');

const aLines0 = dedentLines(aLines2);
// Fall through to fix a regression for custom serializers
// like jest-snapshot-serializer-raw that ignore the indent option.
const b0 = serialize(received, 0);
if (b0 !== b) {
const aLines0 = dedentLines(aLines2);

if (aLines0 !== null) {
// Compare lines without indentation.
const bLines0 = serialize(received, 0).split('\n');
return diffLinesUnified2(aLines2, bLines2, aLines0, bLines0, options);
if (aLines0 !== null) {
// Compare lines without indentation.
const bLines0 = b0.split('\n');

return diffLinesUnified2(aLines2, bLines2, aLines0, bLines0, options);
}
}

// Fall back because:
Expand Down

0 comments on commit c8c4c4e

Please sign in to comment.