/qa-test-data:golden-file-conventionsfrom qa-test-data
Establishes conventions for snapshot/golden-file tests: naming, directory layout, per-OS variants, sanitization, and PR review workflow. Use when snapshots are noisy, untrusted, or lack clear rules.
Ships in qa-test-data. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Terminology note: "golden file" / "golden master" are practitioner-emergent terms popularized by the Working Effectively with Legacy Code tradition. ISTQB has no canonical entry - the closest formal term is "snapshot test." This catalog uses both interchangeably; assume "golden file" and "snapshot" mean the same thing in the rest of the body.
A reference catalog for how to manage snapshot / golden files. It supplies the conventions that active snapshot-management workflows follow when updating / pruning golden files.
Most snapshot frameworks (Jest, Vitest, pytest-snapshot, RSpec Snapshot) use a path adjacent to the test file:
src/
components/
Button.tsx
Button.test.tsx
__snapshots__/
Button.test.tsx.snap
Convention: one snapshot file per test file, named
<test-file-name>.snap. Do not split snapshots across multiple
files per test.
Inside a .snap file, each snapshot is keyed by <describe> >
<it> chain:
exports[`Button renders with primary variant 1`] = `<button class="primary">...</button>`;
The trailing 1 is the snapshot index when one test takes multiple
snapshots - keep these to a minimum (≤3 per test); beyond that,
split the test.
For visual / screenshot-based snapshots, the name carries the
platform suffix (per playwright-snapshots, in the qa-visual-regression plugin):
Button-primary-1-chromium-linux.png
Button-primary-1-firefox-linux.png
Button-primary-1-webkit-darwin.png
OS / browser suffixes are load-bearing - anti-aliasing and font metrics differ. Don't strip them.
| Layout | When to use |
|---|---|
Adjacent (__snapshots__/ next to test) | Default. Reviewer sees the diff in the same PR view as the test. |
Centralized (tests/__fixtures__/) | Cross-test fixtures (golden inputs reused by many tests). |
External (s3://snapshots-bucket/) | Visual snapshots that are large; CI uploads / downloads. Common with Percy, Chromatic, Playwright + S3. |
Default to adjacent. Centralized only when fixtures are reused. External only when artifact size makes adjacent impractical.
Add a snapshot when:
Don't add a snapshot for:
A snapshot that contains volatile values (timestamps, UUIDs, random IDs, current dates) breaks every run. Sanitize before snapshotting:
| Volatile field | Sanitization pattern |
|---|---|
| Timestamps | Replace with a fixed string [TIMESTAMP] or freeze the clock (vi.useFakeTimers()). |
| UUIDs | Replace with [UUID] or seed a deterministic generator. |
| Auto-increment IDs | Replace with [ID] or use a sequence-controlled fixture. |
File paths (/var/folders/...) | Replace with [PATH] or normalize via project root. |
| Memory addresses (object refs) | Avoid in serialized output; use a custom serializer. |
| User-data tokens | Strip before snapshotting; tokens shouldn't be in the test surface anyway. |
Most frameworks support custom serializers / matchers - use them.
Jest's expect.any(Date) matcher pattern is canonical:
expect(result).toMatchSnapshot({
createdAt: expect.any(Date),
uuid: expect.any(String),
});
The serializer normalizes volatile fields before comparison,
so the snapshot shows Any<Date> rather than a specific timestamp.
When a snapshot diff appears in a PR:
Is the diff explained by code changes in the same PR?
├── No → REGRESSION; fix the code, do not update the snapshot.
└── Yes → Did the diff align with the intent (described in the PR title)?
├── No → REGRESSION (cascade from an unrelated change); investigate before updating.
└── Yes → Is the diff isolated to the components the PR is supposed to change?
├── No → INVESTIGATE: a CSS / token / shared-component change affected unrelated snapshots.
└── Yes → UPDATE: run `--update-snapshots` and commit.
The most common review failure is rubber-stamping snapshot updates - accepting a 47-component diff because the PR title says "Refactor Button". A snapshot-diff classifier can implement this decision tree.
Every snapshot has an implicit severity:
| Tier | Behavior | Examples |
|---|---|---|
| Critical | Blocks merge on diff; requires explicit reviewer acceptance. | Production-shipped pages; payment flows; auth. |
| Standard | Blocks merge on diff; author can self-approve with a clear PR description. | Internal admin tooling; non-shipping experiments. |
| Advisory | Surfaces diff but doesn't block. | Unstable areas under active redesign; new baselines during ramp-up. |
Promote Advisory → Standard after ~2 weeks of stability. Promote Standard → Critical for security-sensitive surfaces.
Remove a snapshot when:
The "test deleted but snapshot remained" cleanup can be automated.
| Anti-pattern | Why it fails | Fix |
|---|---|---|
| Updating snapshots in a separate "snapshot refresh" PR | Reviewer can't see the code change that justifies the diff. | Always update snapshots in the same PR as the source change. |
--update-snapshots in PR CI as the default | Snapshots become tautologies; never catch a regression. | Update snapshots only in interactive runs; PR CI fails on diff. |
| Snapshotting raw HTML for components | Brittle to attribute-order changes from tooling upgrades. | Snapshot the React / Vue / Svelte component tree (e.g. react-test-renderer), not raw HTML; OR use a normalizer. |
| One mega-snapshot per page | A 5kb diff is uninterpretable; reviewers approve to move on. | Per-component snapshots; smaller surface = faster review. |
| Storing snapshots externally without checksums | A drift in S3 vs. the test code makes "what changed?" hard. | Include checksums in the test code; verify on each run. |
| Snapshots of error messages with stack traces | Stack traces include line numbers that drift with every refactor. | Snapshot the error type + message only; strip the trace. |
| Cross-OS shared snapshots | Anti-aliasing / font / line-ending differences flake the test. | Per-OS snapshot suffixes (see naming above). |
playwright-snapshots - visual-snapshot-specific naming and per-OS suffix conventions.visual-baseline-conventions - broader visual-coverage conventions; this skill is the
text/object-snapshot equivalent.evals/mega-baseline-split/criteria.json (opens in a new tab)evals/mega-baseline-split/task.md (opens in a new tab)evals/orphan-pruning/criteria.json (opens in a new tab)evals/orphan-pruning/task.md (opens in a new tab)evals/volatile-baseline/criteria.json (opens in a new tab)evals/volatile-baseline/task.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
12 skills in this plugin
/boundary-value-generatorUse when writing or extending tests for a function, form field or endpoint with limits (min/max values, string length in characters or bytes, collection size), or after a bug at a limit, such as a maximum-length value rejected or a too-short one accepted: generates the boundary-value cases, one below, at and above each bound, plus one representative per equivalence class, and emits them as parameterized tests (pytest @parametrize, Jest test.each, xUnit InlineData)./faker-dataFixes test data that breaks tests - factory values in a shape the code under test rejects (a phone number that is not E.164), fixtures that only pass when the whole suite runs in order, and random values that make an assertion pass or fail depending on the run. Authors test-data factories with Faker: the Python `faker` library, the `@faker-js/faker` JS port, and the `faker-ruby` gem - install per language, the provider catalogue (person / internet / location / date / finance / lorem), locale selection and multi-locale mode, and seed-based determinism for reproducible runs. Scope is generating fresh values for tests that start from nothing, not replacing values inside a dataset that already holds real records - that goes to pii-masking-pipeline-builder. Use when fixtures need realistic values, a stable shape, or a fixed seed./malicious-payload-bankUse when writing negative tests for input validation, fuzz targets or security tests that need real attack strings: SQL injection, XSS, SSRF, path traversal, command injection, XXE, prototype pollution, ReDoS, Unicode confusables and header injection, with which payloads fit each input context./msw-handlersUse when JavaScript or TypeScript tests need to mock fetch or XHR calls to an HTTP API, such as replacing hand-rolled fetch mocks or testing loading and error responses, in Vitest or Jest and in Cypress or Playwright: writes Mock Service Worker handlers (`http.get`, `http.post`, `HttpResponse.json`), wires `setupServer` (Node) or `setupWorker` (browser), and manages the `listen` / `resetHandlers` / `close` lifecycle./negative-test-generatorUse when code has deliberate error paths but the tests only prove the success case. For each happy-path test, generates parameterized tests for validation errors, missing fields, wrong types, authorization failures, rate limits, conflicts and attack payloads in the project's test runner format./pairwise-test-case-generatorUse when a function or endpoint takes 3 or more inputs whose combinations matter and the full Cartesian product is too large. Combines boundary values, equivalence classes and pairwise (or N-wise) reduction into parameterized cases in the project's runner format.npx claudepluginhub testland/qa --plugin qa-test-dataOther plugins' skills for the same job