Jest
Snapshots Commands
Use snapshot testing to detect unexpected UI or data changes. Jest captures output and compares against stored snapshots, making it easy to catch regressions.
4 commands
Pro Tips
Use 'jest --updateSnapshot' or press 'u' in watch mode to update snapshots after intentional changes.
Prefer 'toMatchInlineSnapshot()' for small outputs — keeps expected values visible right in the test file.
Use snapshot serializers to remove volatile data like timestamps and IDs before snapshotting.
Common Mistakes
Don't blindly update snapshots. Review changes in 'jest --updateSnapshot' to ensure they're intentional.
Large snapshots are hard to review and easy to approve without reading. Keep snapshots focused and small.