What is approval testing?

Answer

Approval testing (golden master testing) is a testing technique that captures the complete output of a system (a "golden master") and compares subsequent runs against it, failing if anything changes. Similar to snapshot testing but for larger, more complex outputs (entire documents, API responses, rendered HTML, serialized objects). Process: (1) Run the system once, capture output. (2) Review and approve it as correct. (3) Subsequent runs compare against the approved output — any diff fails the test. (4) When an intentional change is made, re-approve the new output. Tools: ApprovalTests (multi-language library), Verify (C# — excellent), jest-snapshot. Best for: testing legacy code without tests (characterization testing), testing complex output structures, serialization, generated code, HTML templates. Advantages: fast to write for complex outputs, catches any change. Pitfalls: same as snapshot tests — diffs must be reviewed carefully, not blindly approved. Combine with Diff tools for readable approval reviews.