Testing Strategy
Purpose
Design comprehensive test strategies with test pyramid coverage, test file structure, and quality gates.
Scope Constraints
- Covers test plan design, pyramid layering, coverage targets, and CI quality gates.
- Does not cover codebase pattern auditing or convention enforcement — hand off to pattern-analysis.
- Does not cover architectural decisions about system boundaries — hand off to architect department.
Inputs
- Feature description and scope
- Existing test infrastructure (framework, runner, coverage tools)
- CI/CD pipeline details (if relevant)
- Existing test conventions in the codebase
- Coverage targets or requirements (if any)
Input Sanitization
No user-provided values are used in commands or file paths. All inputs are treated as read-only analysis targets.
Procedure
Progress Checklist
Step 1: Audit Existing Test Infrastructure
- Test framework (Jest, Vitest, Playwright, Cypress, etc.)
- Test runner and configuration
- Coverage tools (Istanbul, c8, etc.)
- CI integration (GitHub Actions, etc.)
- Existing test patterns (file location, naming, describe/it structure)
- Existing mocking patterns (jest.mock, vi.mock, MSW, etc.)
Step 2: Identify Testable Units
From the feature, extract:
- Pure functions and utilities — deterministic, no side effects, easiest to test
- Data transformations — input/output mapping, validation logic
- API handlers/endpoints — request/response contracts, error handling
- UI components — render output, interaction behavior, state changes
- Integration points — database queries, external API calls, file I/O
- Business logic — rules, calculations, conditional flows
Step 3: Design the Test Pyramid
/ E2E \ <- Few: critical user paths only (expensive, slow)
/----------\
/ Integration \ <- Some: cross-boundary, API contracts, DB queries
/----------------\
/ Unit Tests \ <- Many: fast, isolated, 80%+ of test count
/--------------------\
- Unit tests (base): Fast, isolated, test one thing. Target 80%+ of total test count.
- Integration tests (middle): Cross-boundary tests. Database interactions, API contracts, service-to-service.
- E2E tests (top): Critical user paths only. Expensive to write and maintain, keep count low.
Step 4: Write Test Specifications
For each layer, specify:
| Layer |
Test File |
Test Cases |
Mocks Needed |
Priority |
| Unit |
... |
... |
... |
... |
| Integration |
... |
... |
... |
... |
| E2E |
... |
... |
... |
... |
For each test case:
- Location: Follow existing convention (co-located
__tests__/, top-level tests/, or .test.ts suffix)
- Description:
describe('ModuleName', () => { it('should ...') }) format
- Key assertions: What exactly are we verifying?
- Mock strategy: What to mock (external deps), what to keep real (internal logic)
- Edge cases: Boundary values, empty inputs, error conditions
Step 5: Define Coverage Targets
- Line coverage: Pragmatic target (70-90%, not 100%)
- Branch coverage: Focus on critical paths and business logic branches
- Not worth testing: Glue code, framework boilerplate, simple pass-through, type-only files
- Must test: Business rules, data transformations, error handling, security-sensitive code
Step 6: Plan Quality Gates
- Pre-commit:
- Lint (ESLint, Biome)
- Type check (tsc --noEmit)
- Affected unit tests (if tooling supports)
- CI pipeline:
- Full test suite
- Coverage threshold check
- Build verification
- Manual review checklist:
Compaction resilience: If context is compacted mid-task, check the Progress Checklist for completed steps, re-read this Procedure section, and continue from the next incomplete step.
Handoff
- If pattern inconsistencies are discovered in test file structure or naming conventions, hand off to pattern-analysis for a full codebase convention audit.
- If test boundaries reveal unclear architectural boundaries or service decomposition issues, hand off to architect department for structural analysis.
Output Format
Test Pyramid Summary
| Layer |
Count |
Run Time |
Mock Strategy |
| Unit |
... |
... |
... |
| Integration |
... |
... |
... |
| E2E |
... |
... |
... |
Test Specifications
For each test file:
File: src/__tests__/feature.test.ts
Layer: Unit
describe('FeatureName')
it('should handle the happy path')
- Input: ...
- Expected: ...
it('should handle invalid input')
- Input: ...
- Expected: throws/returns error
it('should handle edge case')
- Input: ...
- Expected: ...
Mocks: ExternalService (return mock data)
Coverage Targets
| Category |
Target |
Rationale |
| Business logic |
90%+ |
Core value, must be correct |
| API handlers |
80%+ |
Contract compliance |
| UI components |
70%+ |
Render + key interactions |
| Utilities |
90%+ |
Pure functions, easy to test |
| Glue/config |
Skip |
Not worth testing |
Quality Gate Checklist
Quality Checks
Evolution Notes
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: testing-strategy-53description: Use when designing test plans for new features or improving existing test coverage. Covers test pyramid design, coverage targets, quality gates, and test file specifications. Do not use for codebase pattern audits or convention enforcement (use pattern-analysis).4---56# Testing Strategy78## Purpose910Design comprehensive test strategies with test pyramid coverage, test file structure, and quality gates.1112## Scope Constraints1314- Covers test plan design, pyramid layering, coverage targets, and CI quality gates.15- Does not cover codebase pattern auditing or convention enforcement — hand off to pattern-analysis.16- Does not cover architectural decisions about system boundaries — hand off to architect department.1718## Inputs1920- Feature description and scope21- Existing test infrastructure (framework, runner, coverage tools)22- CI/CD pipeline details (if relevant)23- Existing test conventions in the codebase24- Coverage targets or requirements (if any)2526## Input Sanitization2728No user-provided values are used in commands or file paths. All inputs are treated as read-only analysis targets.2930## Procedure3132### Progress Checklist3334- [ ] Step 1: Audit existing test infrastructure35- [ ] Step 2: Identify testable units36- [ ] Step 3: Design test pyramid37- [ ] Step 4: Write test specifications38- [ ] Step 5: Define coverage targets39- [ ] Step 6: Plan quality gates4041### Step 1: Audit Existing Test Infrastructure4243- Test framework (Jest, Vitest, Playwright, Cypress, etc.)44- Test runner and configuration45- Coverage tools (Istanbul, c8, etc.)46- CI integration (GitHub Actions, etc.)47- Existing test patterns (file location, naming, describe/it structure)48- Existing mocking patterns (jest.mock, vi.mock, MSW, etc.)4950### Step 2: Identify Testable Units5152From the feature, extract:53- **Pure functions and utilities** — deterministic, no side effects, easiest to test54- **Data transformations** — input/output mapping, validation logic55- **API handlers/endpoints** — request/response contracts, error handling56- **UI components** — render output, interaction behavior, state changes57- **Integration points** — database queries, external API calls, file I/O58- **Business logic** — rules, calculations, conditional flows5960### Step 3: Design the Test Pyramid6162```63 / E2E \ <- Few: critical user paths only (expensive, slow)64 /----------\65 / Integration \ <- Some: cross-boundary, API contracts, DB queries66 /----------------\67 / Unit Tests \ <- Many: fast, isolated, 80%+ of test count68 /--------------------\69```7071- **Unit tests (base):** Fast, isolated, test one thing. Target 80%+ of total test count.72- **Integration tests (middle):** Cross-boundary tests. Database interactions, API contracts, service-to-service.73- **E2E tests (top):** Critical user paths only. Expensive to write and maintain, keep count low.7475### Step 4: Write Test Specifications7677For each layer, specify:7879| Layer | Test File | Test Cases | Mocks Needed | Priority |80|-------|-----------|------------|--------------|----------|81| Unit | ... | ... | ... | ... |82| Integration | ... | ... | ... | ... |83| E2E | ... | ... | ... | ... |8485For each test case:86- **Location:** Follow existing convention (co-located `__tests__/`, top-level `tests/`, or `.test.ts` suffix)87- **Description:** `describe('ModuleName', () => { it('should ...') })` format88- **Key assertions:** What exactly are we verifying?89- **Mock strategy:** What to mock (external deps), what to keep real (internal logic)90- **Edge cases:** Boundary values, empty inputs, error conditions9192### Step 5: Define Coverage Targets9394- **Line coverage:** Pragmatic target (70-90%, not 100%)95- **Branch coverage:** Focus on critical paths and business logic branches96- **Not worth testing:** Glue code, framework boilerplate, simple pass-through, type-only files97- **Must test:** Business rules, data transformations, error handling, security-sensitive code9899### Step 6: Plan Quality Gates100101- **Pre-commit:**102 - Lint (ESLint, Biome)103 - Type check (tsc --noEmit)104 - Affected unit tests (if tooling supports)105- **CI pipeline:**106 - Full test suite107 - Coverage threshold check108 - Build verification109- **Manual review checklist:**110 - [ ] New business logic has unit tests111 - [ ] Error paths are tested112 - [ ] No snapshot tests for logic (only for stable UI)113 - [ ] Mocks don't hide real bugs114 - [ ] Test descriptions read as documentation115116> **Compaction resilience:** If context is compacted mid-task, check the Progress Checklist for completed steps, re-read this Procedure section, and continue from the next incomplete step.117118## Handoff119120- If pattern inconsistencies are discovered in test file structure or naming conventions, hand off to **pattern-analysis** for a full codebase convention audit.121- If test boundaries reveal unclear architectural boundaries or service decomposition issues, hand off to **architect department** for structural analysis.122123## Output Format124125### Test Pyramid Summary126127| Layer | Count | Run Time | Mock Strategy |128|-------|-------|----------|---------------|129| Unit | ... | ... | ... |130| Integration | ... | ... | ... |131| E2E | ... | ... | ... |132133### Test Specifications134135For each test file:136137```138File: src/__tests__/feature.test.ts139Layer: Unit140141describe('FeatureName')142 it('should handle the happy path')143 - Input: ...144 - Expected: ...145 it('should handle invalid input')146 - Input: ...147 - Expected: throws/returns error148 it('should handle edge case')149 - Input: ...150 - Expected: ...151152Mocks: ExternalService (return mock data)153```154155### Coverage Targets156157| Category | Target | Rationale |158|----------|--------|-----------|159| Business logic | 90%+ | Core value, must be correct |160| API handlers | 80%+ | Contract compliance |161| UI components | 70%+ | Render + key interactions |162| Utilities | 90%+ | Pure functions, easy to test |163| Glue/config | Skip | Not worth testing |164165### Quality Gate Checklist166167- [ ] Pre-commit hooks configured168- [ ] CI runs full test suite169- [ ] Coverage thresholds enforced170- [ ] New code has corresponding tests171172## Quality Checks173174- [ ] Every business logic function has a unit test spec175- [ ] Critical user paths have integration tests176- [ ] At least 1 E2E test for the main happy-path flow177- [ ] Mock strategy documented and doesn't hide real bugs178- [ ] Test file locations follow existing project conventions179- [ ] Edge cases and error paths included in test specs180- [ ] Coverage targets are pragmatic (not aspirational 100%)181182## Evolution Notes183<!-- Observations appended after each use -->184185---186> Converted and distributed by [TomeVault](https://tomevault.io/claim/dtsong) — claim your Tome and manage your conversions.187<!-- tomevault:4.0:skill_md:2026-04-13 -->