Files
taskgraph_ts/tasks/implementation/setup/test-infrastructure.md
glm-5.1 167dde68f4 feat(setup/test-infrastructure): configure Vitest with shared test fixtures and helpers
- Add test:coverage script and @vitest/coverage-v8 dev dependency
- Update vitest.config.ts with @/ path alias and v8 coverage config
- Create test/fixtures/graphs.ts with 5 fixture graphs (linearChain,
  diamond, mixedCategory, cyclic, largeGraph) and createTaskGraph helper
- Expand graph.test.ts with 26 fixture validation tests
- 30 tests passing, CI-compatible output (vitest run)
2026-04-27 10:48:35 +00:00

2.7 KiB

id, name, status, depends_on, scope, risk, impact, level
id name status depends_on scope risk impact level
setup/test-infrastructure Configure test runner and shared test fixtures completed
setup/project-init
narrow low project implementation

Description

Set up the test infrastructure: configure Vitest (or chosen runner), create shared test fixtures and helpers for graph construction that all downstream test files will use. This avoids every test file building graphs from scratch.

Acceptance Criteria

  • Test runner configured in package.json scripts ("test", "test:watch", "test:coverage")
  • Vitest config (or equivalent) exists with ESM support and TypeScript path resolution
  • Shared test fixture file created (e.g., test/fixtures/graphs.ts) with:
    • A simple linear chain graph (3-4 tasks, A→B→C→D)
    • A diamond dependency graph (A→B, A→C, B→D, C→D)
    • A graph with mixed categorical fields (some assessed, some null)
    • A graph with cycles for testing cycle detection
    • A larger graph (20+ nodes) for performance/bottleneck testing
  • Helper function to create a TaskGraph from TaskInput[] for one-liner test setup
  • Test runner executes successfully against placeholder test files
  • CI-compatible output format (no watch mode in default script)

References

  • docs/architecture/build-distribution.md — test directory structure
  • docs/architecture/graph-model.md — graph construction examples for fixtures

Notes

  • Added @vitest/coverage-v8@^3.2.4 as a dev dependency to support npm run test:coverage
  • createTaskGraph() builds a graphology DirectedGraph directly using graph.import() (bulk construction per architecture recommendation) with deterministic edge keys (source->target) and default qualityRetention: 0.9
  • The @/ path alias resolves to src/ for convenient test imports of source modules
  • Cycle detection uses hasCycle() from graphology-dag (standalone function, not a method on the graph instance)
  • All fixture types (TaskInput, TaskGraphNodeAttributes, etc.) are defined inline until the schema module is implemented

Summary

Configured Vitest test infrastructure and created shared test fixtures for graph construction.

  • Modified: package.json (added test:coverage script, @vitest/coverage-v8 dev dependency)
  • Modified: vitest.config.ts (added @/ path alias, include pattern, coverage config with v8 provider)
  • Modified: test/graph.test.ts (expanded with 26 fixture validation tests)
  • Created: test/fixtures/graphs.ts (shared fixtures: linearChain, diamond, mixedCategory, cyclic, largeGraph + createTaskGraph helper + allGraphs/allTasks convenience exports)
  • Tests: 30, all passing (5 placeholder + 25 fixture validation + 1 retained placeholder)