Approval testing
Assert hard-to-specify output by reviewing a human-readable snapshot once, approving it, then failing on any later diff. Use when the correct result is easy to recognize but tedious to write as explicit assertions.From its SKILL.md
npx -y skills add Amey-Thakur/AI-SKILLS --skill approval-testingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 23 days oldThe repository was created 23 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
2.8 KB, 595 tokens by cl100k_base, as published. Nobody here has run it
Approval testing
Some outputs resist hand-written assertions: a rendered invoice, a generated
SQL query, a serialized object graph, an ASCII report. Spelling out every
field in assertEquals is brittle to write and unreadable afterward.
Approval testing inverts the flow: the code prints its result, a human reads
it once and approves it, and the framework guards that approved value from
then on.
Method
- Emit output in a stable, diffable format. Serialize to sorted JSON, pretty-printed text, or a canonical string. Unstable key order or trailing whitespace turns every run into a false diff, so normalize before you write.
- Split into received and approved files. The run writes
invoice.received.txt; the test compares it toinvoice.approved.txt. A missing or mismatched approved file fails the test. Tools like ApprovalTests, Verify, syrupy, or insta manage this pair for you. - Review the received file like a pull request. Read it line by line and decide whether every value is correct. This review is the actual assertion; skimming it defeats the method. Wrong output you approve is wrong output you have now locked in.
- Approve by promoting received to approved. Rename or run the approve command, then commit the approved file. It now lives in version control as the reviewed specification of the output.
- Wire a readable diff reporter. Configure the framework to open a diff viewer on mismatch so the change is obvious at a glance. A wall of "line 417 differs" trains people to re-approve blindly.
- Scrub nondeterminism before comparison. Replace timestamps, GUIDs, temp paths, and random ids with fixed sentinel values. Anything that changes run to run must be masked, or the approval never stabilizes.
- Review approved-file changes in code review. A diff to an
.approvedfile in a pull request is a behavior change. Treat an unexplained one as a red flag, the same as a suspicious source edit.
Litmus tests
- When output changes, does the diff show a human exactly what moved and let them accept or reject it in seconds?
- Is every run's received file byte-identical given the same input, with all volatile values masked?
- Would a reviewer notice an incorrect value slipping into an approved file during code review?
Boundaries
Approval testing shines when output is large and recognition is easy; for a rule expressible in one line, a plain assertion is clearer and defer to unit-test-design. For screenshots specifically, use visual-regression-testing, which handles image thresholds this text-oriented method cannot.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.