Day 9 of 60
·
Unit, integration, contract
Snapshot / golden-master
The fastest way to lock down output that should not change, and the fastest way to make every PR a five-line ceremony of accepted snapshots if you're not careful.
ProblemOutput formats and complex object graphs change unintentionally.
How it works
First run records the output; future runs compare. Useful for serialization, rendered HTML, generated code.
What it catches
Unintended output drift. Becomes a maintenance burden if every change rewrites snapshots, use sparingly on stable surfaces.
Tools
Jest snapshots · OSS Approval Tests · OSS syrupy (pytest) · OSS
Verdict by project size
Small
Opt
Medium
Rec
Large
Rec
Extra-large
Rec
Cost
| Project size | Setup | Maint / mo | Tool / mo | CI / run |
|---|---|---|---|---|
| Small <10k LOC | 2h | 1h | $0 | +0.5m |
| Medium 10–100k LOC | 4h | 4h | $0 | +1m |
| Large 100k–1M LOC | 2d | 15h | $0 | +3m |
| Extra-large >1M LOC | 5d | 50h | $0 | +8m |
Setup = engineer-days to first useful run ·
Maint = engineer-hours / month at steady state ·
Tool = out-of-pocket $ / month ·
CI = minutes added (or saved) per pipeline run
Lifecycle & ownership
When in lifecycle
Code Test
Per pull request · Runs in CI on every PR; gates merge.
Who owns it
Developer
Authoring + the inner loop
Collaborates with: QA / Test Engineer
Reference implementations
-
ApprovalTests Python
Golden-master and approval testing patterns for stable output surfaces.
-
Jest snapshot testing docs
Official snapshot workflow for UI, serialization, and output regression checks.
-
ApprovalTests Java
Approval-testing implementation for golden-master validation on the JVM.
Quick check
Snapshot/golden-master testing is risky when applied to…
One question. Pick the best answer. Your streak is saved locally on this device.
Save the lesson
Download SVG ↓Screenshot for a 1:1, drop it in Slack, or download the SVG.