DEV Community

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

Collapse
 
destro_mas profile image
Shahjada Talukdar

Thanks for your opinion!

But what do you think about the example I gave in this Article?
Do you think snapshot testing is good for this kind of case?

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

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.