Create the live Claude Code test file with six test cases that exercise CliProcess against the real claude binary. Tests gate on binary availability and credential presence, assert on event stream structure only (never on LLM-generated text), and run serially.
Requirements
- Create
src/__tests__/live/claude.live.test.ts
- Entire suite must be gated in
beforeAll using describe.skipIf(!claudeAvailable || !hasCredentials) — no test should fail if prerequisites are absent
- Use
collectLive() and assertEventStreamStructure() from Phase 1 helpers
- Implement six test cases:
- Golden path: trivial prompt (
"respond with exactly the word hello"), call assertEventStreamStructure(), assert DoneEvent.usage.inputTokens > 0 and usage.outputTokens > 0
- ReadyEvent fields: assert
ReadyEvent.sessionId is a non-empty string and ReadyEvent.model is truthy
- Session resume: two sequential runs; second run uses
isFirstMessage: false with sessionId from first run's DoneEvent; assert second ReadyEvent.sessionId matches captured ID; assert no ErrorEvent in either run
- AbortSignal mid-run: prompt for a long response, abort after
ReadyEvent is received; assert final event is ErrorEvent { code: 'aborted' }
- OAuth auth path: skip individually if
CLAUDE_CODE_OAUTH_TOKEN not present; run with only OAuth token in subprocess env; assert no ErrorEvent
- API key auth path: skip individually if
ANTHROPIC_API_KEY not present; run with only API key in subprocess env; assert no ErrorEvent
- Each test must set
maxTimeout: 60 on ProcessOptions to prevent zombie processes
- Tests must never assert on specific generated text content
Design Guidance
Implements the 'Claude Live Test Suite' section of the architecture design. The six test cases, their prompt strings, assertion strategies, and gating patterns are fully specified in the architecture's component design table for claude.live.test.ts. The credential isolation approach (removing unused credential from subprocess env) is documented in the architecture's auth path coverage section.
Acceptance Criteria
Dependencies
Phase 1
Create the live Claude Code test file with six test cases that exercise
CliProcessagainst the realclaudebinary. Tests gate on binary availability and credential presence, assert on event stream structure only (never on LLM-generated text), and run serially.Requirements
src/__tests__/live/claude.live.test.tsbeforeAllusingdescribe.skipIf(!claudeAvailable || !hasCredentials)— no test should fail if prerequisites are absentcollectLive()andassertEventStreamStructure()from Phase 1 helpers"respond with exactly the word hello"), callassertEventStreamStructure(), assertDoneEvent.usage.inputTokens > 0andusage.outputTokens > 0ReadyEvent.sessionIdis a non-empty string andReadyEvent.modelis truthyisFirstMessage: falsewithsessionIdfrom first run'sDoneEvent; assert secondReadyEvent.sessionIdmatches captured ID; assert noErrorEventin either runReadyEventis received; assert final event isErrorEvent { code: 'aborted' }CLAUDE_CODE_OAUTH_TOKENnot present; run with only OAuth token in subprocess env; assert noErrorEventANTHROPIC_API_KEYnot present; run with only API key in subprocess env; assert noErrorEventmaxTimeout: 60onProcessOptionsto prevent zombie processesDesign Guidance
Implements the 'Claude Live Test Suite' section of the architecture design. The six test cases, their prompt strings, assertion strategies, and gating patterns are fully specified in the architecture's component design table for
claude.live.test.ts. The credential isolation approach (removing unused credential from subprocess env) is documented in the architecture's auth path coverage section.Acceptance Criteria
npm run test:livewith no credentials set shows all Claude live tests as skipped (not failed)npm run test:livewith validANTHROPIC_API_KEYruns all six tests and they passReadyEvent, at least oneTextEvent, and exactly oneDoneEventReadyEvent.sessionIdmatches first run'sDoneEvent.sessionIdtype === 'error'andcode === 'aborted'CLAUDE_CODE_OAUTH_TOKENis absentDependencies
Phase 1