Search⌘ K

Creating Snapshots

Explore how to create and manage snapshot tests in Jest to verify UI consistency. Understand how Jest generates snapshots as artifacts for reference, how to use serializers for different frameworks, and leverage snapshot matchers for effective test assertions. This lesson helps you ensure your user interface remains accurate and stable throughout development.

Managing the snapshot

After writing a snapshot test, Jest will create the snapshot on the first run and store it for future reference. Snapshots should be committed to any version control systems being used, such as GitHub or GitLabs. Because they represent the expected current element tree making up a user interface, all developers need to be referencing the same tree to accurately know whether or not their current tree passes the test.

Additional tooling

An additional package is required to write snapshot tests, and different client-side frameworks require different packages to do so. A list is included below for the three most popular client-side frameworks, but we are referencing ...