Skip to content

feat: per-test sequence isolation via X-Test-Id header#93

Merged
jpr5 merged 3 commits intomainfrom
feature/test-id-isolation
Apr 8, 2026
Merged

feat: per-test sequence isolation via X-Test-Id header#93
jpr5 merged 3 commits intomainfrom
feature/test-id-isolation

Conversation

@AlemTuzlak
Copy link
Copy Markdown
Contributor

Summary

  • Adds X-Test-Id header (and ?testId= query param fallback) to scope sequenceIndex counters per test, enabling parallel test execution against a shared aimock instance
  • Changes Journal.fixtureMatchCounts from Map<Fixture, number> to a nested Map<string, Map<Fixture, number>> keyed by testId, with a backwards-compatible getter for the default scope
  • Updates all 12 HTTP handler locations and 3 WebSocket handlers to extract testId and pass per-test counter maps
  • Adds resetMatchCounts(testId?) to the LLMock public API — with testId clears only that test's counters, without clears all

Zero breaking changes — requests without X-Test-Id use "__default__" scope, identical to current behavior.

Test plan

  • 9 new tests: 4 Journal unit tests + 4 integration tests (parallel isolation, backwards compat, query param fallback, Anthropic cross-provider) + 1 resetMatchCounts(testId) test
  • Full suite: 2035 tests pass, 0 failures
  • Lint and format clean

Journal.fixtureMatchCounts now nested Map<string, Map<Fixture, number>>
keyed by testId. Requests with X-Test-Id header (or ?testId= query param)
get isolated sequence counters. Requests without use "__default__" scope
(backwards compatible). resetMatchCounts(testId?) selectively or globally
clears counters.
Extract testId via getTestId(req) in every handler, pass per-test
counter maps to matchFixture, thread testId to incrementFixtureMatchCount.
WebSocket handlers receive testId via defaults from upgrade request.
Journal unit tests (4), integration tests covering parallel isolation,
backwards compat, query param fallback, Anthropic cross-provider,
selective reset, header-over-query precedence, global reset.
@jpr5 jpr5 force-pushed the feature/test-id-isolation branch from a028097 to c3a5678 Compare April 8, 2026 23:12
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 8, 2026

Open in StackBlitz

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

commit: c3a5678

Copy link
Copy Markdown
Contributor

@jpr5 jpr5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zero source code bugs found in Round 1. Clean implementation — all 15 handlers wired consistently, backwards compatible, no race conditions.

Rebased on current main (post PR #88, #89, #92), redone as 3 clean commits. Internal docs removed. Added 2 missing test cases (header-over-query precedence, global resetMatchCounts integration). 11 tests, 2104 full suite pass.

🤖 Reviewed with Claude Code

@jpr5 jpr5 merged commit 465860f into main Apr 8, 2026
18 checks passed
@jpr5 jpr5 deleted the feature/test-id-isolation branch April 8, 2026 23:14
@jpr5 jpr5 mentioned this pull request Apr 8, 2026
5 tasks
jpr5 added a commit that referenced this pull request Apr 8, 2026
## Summary

- **Per-test sequence isolation** via `X-Test-Id` header — each test
gets its own fixture match counters across all 12 HTTP + 3 WebSocket
handlers (#93)
- **Combined content + toolCalls** in fixture responses — new
`ContentWithToolCallsResponse` type across OpenAI Chat, Responses,
Anthropic Messages, and Gemini with stream collapse support (#92)
- **OpenRouter reasoning_content** support (#88)
- **Clean URLs** for docs site — all pages restructured as directories,
.html extensions removed from links
- Fix `web_search_call` items to use `action.query` matching real OpenAI
API (#89)
- Bump aimock-pytest to 0.3.0

## Version bumps
- `package.json`: 1.8.0 → 1.9.0
- `pyproject.toml`: 0.2.0 → 0.3.0
- `Chart.yaml` appVersion: 1.8.0 → 1.9.0
- `plugin.json` / `marketplace.json`: 1.8.0 → 1.9.0

## Test plan
- [x] All 2206 tests pass (including 80 new clean-URL validation tests)
- [x] Build passes
- [x] Prettier clean
- [ ] npm publish triggers automatically on merge via OIDC workflow
- [ ] Verify v1.9.0 appears on npm after merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

2 participants