DEV Community

Ankit Utekar
Ankit Utekar

Posted on

2 1

When to snapshot ?

I am having hard time understanding valid use cases for Jest snapshot testing.
There are lots of opinionated posts explaining snapshot testing.
Have you used snapshot tests in your projects ? If yes, for what kind of components (functional vs stateful with lots of logic, components that are edited frequently vs components that aren't)? If no, why?

Top comments (1)

Collapse
 
ryancraigmartin profile image
Ryan Craig Martin

It depends on what kind of testing you are planning on doing. For instance I am currently using Jest to test the API gateway for a microservices architecture at my company and using snapshots to validate responses from GraphQL.

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay