Skip to content

feat(tdd-from-schema): generate response schema snapshot tests#98

Merged
PAMulligan merged 1 commit into
mainfrom
47-add-snapshot-testing-for-generated-api-response-schemas
May 19, 2026
Merged

feat(tdd-from-schema): generate response schema snapshot tests#98
PAMulligan merged 1 commit into
mainfrom
47-add-snapshot-testing-for-generated-api-response-schemas

Conversation

@PAMulligan
Copy link
Copy Markdown
Contributor

Summary

  • Adds snapshot test generation to the tdd-from-schema skill so every generated suite captures response body keys, full normalized bodies, headers, and error envelopes — catching added/removed/renamed fields that status-code assertions miss.
  • Introduces normalizeForSnapshot / responseShape / snapshotHeaders helpers that strip UUIDs and ISO timestamps so snapshots stay stable across runs without losing schema-drift detection.
  • Uses toMatchInlineSnapshot() for contract-critical bits (top-level keys, error codes, headers) so breakage shows up in the test file at code-review time, and toMatchSnapshot() for full normalized bodies stored under tests/routes/__snapshots__/.
  • Documents the vitest -u workflow for intentional contract changes and updates the skill's Output table to list the new artifacts.

Closes #47

Test plan

  • Run /build-from-schema end-to-end against a sample OpenAPI spec and confirm *.snapshot.test.ts files are emitted per resource
  • Verify generated snapshot tests fail in RED (no handlers) alongside the rest of the suite
  • Confirm snapshots are created on first GREEN run and subsequent runs pass
  • Intentionally change a response shape and confirm pnpm vitest run -u regenerates snapshots cleanly
  • CI passes on this branch

🤖 Generated with Claude Code

Add snapshot test patterns to the tdd-from-schema skill so generated
test suites capture response body shape, headers, and error envelopes.
This catches added/removed fields and renamed keys that status-code
assertions miss.

- Add normalizeForSnapshot / responseShape / snapshotHeaders helpers
  that strip UUIDs and ISO timestamps so snapshots stay stable
- New Step 7 emits a *.snapshot.test.ts file per resource using
  toMatchInlineSnapshot for contract-critical bits (key lists, error
  codes, headers) and toMatchSnapshot for full normalized bodies
- Document vitest -u workflow for intentional contract changes
- Update Output table to list snapshot test files and __snapshots__/

Closes #47

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@PAMulligan PAMulligan linked an issue May 19, 2026 that may be closed by this pull request
6 tasks
@github-actions github-actions Bot added the area: skills Claude Code skills label May 19, 2026
@PAMulligan PAMulligan self-assigned this May 19, 2026
@PAMulligan PAMulligan moved this from Todo to Done in PMDS Open Source Roadmap May 19, 2026
@PAMulligan PAMulligan merged commit b7c8436 into main May 19, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: skills Claude Code skills

Projects

Development

Successfully merging this pull request may close these issues.

Add snapshot testing for generated API response schemas

1 participant