Testing
Test commands
# Run all tests across the monorepopnpm test
# Run tests for a specific packagepnpm --filter @jarvis/api-gateway test
# Typecheck all packagespnpm typecheckTest policy
Every bug fix requires a regression test. Every new API endpoint requires at least one test. pnpm test must pass before any commit.
Test placement
- Unit tests: co-located with source (
foo.ts→foo.test.ts) - Integration tests:
packages/<name>/src/__tests__/ - All test files:
.test.tsextension
What we test
| Layer | Test type | Key files |
|---|---|---|
| Archetype configs | Unit | packages/core/src/archetypes/configs.test.ts |
| Formatters | Unit | packages/core/src/formatters.test.ts |
| Assessment engine | Unit + integration | packages/api-gateway/src/lib/assessment.test.ts |
| Policy evaluator | Unit | packages/api-gateway/src/lib/policy-evaluator.test.ts |
| API routes | Integration | packages/api-gateway/src/__tests__/ |
Running specific test suites
# Run only api-gateway testscd packages/api-gateway && pnpm test
# Run with watch mode (development)cd packages/api-gateway && pnpm test --watch
# Run with coveragecd packages/api-gateway && pnpm test --coverageTest data
Test fixtures live in packages/api-gateway/src/__tests__/fixtures/. Do not use production API keys in tests. The test environment uses a dedicated Supabase project.