React snapshot tests - discussion

chriss profile image Kristijan Pajtasev ・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?


Editor guide
voluntadpear profile image
Guillermo Peralta Scura

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...

chriss profile image
Kristijan Pajtasev Author

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