React snapshot tests - discussion

github logo ・1 min read

Recently i spent some time looking more into snapshot tests, and wondering on usefulness of full rendered ones.

If we use shallow renderer, subcomponents will stay as is and won't be replaced with their rendered version, in full renderer they will.

This means that any change in subcomponent will break parent component test and snapshot needs to be recreated. In system still in development, this can happen quite often. These snapshots are also much larger, therefore harder to review.

So I am interested to hear others opinion on them, how and how much are you using them and how useful do you find them?

twitter logo DISCUSS (2)
markdown guide
 

Snapshot tests can be misused. You should check this article by Kent C. Dodds (the author of React Testing Library and the Testing JavaScript course) where he shares some recommendations on how to make them effective: kentcdodds.com/blog/effective-snap...

 

Thank you Guillermo. I saw this post already, and it is a really good article. I really appreciate you posting it.

Classic DEV Post from Apr 4

What's an awesome VS Code extension you recently installed?

I just came across a simple yet awesome VS Code extension tonight care of Elija...

Kristijan Pajtasev profile image
Software developer with interest in all parts of CS, specially into UI and ML at the moment. Outside of CS I am total outdoor person and currently i am trying to learn piano and german.