All glossary terms
Verify

Snapshot testing

Snapshot testing captures the serialised output of a function or component (rendered HTML, formatted JSON, computed data structure) and compares against a committed baseline on every run. Differences fail the test until the developer either fixes the code or accepts the new snapshot. Most associated with Jest, but supported broadly.

Snapshot testing is fast to write and excellent for catching unintended changes to structured output — a refactor that should be behaviour-preserving but accidentally changes rendered markup. The trade-off is signal quality: snapshots that frequently legitimately change train developers to accept-snapshot blindly, defeating the test's purpose. Healthy use: snapshot stable outputs (component renders, formatted reports), keep snapshots small (focused on one assertion), and review snapshot updates carefully in PRs. The anti-pattern is large monolithic snapshots updated on every PR without scrutiny.

Related terms