DEV Community

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

Collapse
 
dacko_m profile image
Dragan Malinović

Finally someone said it, and I am not feeling like the only one who thinks like this. I have no big experience in writing tests for react, but I wanted to learn it, and wrote a few snapshot tests and I got the same conclusion. I simply dont see the point of snapshot testing, because, if component is changed that probably means that I changed it for a reason, and I would regenerate all the snapshots, anyway.

The only thing that makes me think that this testing makes sense is if for example you update react itself or some other libraries that are maybe generating components. So they render components differently. But then again, I would probably just update snapshots. 🤔

Collapse
 
dorshinar profile image
Dor Shinar

Yes exactly. Plus updating a snapshot solved all the problems in the test - what if there are 2 faults? A regular test would contain 2 expects that will fail independently, and fixing one might not be enough.