Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

pi/agent/skills/testing/references/snapshot-testing.md

Raw
Rendered preview

Snapshots / approved output

Also: approval tests, golden files/masters, reference-output comparisons. Characterization describes a purpose, not necessarily snapshots.

  • Fit: consumer-visible formats, protocols, generated files/data, text whose representation matters.
  • Review initial baselines against intent, requirements, or independent examples. Recording current output ≠ validating it.
  • Keep output focused, readable, deterministic. Stabilize inputs; normalize only irrelevant variation.
  • Keep semantic checks where multiple representations are valid. Do not accidentally mandate irrelevant ordering, whitespace, or prose.
  • Snapshots describe selected examples, not the whole input domain.

Failed comparison

  1. Inspect the diff; identify why output changed.
  2. Compare with authorized intent and consumer contracts.
  3. Fix regressions; regenerate only justified intentional changes.
  4. Review the complete affected baseline diff, including removals and normalization.
  5. Rerun relevant comparisons and behavioral checks; disclose unresolved differences.

No bulk refresh to silence failures. Generated ≠ approved. Follow existing approval requirements, not a new ceremony.

During curation, replace repetitive field assertions with focused approved output where cases remain protected. Replace internal dumps with meaningful output or semantic checks. Keep targeted safety/protocol assertions when clearer. Appearance-dependent acceptance → use the visual-verification skill. Snapshot changes may invalidate mutation history.

Sources

# Snapshots / approved output

Also: approval tests, golden files/masters, reference-output comparisons.
Characterization describes a purpose, not necessarily snapshots.

- Fit: consumer-visible formats, protocols, generated files/data, text whose representation matters.
- Review initial baselines against intent, requirements, or independent examples.
  Recording current output ≠ validating it.
- Keep output focused, readable, deterministic.
  Stabilize inputs; normalize only irrelevant variation.
- Keep semantic checks where multiple representations are valid.
  Do not accidentally mandate irrelevant ordering, whitespace, or prose.
- Snapshots describe selected examples, not the whole input domain.

## Failed comparison

1. Inspect the diff; identify why output changed.
2. Compare with authorized intent and consumer contracts.
3. Fix regressions; regenerate only justified intentional changes.
4. Review the complete affected baseline diff, including removals and normalization.
5. Rerun relevant comparisons and behavioral checks; disclose unresolved differences.

No bulk refresh to silence failures.
Generated ≠ approved.
Follow existing approval requirements, not a new ceremony.

During curation, replace repetitive field assertions with focused approved output where cases remain protected.
Replace internal dumps with meaningful output or semantic checks.
Keep targeted safety/protocol assertions when clearer.
Appearance-dependent acceptance → use the visual-verification skill.
Snapshot changes may invalidate mutation history.

## Sources

- [ApprovalTests](https://approvaltests.com/)
- [Jest: review and scoped updates](https://jestjs.io/docs/snapshot-testing)