Strategy
Push logic to common. Most tests live in common.
| Layer | Volume | Coverage target |
|---|---|---|
common | High | ~80%+ |
model/common | Medium | Cross-cutting essentials |
model/{model} | Low | Wiring, critical paths |
pages / app | Minimal | Smoke / e2e |
Rules
- Test next to logic —
lib/converter.test.ts - Test
commonheavily (fast, stable) modeltests wiring only — don't re-test logic- No business logic tests in
pages/app
Extract to common
| Move to common | Path |
|---|---|
| Validation, predicates, transforms | common/lib/ |
| Date, string, URL formatting | common/lib/ |
| Generic input UI (no domain names) | common/ui/ |
Before adding to model:
- Does it mention project-specific names?
- If not, put it in
common - Pure functions in
model→ move tocommon/lib/on review
model/view.tsx should wire OOUI props only. Logic goes to common.
TDD flow
1. Extract logic to common/lib
2. Write unit tests in common first
3. Model only wires common
4. Add one model integration test if neededSample
templates/common/lib/example.test.ts
Use the project's test runner. If none, prefer bun:test or vitest.
*.test.ts sits beside source — not in a tests/ folder (avoid path duplication).