Skip to content

feat: snapshot-style fixture recording by test ID (closes #155)#157

Merged
jpr5 merged 3 commits intomainfrom
feat/snapshot-recording
May 6, 2026
Merged

feat: snapshot-style fixture recording by test ID (closes #155)#157
jpr5 merged 3 commits intomainfrom
feat/snapshot-recording

Conversation

@jpr5
Copy link
Copy Markdown
Contributor

@jpr5 jpr5 commented May 5, 2026

Summary

When X-Test-Id is present, recorded fixtures are organized by test instead of timestamps:

fixtures/recorded/
  agent-chat--handles-tool-call/
    openai.json
  agent-chat--streams-correctly/
    openai.json
  • Slugified test IDs as directory names — readable, grepable, stable across runs
  • Merge-append on re-run — new fixtures join existing ones in the same file
  • Timestamp fallback when no X-Test-Id or empty slug — backwards compatible
  • Path traversal safe — slugifier strips all dangerous characters
  • Corrupted file recovery — invalid JSON silently replaced

Closes #155 — feature request by @jantimon

Test plan

  • pnpm test — 2769 passed, 36 skipped
  • npx tsc --noEmit — clean
  • pnpm run lint / pnpm run format:check — clean
  • CR converged (R1: 1 finding already fixed, R2: 0 findings, 7 agents per round)
  • Adversarial review: all 6 issue asks verified delivered

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 5, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@157

commit: e1d4604

@jpr5 jpr5 self-assigned this May 5, 2026
@jantimon
Copy link
Copy Markdown

jantimon commented May 5, 2026

amazing 🤩

shot-QnoThc6q@2x

I guess the replacement of > is not necessary but everything else looks really good

for my project I also stripped out the .spec.ts file extension

@jpr5 jpr5 force-pushed the feat/snapshot-recording branch from 9d260cc to 4019808 Compare May 5, 2026 21:51
jpr5 added 3 commits May 5, 2026 15:16
When X-Test-Id is present, recorded fixtures save to
<fixturePath>/<slugified-testId>/<provider>.json instead of
timestamp-based filenames. Slugifier strips test file prefixes
(.spec.ts, .test.tsx, .e2e.js), treats both Unicode › and ASCII >
as hierarchy separators (double-dash). Multiple fixtures for same
test+provider merge into one file. Falls back to timestamps when
no testId or slug is empty. Closes #155 (@jantimon).
21 tests covering slugifyTestId (13 unit: separators, special chars,
file extension stripping, ASCII > handling, edge cases) and snapshot
integration (8: directory creation, merge, isolation, timestamp
fallback, append-on-rerun, corrupted file recovery, empty slug
fallback).
Dedicated section in record-replay docs. Info-box on fixtures page.
Snapshot example on examples page with Playwright setup and directory
layout. Changelog credits @jantimon (issue #155).
@jpr5 jpr5 force-pushed the feat/snapshot-recording branch from 4019808 to e1d4604 Compare May 5, 2026 22:16
@jpr5 jpr5 merged commit a44f73f into main May 6, 2026
22 checks passed
@jpr5 jpr5 deleted the feat/snapshot-recording branch May 6, 2026 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Better Recording File Organisation

2 participants