DEV Community

Discussion on: Why I've Stopped Writing Snapshots Tests in Jest

Collapse
 
frontendwizard profile image
Juliano Rafael

I couldn't agree more.

The thing with snapshots is that they are indeed useful to detect the impact of your UI changes across your components. The problem is that we overuse this to the point where we stop doing actual assertions and only do snapshots, which break every time anything changes and definitely put you into the "just update" mindset.

For now, I'm certainly moving towards more descriptive and precise assertions other than snapshotting everything. We certainly should be writing more tests following the @testing-library/react approach and doing more assertions with jest-dom matchers. This leads to more readable tests and less false alarms in your test suits.