Skip to content

Commit 27fcd0b

Browse files
committed
test(diff): Add regression test for large images.
1 parent eb3dfa6 commit 27fcd0b

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

__tests__/integration.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,5 +306,20 @@ describe('toMatchImageSnapshot', () => {
306306

307307
expect(diffExists(customSnapshotIdentifier)).toBe(false);
308308
});
309+
310+
it('handles diffs for large images', () => {
311+
const largeImageData = fs.readFileSync(fromStubs('LargeTestImage.png'));
312+
const largeFailureImageData = fs.readFileSync(fromStubs('LargeTestImageFailure.png'));
313+
const customSnapshotIdentifier = getIdentifierIndicatingCleanupIsRequired();
314+
// First we need to write a new snapshot image
315+
expect(
316+
() => expect(largeImageData).toMatchImageSnapshot({ customSnapshotIdentifier })
317+
).not.toThrowError();
318+
319+
// then test against a different image
320+
expect(
321+
() => expect(largeFailureImageData).toMatchImageSnapshot({ customSnapshotIdentifier })
322+
).toThrow(/Expected image to match or be a close match/);
323+
});
309324
});
310325
});

__tests__/stubs/LargeTestImage.png

456 KB
Loading
442 KB
Loading

0 commit comments

Comments
 (0)