← ClaudeAtlas

e2e-agent-testinglisted

Strategy for mocking Claude Code agents in E2E tests with canary validation against real behavior.
kookr-ai/kookr · ★ 2 · Testing & QA · score 78
Install: claude install-skill kookr-ai/kookr
# E2E Agent Testing Strategy ## When to Use - Writing or modifying E2E tests that involve Claude Code agents - Deciding whether to mock agent behavior or use a real agent - Adding new hook event types or changing the event contract - Reviewing test cost and speed trade-offs ## Core Principle: Mock by Default, Verify with Canary **Most E2E tests should mock Claude Code** using `FakeTerminalBackend` and event injection. One opt-in **canary test** validates that mocks match real Claude Code behavior. If Claude Code changes its hook event format, the canary test breaks first, the mock fixtures get updated, and all other tests stay accurate. ``` ┌─────────────────────────────────────────────────────┐ │ e2e/canary.spec.ts (CANARY=1, real Claude + Haiku) │ │ Validates: mock event shapes match real behavior │ │ Runs: locally before merge (PR checklist item) │ └──────────────────────┬──────────────────────────────┘ │ if drift detected, update ↓ ┌──────────────────────▼──────────────────────────────┐ │ e2e/fixtures/mock-events.ts │ │ Source of truth for mock hook events │ │ Used by: all E2E tests + unit tests │ └──────────────────────┬──────────────────────────────┘ │ imported by ↓ ┌──────────────────────▼──────────────────────────────┐ │ e2e/kookr.spec.ts (fast, no real Claude) │ │ Uses: FakeTerminalBackend + inject-event endpoint │ │ Runs: every PR,