DEV Community

loading...

Discussion on: Jest Snapshot Testing for React Components is useless? Is it slowly dying? 🧐🤔😐

Collapse
barakplasma profile image
Michael Salaverry

I think snapshot testing is good for testing single components like your example anchor component.

Especially when the typical alternative is writing many selectors and expectations by hand.

Using snapshots to test the root element of an entire SPA is a mistake since snapshot update fatigue is real, but that doesn't make snapshots useless.

That being said, there are visual regression testing tools worth looking into as a replacement for jest snapshots.

Thread Thread
destro_mas profile image
Shahjada Talukdar Author

The example is actually just a placeholder. But let's assume it as a bigger component and then the snapshot will be very big and if we change the component and generate snapshot again, the diff will be very big too.

Also, Doing visual snapshot testing can be a good thing and can also get potential UI bugs. And tools like Percy can be a good replacement.