testing · git:20260315.01353e4 · 2026-03-15 · sha256 b262b190f09b9e8b

testing git:20260315.01353e4A

Immutable. This exact content never changes and is served at /api/v1/blob/b262b190f09b9e8b.

---
description: Vitest testing patterns — LLM mocks, coverage config, test file structure
globs: src/**/__tests__/*.test.ts,src/test/**
alwaysApply: false
---
- All LLM calls globally mocked via `src/test/setup.ts` — no real API calls
- Override per-test: `vi.spyOn(llm, 'llmCall').mockResolvedValue('...')`
- Coverage excludes: `src/test/`, `src/bin.ts`, `src/cli.ts`, `src/commands/**`, `dist/**`
- Scoring checks are pure functions — test with temp dirs or mocked fs
- LLM utils (`extractJson`, `estimateTokens`) are pure — no mocking needed
- Fingerprint tests: mock `fs` and `child_process.execSync`
- Learner tests: use temp directories from `os.tmpdir()`
- Use `memfs` for filesystem mocking when needed
- Run single file: `npx vitest run src/scoring/__tests__/accuracy.test.ts`