Blog
Approval Tests: Snapshot The Contract, Not The Noise
Approval tests capture output and ask a reviewer to approve a diff. They are powerful for reports, serializers, compilers, and legacy behavior. They are terrible when a team updates snapshots without reading them.
Remove Accidental Noise
Normalize generated IDs, timestamps, unstable map order, and environment paths only when those values are not part of contract. Otherwise every run changes and real differences disappear in confetti.
Keep approved files small enough to inspect. Split a giant report by meaningful section rather than blessing 20,000 lines.
Pair With Focused Assertions
A snapshot shows broad change. A focused assertion explains a critical invariant. Use both when one amount or status must never drift unnoticed.
Reviewers must understand why output changed and regenerate through a documented command. “Update all snapshots” is not validation; it is deleting alarms with extra steps.
Store approved output in a reviewable text format when possible. Binary snapshots hide the meaningful change behind tooling. If the real artifact is binary, derive a stable semantic representation for review and keep one focused integration check for the encoder itself.
That keeps the diff useful during ordinary code review.