---
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`