Testing Strategy
Overview
Analyze the project context and recommend a comprehensive testing strategy. This skill selects appropriate frameworks, defines the testing pyramid, establishes coverage thresholds, and generates test configuration files. The goal is a repeatable, measurable testing foundation that the team can maintain.
Announce at start: "I'm using the testing-strategy skill to define the testing approach."
Phase 1: Analyze Project
Goal: Understand the current stack, existing tests, and CI setup before recommending anything.
Actions
- Identify the tech stack (language, framework, runtime)
- Survey existing tests (what testing exists already?)
- Review CI/CD pipeline (how do tests run?)
- Measure current coverage levels
- Map external dependencies (services, databases, APIs)
Discovery Commands
# Identify test files
find . -name "*.test.*" -o -name "*.spec.*" | head -30
# Check for test config
ls vitest.config.* jest.config.* pytest.ini pyproject.toml .mocharc.* 2>/dev/null
# Check current coverage
cat coverage/coverage-summary.json 2>/dev/null || echo "No coverage report found"
# Check CI config
cat .github/workflows/*.yml 2>/dev/null | head -50
STOP — Do NOT proceed to Phase 2 until:
Phase 2: Recommend Testing Pyramid
Goal: Select frameworks and define the pyramid ratios.
Framework Selection Table
| Stack |
Unit |
Integration |
E2E |
| Node.js/TS |
Vitest |
Vitest + Supertest |
Playwright |
| React/Next.js |
Vitest + Testing Library |
Vitest + MSW |
Playwright/Cypress |
| Python |
pytest |
pytest + httpx |
Playwright |
| Go |
testing + testify |
testing + testcontainers |
Playwright |
| Rust |
cargo test |
cargo test + testcontainers |
- |
| PHP/Laravel |
Pest/PHPUnit |
Pest + HTTP tests |
Playwright/Dusk |
Testing Pyramid Ratios
/\
/ \ E2E Tests (10%)
/ \ Critical user journeys only
/------\
/ \ Integration Tests (30%)
/ \ API endpoints, DB queries, service interactions
/------------\
/ \ Unit Tests (60%)
/ \ Pure functions, business logic, utilities
What to Test at Each Level
| Level |
Test These |
Do NOT Test These |
| Unit (60%) |
Pure functions, business logic, data transformations, validations, state management |
Framework internals, third-party libraries |
| Integration (30%) |
API endpoints, database queries, service-to-service calls, auth flows |
Individual functions in isolation |
| E2E (10%) |
Critical user journeys (signup, purchase), cross-browser, accessibility |
Edge cases (handle at unit level) |
STOP — Do NOT proceed to Phase 3 until:
Phase 3: Define Coverage Thresholds
Goal: Set realistic, enforceable coverage targets.
Coverage Threshold Table
| Category |
Minimum |
Target |
Notes |
| Overall |
70% |
85% |
Lines covered |
| Critical paths |
90% |
95% |
Auth, payments, data access |
| New code (PRs) |
80% |
90% |
Enforced in CI |
| Utilities |
95% |
100% |
Pure functions are easy to test |
Threshold Selection Decision Table
| Project Maturity |
Overall Minimum |
New Code Minimum |
Rationale |
| Greenfield |
80% |
90% |
Start high, maintain standard |
| Active (good coverage) |
70% |
85% |
Maintain and improve |
| Legacy (low coverage) |
50% |
80% |
Raise floor gradually |
| Prototype/MVP |
60% |
70% |
Cover critical paths, accept gaps |
STOP — Do NOT proceed to Phase 4 until:
Phase 4: Generate Configuration
Goal: Produce working test configuration files and CI integration.
Actions
- Generate test runner config (
vitest.config.ts, jest.config.js, pytest.ini)
- Configure coverage with thresholds
- Add test commands to CI workflow
- Set up test environment (
.env.test, test databases)
Example: Vitest Config
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
globals: true,
environment: 'jsdom',
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
thresholds: {
lines: 80,
functions: 80,
branches: 80,
statements: 80,
},
},
include: ['src/**/*.test.{ts,tsx}'],
},
});
STOP — Do NOT proceed to Phase 5 until:
Phase 5: Create Test Templates
Goal: Provide example test files demonstrating project conventions.
Actions
- Create a unit test example with Arrange-Act-Assert
- Create an integration test with setup/teardown
- Create mock/stub patterns for external dependencies
- Create test data factories/fixtures
- Create a snapshot test example (when appropriate)
STOP — Verification Gate before claiming complete:
Anti-Patterns / Common Mistakes
| Anti-Pattern |
Why It Is Wrong |
Correct Approach |
| Testing implementation details |
Breaks on every refactor, provides false confidence |
Test behavior and outcomes |
| Excessive mocking |
Tests nothing real, mocks mask real failures |
Mock at boundaries only |
| Brittle CSS selectors in E2E |
Break with styling changes |
Use data-testid or accessible roles |
| Test interdependence |
Ordering failures, flaky in CI |
Each test must run independently |
| Slow tests blocking CI |
Developers skip running tests |
Parallelize, use test databases, mock external APIs |
| Snapshot overuse |
Snapshots approved without reading, stale baselines |
Use for stable output only |
| No coverage enforcement in CI |
Coverage degrades over time |
Enforce thresholds in CI pipeline |
| Same coverage target everywhere |
Utilities and critical paths differ |
Use per-category thresholds |
Decision Table: Mock Strategy
| Dependency Type |
Mock Strategy |
Example |
| External API |
MSW / nock / responses |
Third-party payment API |
| Database |
Test database or in-memory |
PostgreSQL test container |
| File system |
Virtual FS or temp directory |
File upload processing |
| Time/Date |
Fake timers |
Expiration logic |
| Environment vars |
Override in test setup |
Feature flags |
| Random/UUID |
Seed or stub |
ID generation |
Integration Points
| Skill |
Relationship |
test-driven-development |
Strategy defines frameworks; TDD defines the cycle |
acceptance-testing |
Strategy includes acceptance test infrastructure |
code-review |
Review checks that tests follow the defined strategy |
senior-frontend |
Frontend testing uses strategy-selected frameworks |
senior-backend |
Backend testing uses strategy-selected frameworks |
performance-optimization |
Load tests are part of the overall testing strategy |
webapp-testing |
Playwright E2E tests follow strategy pyramid |
Key Principles
- Test behavior, not implementation — what it does, not how
- Fast feedback — unit tests should run in seconds
- Deterministic — no flaky tests, no time-dependent logic
- Readable — tests are documentation; make them clear
- Maintainable — tests should help refactoring, not block it
Skill Type
FLEXIBLE — Adapt framework selection and coverage thresholds to the project context. The five-phase process and testing pyramid structure are strongly recommended but can be scaled to project size.
1---2name: testing-strategy3description: Use when choosing a testing approach for a project — selecting frameworks, defining coverage thresholds, setting up test infrastructure, and establishing testing patterns. Triggers: new project setup, CI/CD pipeline design, coverage audit, test framework migration, quality standard definition.4---5
6# Testing Strategy
7
8## Overview
9
10Analyze the project context and recommend a comprehensive testing strategy. This skill selects appropriate frameworks, defines the testing pyramid, establishes coverage thresholds, and generates test configuration files. The goal is a repeatable, measurable testing foundation that the team can maintain.
11
12**Announce at start:** "I'm using the testing-strategy skill to define the testing approach."
13
14---
15
16## Phase 1: Analyze Project
17
18**Goal:** Understand the current stack, existing tests, and CI setup before recommending anything.
19
20### Actions
21
221. Identify the tech stack (language, framework, runtime)
232. Survey existing tests (what testing exists already?)
243. Review CI/CD pipeline (how do tests run?)
254. Measure current coverage levels
265. Map external dependencies (services, databases, APIs)
27
28### Discovery Commands
29
30```bash
31# Identify test files
32find . -name "*.test.*" -o -name "*.spec.*" | head -30
33
34# Check for test config
35ls vitest.config.* jest.config.* pytest.ini pyproject.toml .mocharc.* 2>/dev/null
36
37# Check current coverage
38cat coverage/coverage-summary.json 2>/dev/null || echo "No coverage report found"
39
40# Check CI config
41cat .github/workflows/*.yml 2>/dev/null | head -50
42```
43
44### STOP — Do NOT proceed to Phase 2 until:
45- [ ] Tech stack is identified
46- [ ] Existing test infrastructure is mapped
47- [ ] CI pipeline status is known
48- [ ] External dependencies are listed
49
50---
51
52## Phase 2: Recommend Testing Pyramid
53
54**Goal:** Select frameworks and define the pyramid ratios.
55
56### Framework Selection Table
57
58| Stack | Unit | Integration | E2E |
59|-------|------|-------------|-----|
60| **Node.js/TS** | Vitest | Vitest + Supertest | Playwright |
61| **React/Next.js** | Vitest + Testing Library | Vitest + MSW | Playwright/Cypress |
62| **Python** | pytest | pytest + httpx | Playwright |
63| **Go** | testing + testify | testing + testcontainers | Playwright |
64| **Rust** | cargo test | cargo test + testcontainers | - |
65| **PHP/Laravel** | Pest/PHPUnit | Pest + HTTP tests | Playwright/Dusk |
66
67### Testing Pyramid Ratios
68
69```
70 /\
71 / \ E2E Tests (10%)
72 / \ Critical user journeys only
73 /------\
74 / \ Integration Tests (30%)
75 / \ API endpoints, DB queries, service interactions
76 /------------\
77 / \ Unit Tests (60%)
78/ \ Pure functions, business logic, utilities
79```
80
81### What to Test at Each Level
82
83| Level | Test These | Do NOT Test These |
84|-------|-----------|------------------|
85| **Unit (60%)** | Pure functions, business logic, data transformations, validations, state management | Framework internals, third-party libraries |
86| **Integration (30%)** | API endpoints, database queries, service-to-service calls, auth flows | Individual functions in isolation |
87| **E2E (10%)** | Critical user journeys (signup, purchase), cross-browser, accessibility | Edge cases (handle at unit level) |
88
89### STOP — Do NOT proceed to Phase 3 until:
90- [ ] Framework selection matches the tech stack
91- [ ] Pyramid ratios are defined
92- [ ] Testing scope at each level is documented
93
94---
95
96## Phase 3: Define Coverage Thresholds
97
98**Goal:** Set realistic, enforceable coverage targets.
99
100### Coverage Threshold Table
101
102| Category | Minimum | Target | Notes |
103|----------|---------|--------|-------|
104| Overall | 70% | 85% | Lines covered |
105| Critical paths | 90% | 95% | Auth, payments, data access |
106| New code (PRs) | 80% | 90% | Enforced in CI |
107| Utilities | 95% | 100% | Pure functions are easy to test |
108
109### Threshold Selection Decision Table
110
111| Project Maturity | Overall Minimum | New Code Minimum | Rationale |
112|-----------------|----------------|-------------------|-----------|
113| Greenfield | 80% | 90% | Start high, maintain standard |
114| Active (good coverage) | 70% | 85% | Maintain and improve |
115| Legacy (low coverage) | 50% | 80% | Raise floor gradually |
116| Prototype/MVP | 60% | 70% | Cover critical paths, accept gaps |
117
118### STOP — Do NOT proceed to Phase 4 until:
119- [ ] Coverage thresholds are realistic for the project maturity
120- [ ] Critical path coverage targets are defined
121- [ ] CI enforcement strategy is decided
122
123---
124
125## Phase 4: Generate Configuration
126
127**Goal:** Produce working test configuration files and CI integration.
128
129### Actions
130
1311. Generate test runner config (`vitest.config.ts`, `jest.config.js`, `pytest.ini`)
1322. Configure coverage with thresholds
1333. Add test commands to CI workflow
1344. Set up test environment (`.env.test`, test databases)
135
136### Example: Vitest Config
137
138```typescript
139import { defineConfig } from 'vitest/config';
140
141export default defineConfig({
142 test: {
143 globals: true,
144 environment: 'jsdom',
145 coverage: {
146 provider: 'v8',
147 reporter: ['text', 'json', 'html'],
148 thresholds: {
149 lines: 80,
150 functions: 80,
151 branches: 80,
152 statements: 80,
153 },
154 },
155 include: ['src/**/*.test.{ts,tsx}'],
156 },
157});
158```
159
160### STOP — Do NOT proceed to Phase 5 until:
161- [ ] Config files are syntactically valid
162- [ ] Coverage thresholds match Phase 3 decisions
163- [ ] CI integration commands are defined
164
165---
166
167## Phase 5: Create Test Templates
168
169**Goal:** Provide example test files demonstrating project conventions.
170
171### Actions
172
1731. Create a unit test example with Arrange-Act-Assert
1742. Create an integration test with setup/teardown
1753. Create mock/stub patterns for external dependencies
1764. Create test data factories/fixtures
1775. Create a snapshot test example (when appropriate)
178
179### STOP — Verification Gate before claiming complete:
180- [ ] Framework selection matches tech stack
181- [ ] Coverage thresholds are realistic
182- [ ] Test configuration files are valid
183- [ ] Example tests actually run
184- [ ] CI integration is configured
185
186---
187
188## Anti-Patterns / Common Mistakes
189
190| Anti-Pattern | Why It Is Wrong | Correct Approach |
191|-------------|----------------|-----------------|
192| Testing implementation details | Breaks on every refactor, provides false confidence | Test behavior and outcomes |
193| Excessive mocking | Tests nothing real, mocks mask real failures | Mock at boundaries only |
194| Brittle CSS selectors in E2E | Break with styling changes | Use data-testid or accessible roles |
195| Test interdependence | Ordering failures, flaky in CI | Each test must run independently |
196| Slow tests blocking CI | Developers skip running tests | Parallelize, use test databases, mock external APIs |
197| Snapshot overuse | Snapshots approved without reading, stale baselines | Use for stable output only |
198| No coverage enforcement in CI | Coverage degrades over time | Enforce thresholds in CI pipeline |
199| Same coverage target everywhere | Utilities and critical paths differ | Use per-category thresholds |
200
201---
202
203## Decision Table: Mock Strategy
204
205| Dependency Type | Mock Strategy | Example |
206|----------------|--------------|---------|
207| External API | MSW / nock / responses | Third-party payment API |
208| Database | Test database or in-memory | PostgreSQL test container |
209| File system | Virtual FS or temp directory | File upload processing |
210| Time/Date | Fake timers | Expiration logic |
211| Environment vars | Override in test setup | Feature flags |
212| Random/UUID | Seed or stub | ID generation |
213
214---
215
216## Integration Points
217
218| Skill | Relationship |
219|-------|-------------|
220| `test-driven-development` | Strategy defines frameworks; TDD defines the cycle |
221| `acceptance-testing` | Strategy includes acceptance test infrastructure |
222| `code-review` | Review checks that tests follow the defined strategy |
223| `senior-frontend` | Frontend testing uses strategy-selected frameworks |
224| `senior-backend` | Backend testing uses strategy-selected frameworks |
225| `performance-optimization` | Load tests are part of the overall testing strategy |
226| `webapp-testing` | Playwright E2E tests follow strategy pyramid |
227
228---
229
230## Key Principles
231
232- **Test behavior, not implementation** — what it does, not how
233- **Fast feedback** — unit tests should run in seconds
234- **Deterministic** — no flaky tests, no time-dependent logic
235- **Readable** — tests are documentation; make them clear
236- **Maintainable** — tests should help refactoring, not block it
237
238---
239
240## Skill Type
241
242**FLEXIBLE** — Adapt framework selection and coverage thresholds to the project context. The five-phase process and testing pyramid structure are strongly recommended but can be scaled to project size.