| document_id | doc.testing | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| last_verified | 2026-02-19 | ||||||||||||||||||||
| tokens_estimate | 900 | ||||||||||||||||||||
| tags |
|
||||||||||||||||||||
| anchors |
|
||||||||||||||||||||
| ttl_expires_on |
Anchors: SYSTEM_ARCHITECTURE.md, user-workflows-reference.md
- INVARIANT: Tests use Vitest; jsdom for React components
- INVARIANT: Contract and integration tests are source of truth; E2E augments
- INVARIANT: DB tests use in-memory SQLite or mock adapter
- INVARIANT: Tests assert product outcomes from user-workflows-reference.md and user-stories.md
| Command | Purpose |
|---|---|
npm run test |
Run full suite once |
npm run test:watch |
Watch mode |
npm run test:coverage |
Coverage report (v8) |
npm run test:planning |
Planning LLM tests (mock allowed) |
npm run test:planning:e2e |
Planning E2E (trading card marketplace) |
npm run test:e2e:project-to-cards |
Full flow: create project → idea → cards for 2+ workflows |
npm run test:e2e:adaptive |
Adaptive E2E flows |
npm run test:db |
DB adapter and migration tests |
__tests__/
├── setup.ts # @testing-library/jest-dom
├── lib/
│ ├── mock-db-adapter.ts # Shared mock DbAdapter
│ ├── create-test-db.ts # Test DB helpers
│ ├── memory/ # ingestion, retrieval, harvest, store, snapshots
│ ├── llm/ # stream-action-parser, planning fixtures
│ └── ruvector-* # RuVector client tests
├── components/ # workflow-block, activity-column, implementation-card, etc.
├── api/ # projects, map, actions, chat-stream, orchestration
├── mutations/ # apply-action, pipeline
├── orchestration/ # create-run, trigger-build, approval-gates, etc.
├── schemas/ # slice-b, slice-c, core-planning
├── hooks/ # use-submit-action, use-map-snapshot, etc.
└── e2e/ # project-to-cards-flow, adaptive-flows, trading-card-marketplace-planning
- Use
lib/mock-db-adapter.tsfor unit tests that need DB - In-memory SQLite for integration tests via
createTestDb()(when available)
- Set
PLANNING_MOCK_ALLOWED=1to skip real API calls - Use
__tests__/llm/planning-fixtures.tsfor gold/adversarial examples
@testing-library/react,@testing-library/user-eventsetup.tsimports@testing-library/jest-dom/vitest
- Gate with
describe.skipIf(!ruvectorAvailable || !sqliteAvailable) - Each test block sets
DOSSIER_DATA_DIRto a unique temp dir (fs.mkdtempSync) to prevent parallel file contention onvectors.db - Clean up:
delete process.env.DOSSIER_DATA_DIRinafterEach - Timeout: 30s per test (model download from HuggingFace competes for bandwidth in parallel runs)
- Reset: call
resetRuvectorForTesting()inbeforeEachto clear the client singleton
- Provider: v8
- Reporters: text, html
- Run
npm run test:coveragefor report
Tests assert the following product invariants (from user-workflows-reference.md):
| Outcome | Test Location |
|---|---|
| Build requires finalized_at + approved planned files | trigger-build.test.ts |
| Build rejects when card(s) lack finalized_at | trigger-build.test.ts |
| Build rejects when no cards have approved planned files | trigger-build.test.ts |
| artifact_kind excludes test (tests live as ContextArtifact type:test) | slice-b.test.ts |
| Per-card finalize validates requirements + planned files; sets finalized_at | finalize.test.ts |
| E2E: build-ready = approved planned files + finalized | project-to-cards-flow.test.ts |
- All tests pass before commit
- Contract tests cover schema and action validation
- Integration tests cover API and orchestration boundaries
- Product outcome alignment table reflects current coverage