Skip to content

Commit

Permalink
test(diff): Add regression test for large images.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaelan committed Feb 1, 2020
1 parent eb3dfa6 commit 27fcd0b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions __tests__/integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,20 @@ describe('toMatchImageSnapshot', () => {

expect(diffExists(customSnapshotIdentifier)).toBe(false);
});

it('handles diffs for large images', () => {
const largeImageData = fs.readFileSync(fromStubs('LargeTestImage.png'));
const largeFailureImageData = fs.readFileSync(fromStubs('LargeTestImageFailure.png'));
const customSnapshotIdentifier = getIdentifierIndicatingCleanupIsRequired();
// First we need to write a new snapshot image
expect(
() => expect(largeImageData).toMatchImageSnapshot({ customSnapshotIdentifier })
).not.toThrowError();

// then test against a different image
expect(
() => expect(largeFailureImageData).toMatchImageSnapshot({ customSnapshotIdentifier })
).toThrow(/Expected image to match or be a close match/);
});
});
});
Binary file added __tests__/stubs/LargeTestImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __tests__/stubs/LargeTestImageFailure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 27fcd0b

Please sign in to comment.