Skip to content

Phase 1: Test infrastructure — live vitest config and shared helpers #4

Description

@tinkermonkey

Establish the foundational infrastructure that all live tests depend on: a dedicated vitest configuration for live tests, an npm script to invoke it, and a shared helper module with collection and assertion utilities. No actual live tests are written in this phase — this is the scaffolding.

Requirements

  • Add vitest.config.live.ts targeting src/__tests__/live/**/*.live.test.ts with 120s per-test timeout, maxConcurrency: 1, and pool: 'forks'
  • The existing vitest.config.ts include pattern (src/**/*.test.ts) must continue to exclude all *.live.test.ts files — confirm mutual exclusivity
  • Add "test:live": "vitest run --config vitest.config.live.ts" to package.json scripts
  • Create src/__tests__/live/ directory (empty, ready for test files)
  • Create src/__tests__/helpers/live-helpers.ts exporting:
    • collectLive(backend, options): Promise<ClaudeEvent[]> — drains the async generator from CliProcess.run()
    • assertEventStreamStructure(events: ClaudeEvent[]): void — asserts presence of ReadyEvent/TextEvent/DoneEvent, zero error events, seq monotonicity, ReadyEvent/DoneEvent sessionId match
    • A credential-gating helper that returns { claudeAvailable, hasCredentials } for use in describe.skipIf calls
  • npm run test:live with no test files present must exit with code 0 (no tests found is not a failure)
  • npm test must not pick up any files from src/__tests__/live/

Design Guidance

Implements the 'Dual-Track Test Architecture' (ADR-001) and 'Live Test Helper Module' sections of the architecture design. The vitest config values (120s timeout, maxConcurrency: 1, retry: 0) are specified in the architecture. The assertEventStreamStructure function body is fully specified in the architecture's Component Design section.

Acceptance Criteria

  • npm run test:live exits 0 with output indicating no test files found
  • npm test output confirms zero files from src/__tests__/live/ were executed
  • src/__tests__/helpers/live-helpers.ts compiles under tsconfig.test.json with no type errors
  • collectLive() and assertEventStreamStructure() are exported and importable from live test files
  • package.json contains test:live script pointing to vitest.config.live.ts
  • Code is reviewed and approved

Metadata

Metadata

Assignees

No one assigned

    Labels

    repair-cycle:failedRepair cycle failed, manual intervention required

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions