Should I Commit Jest Snapshots?

Should I Commit Jest Snapshots?

Should snapshot files be committed? # Yes, all snapshot files should be committed alongside the modules they are covering and their tests. They should be considered part of a test, similar to the value of any other assertion in Jest.

Are snapshot tests worth it?

Snapshot tests are easy to create and maintain, and they are a great way to check that your application's behavior isn't changing unexpectedly during development. However, they're not a replacement for unit and functional tests, which verify that an application is working correctly, not just that it hasn't changed.

When should you not use snapshot test?

Bad usages of Snapshots

One of the cases, when snapshots provide more trouble than value, is when they are the only assertion in the test. Later on, when the test breaks the developers have little to none information what actually is tested, and should the snapshot be updated or there is really a bug in the code.

Sophia Al-Mansoor
Author

Sophia Al-Mansoor

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.