Jest React Snapshot
Snapshot react components as images in jest tests
Usage
; expect.extend; it"renders component matching snapshot", ;
See repo test for more details.
Advanced Usage
Uses jest-image-snapshot
to power the image snapshot and diffing functionality.
Supports the toMatchImageSnapshot
API, providing some default configuration.
;
await expectComponent /.imageToMatchSnapshotcustomOptions;
Test Environment Setup
Easiest way is to use jest-puppeeter
which provides sensible defaults for your testing environment.
Example Jest Config
"jest":
Further Work
- Replace
puppeteer
with lighter renderer as only theHTML
andCSS
layout engine is used.