本文へ移動
cccskills
無料GitHub で公開

golden-file-conventions

Reference catalog for snapshot / golden file management - naming conventions, directory layout, when to add / update / remove a baseline, sanitization (timestamps, IDs, PII), per-OS / per-runtime variant strategy, and review workflow for snapshot diffs in PRs. Use when designing a snapshot-testing convention or auditing an existing one for drift.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qaスター 13(GitHub 13 + cccskills 0)
連携ツールAWSPlaywright

実行スコア 未検証

インストール方法を見る

含まれるファイル(8)

  • SKILL.md9.3 KB
  • .tessl-plugin/plugin.json487 B
  • evals/mega-baseline-split/criteria.json2.8 KB
  • evals/mega-baseline-split/task.md3.5 KB
  • evals/orphan-pruning/criteria.json2.8 KB
  • evals/orphan-pruning/task.md3.6 KB
  • evals/volatile-baseline/criteria.json3.4 KB
  • evals/volatile-baseline/task.md2.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

golden-file-conventions

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.

When to use

  • A team is starting snapshot-testing on a project.
  • A team has an existing snapshot suite and reviews are slow because of unclear conventions.
  • A developer is unsure when to update a baseline vs. when to fix the regression.
  • A PR review keeps stalling on "is this snapshot diff intentional?"

Naming conventions

Per-test snapshot file

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.

Per-test name within a snapshot file

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.

Per-OS / per-browser variants (visual snapshots)

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.

Directory layout

LayoutWhen 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.

When to add a baseline

Add a snapshot when:

  • A new component / page / output ships and its rendered shape is load-bearing.
  • A bug fix changes a specific output that lacked coverage; the snapshot is the regression-prevention asset.
  • A redesign locked the new design system; refresh all baselines in one PR.

Don't add a snapshot for:

  • Output that's expected to change frequently (e.g. timestamps, randomized IDs). Snapshot the shape, not the volatile values - see Sanitization below.
  • Internal-only rendering paths the user never sees.
  • Test scaffolding output (e.g. test runner banners).

Sanitization (the load-bearing rule)

A snapshot that contains volatile values (timestamps, UUIDs, random IDs, current dates) breaks every run. Sanitize before snapshotting:

Volatile fieldSanitization pattern
TimestampsReplace with a fixed string [TIMESTAMP] or freeze the clock (vi.useFakeTimers()).
UUIDsReplace with [UUID] or seed a deterministic generator.
Auto-increment IDsReplace 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 tokensStrip 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.

Update vs. fix decision tree

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.

Severity tiering

Every snapshot has an implicit severity:

TierBehaviorExamples
CriticalBlocks merge on diff; requires explicit reviewer acceptance.Production-shipped pages; payment flows; auth.
StandardBlocks merge on diff; author can self-approve with a clear PR description.Internal admin tooling; non-shipping experiments.
AdvisorySurfaces 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.

Pruning rules

Remove a snapshot when:

  • The associated test is deleted.
  • The component / page is removed from the product.
  • The snapshot has produced more false positives than real regressions over a 3-month window - it's noise, not signal.

The "test deleted but snapshot remained" cleanup can be automated.

Anti-patterns

Anti-patternWhy it failsFix
Updating snapshots in a separate "snapshot refresh" PRReviewer 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 defaultSnapshots become tautologies; never catch a regression.Update snapshots only in interactive runs; PR CI fails on diff.
Snapshotting raw HTML for componentsBrittle 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 pageA 5kb diff is uninterpretable; reviewers approve to move on.Per-component snapshots; smaller surface = faster review.
Storing snapshots externally without checksumsA 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 tracesStack traces include line numbers that drift with every refactor.Snapshot the error type + message only; strip the trace.
Cross-OS shared snapshotsAnti-aliasing / font / line-ending differences flake the test.Per-OS snapshot suffixes (see naming above).

Review workflow

  1. PR opens with snapshot diff. Reviewer reads the PR title / description first to understand intent.
  2. Reviewer checks each diff cell against the decision tree above.
  3. For unintended diffs: comment with the specific cell + ask for code investigation; do not approve.
  4. For intended diffs: approve; the snapshot becomes the new baseline.
  5. For ambiguous diffs: request a second reviewer; treat as Critical-tier even if labeled Standard.

References

  • ISO/IEC/IEEE 29119 series - formal test-document conventions (cite by stable ID).
  • 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.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

Builds a CI gate that fails the build on **new** WCAG / a11y violations introduced by a PR while grandfathering pre-existing violations on a per-rule / per-page baseline. Aggregates verdicts from axe-core / pa11y / Lighthouse a11y / WAVE / IBM Equal Access scans. Use when a project has accumulated a11y debt and a strict "zero violations" gate would block every PR - the ratchet pattern lets the team ship while preventing regressions.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Workflow skill that builds an A/B-test validity checklist from an experiment proposal, walking the canonical design-correctness gates - pre-registered OEC/power/guardrails, randomization unit + SRM check, assignment integrity, telemetry, peeking discipline, novelty/primacy, post-experiment SRM re-check - into a per-experiment checklist + sign-off form. Use when launching, auditing, or governing an experiment. For pitfall mechanics (guardrails, peeking) see experiment-results-interpreter's references; to read an already-valid result use experiment-results-interpreter; for per-SDK harness tests use experiment-sdk-testing - this gates DESIGN, not SDK code.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

The single install-flow skill: the reference contract for the PWA install flow (installability gate fields, `beforeinstallprompt` handshake, per-platform paths - Android WebAPK / iOS Share menu / Firefox no-op - and the `display-mode` post-install signal, in references/install-flow-reference.md) plus the build-an-X workflow that emits the Add-to-Home-Screen suite. Walks the four-stage timeline, emitting one test per gate cell per [web.dev/articles/install-criteria][install-criteria], the deferred-prompt → `prompt()` → `userChoice` chain per [web.dev/articles/customize-install][customize-install], the iOS Safari manual-metadata branch (`apple-touch-icon`) per [web.dev/learn/pwa/installation][learn-pwa], and the post-install `(display-mode: standalone)` MQ assertion. Output: a Playwright spec with per-stage cells plus a coverage matrix. Use when a PWA's manifest, icons, or install handler change, when install conversion drops at an unknown stage, or when triaging a flaky install assertion.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Build-an-X workflow that uses an LLM to map existing tests to spec sections - given a spec doc + the test suite, the LLM identifies which tests cover which sections, surfaces uncovered sections (gap), and recommends specific tests to add. Output is a coverage matrix per spec ID. Scope is mapping tests that already exist and naming the gaps, not authoring tests for new acceptance criteria. Use when a spec doc and a test suite both exist but nobody can say which requirements are actually covered - before a release sign-off, an audit, or a decision about where to spend the next round of test effort.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Generates tests from natural-language specs (acceptance criteria, user stories, requirements) using an LLM, with confidence scoring per test case (LLM self-assessment plus heuristics: assertion quality, naming, completeness), batching uncertain cases for human review, and integration with the team's existing test framework. Use when the user asks to generate unit tests from acceptance criteria, convert user stories to test cases, automate test creation from requirements, or augment a spec-driven test suite with AI-generated stubs that are then curated before merge.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Configures Allure Report (test-runner adapter install, `allure-results` directory wiring, `categories.json` for failure classification, `history-trend.json` retention via the copy-history-between-runs pattern), runs the Allure CLI to convert `allure-results` to a static HTML site, and uploads the report as a CI artifact. Use when the team needs richer test reporting than JUnit XML - step-level attachments, per-test history, retry tracking, and severity / epic / feature labeling across framework-agnostic adapters (pytest, Jest, JUnit, TestNG, NUnit, Mocha). As a rich static HTML report generator, it is the open-source alternative to the sunset ExtentReports (JVM/.NET per-test HTML narrative); for hosted cross-run flakiness analytics rather than a static per-run report use currents-integration.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

testland のスキルをすべて見る

このスキルの問題を報告する