// Use this skill when creating comprehensive testing strategies for applications. Provides test planning templates, coverage targets, test case structures, and guidance for unit, integration, E2E, and performance testing. Ensures robust quality assurance across the development lifecycle.
| name | testing-strategy-builder |
| description | Use this skill when creating comprehensive testing strategies for applications. Provides test planning templates, coverage targets, test case structures, and guidance for unit, integration, E2E, and performance testing. Ensures robust quality assurance across the development lifecycle. |
| version | 1.0.0 |
| author | AI Agent Hub |
| tags | ["testing","quality-assurance","test-strategy","automation","coverage"] |
This skill provides comprehensive guidance for building effective testing strategies that ensure software quality, reliability, and maintainability. Whether starting from scratch or improving existing test coverage, this framework helps teams design robust testing approaches.
When to use this skill:
Bundled Resources:
references/code-examples.md - Detailed testing code examplestemplates/test-plan-template.md - Comprehensive test plan templatetemplates/test-case-template.md - Test case documentation templatechecklists/test-coverage-checklist.md - Coverage verification checklistThis skill references the following testing tools. Not all are required - the skill will recommend appropriate tools based on your project.
Jest: Most popular testing framework
npm install --save-dev jest @types/jestnpx jest --initVitest: Vite-native testing framework
npm install --save-dev vitestPlaywright: End-to-end testing
npm install --save-dev @playwright/testnpx playwright installk6: Performance testing
brew install k6k6 run script.jspytest: Standard Python testing framework
pip install pytestpytestpytest-cov: Coverage reporting
pip install pytest-covpytest --cov=.Locust: Performance testing
pip install locustlocust -f locustfile.pyc8: JavaScript/TypeScript coverage
npm install --save-dev c8c8 npm testIstanbul/nyc: Alternative JS coverage
npm install --save-dev nycnyc npm test# JavaScript/TypeScript
jest --version
vitest --version
playwright --version
k6 version
# Python
pytest --version
locust --version
# Coverage
c8 --version
nyc --version
Note: The skill will guide you to select tools based on your project framework (React, Vue, FastAPI, Django, etc.) and testing needs.
Modern testing follows the "Testing Trophy" model (evolved from the testing pyramid):
🏆
/ \
/ E2E \ ← Few (critical user journeys)
/----------\
/ Integration\ ← Many (component interactions)
/--------------\
/ Unit \ ← Most (business logic)
/------------------\
/ Static Analysis \ ← Foundation (linting, type checking)
Principles:
Balance: 70% integration, 20% unit, 10% E2E (adjust based on context)
Recommended Targets:
Coverage Types:
Important: Coverage is a metric, not a goal. 100% coverage ≠ bug-free code.
Purpose: Catch errors before runtime Tools: ESLint, Prettier, TypeScript, Pylint, mypy, Ruff When to run: Pre-commit hooks, CI pipeline
Purpose: Test isolated business logic Tools: Jest, Vitest, pytest, JUnit Characteristics:
Coverage Target: 90%+ for business logic
See references/code-examples.md for detailed unit test examples.
Purpose: Test component interactions Tools: Testing Library, Supertest, pytest with fixtures Characteristics:
Coverage Target: 70%+ for API endpoints and component interactions
See references/code-examples.md for API integration test examples.
Purpose: Validate critical user journeys Tools: Playwright, Cypress, Selenium Characteristics:
Coverage Target: 5-10 critical user journeys
See references/code-examples.md for complete E2E test examples.
Purpose: Validate system performance under load Tools: k6, Artillery, JMeter, Locust Types:
Coverage Target: Test all performance-critical endpoints
See references/code-examples.md for k6 load test examples.
Prioritize testing based on risk assessment:
High Risk (100% coverage required):
Medium Risk (80% coverage):
Low Risk (50% coverage):
Given-When-Then Pattern:
Given [initial context]
When [action occurs]
Then [expected outcome]
This pattern keeps tests clear and focused. See references/code-examples.md for implementation examples.
Strategies:
See references/code-examples.md for test factory and fixture examples.
Structure tests in three clear phases:
See references/code-examples.md for detailed AAA pattern examples.
Each test should be independent:
See references/code-examples.md for test isolation patterns.
When to Mock:
When to Use Real Dependencies:
See references/code-examples.md for mocking examples.
Use for: UI components, API responses, generated code
Warning: Snapshots can become brittle. Use for stable components, not rapidly changing UI.
Test multiple scenarios with same logic using data tables.
See references/code-examples.md for parameterized test patterns.
Pipeline Stages:
# Example: GitHub Actions
name: Test Pipeline
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Type check
run: npm run typecheck
- name: Unit & Integration Tests
run: npm test -- --coverage
- name: Upload coverage
uses: codecov/codecov-action@v3
- name: E2E Tests
run: npm run test:e2e
- name: Performance Tests (on main branch)
if: github.ref == 'refs/heads/main'
run: npm run test:performance
Block merges/deployments if:
On Every Commit:
On Pull Request:
On Deploy to Staging:
On Deploy to Production:
| Category | Tool | Use Case |
|---|---|---|
| Unit/Integration | Vitest | Fast, Vite-native, modern |
| Unit/Integration | Jest | Mature, extensive ecosystem |
| E2E | Playwright | Cross-browser, reliable, fast |
| E2E | Cypress | Developer-friendly, visual debugging |
| Component Testing | Testing Library | User-centric, framework-agnostic |
| API Testing | Supertest | HTTP assertions, Express integration |
| Performance | k6 | Load testing, scriptable |
| Category | Tool | Use Case |
|---|---|---|
| Unit/Integration | pytest | Powerful, extensible, fixtures |
| API Testing | httpx + pytest | Async support, modern |
| E2E | Playwright (Python) | Browser automation |
| Performance | Locust | Load testing, Python-based |
| Mocking | unittest.mock | Standard library, reliable |
❌ Testing Implementation Details
// Bad: Testing internal state
expect(component.state.isLoading).toBe(false);
// Good: Testing user-visible behavior
expect(screen.queryByText('Loading...')).not.toBeInTheDocument();
❌ Tests Too Coupled to Code
// Bad: Test breaks when implementation changes
expect(userService.save).toHaveBeenCalledTimes(1);
// Good: Test behavior, not implementation
const user = await db.users.findOne({ email: 'test@example.com' });
expect(user).toBeTruthy();
❌ Flaky Tests
// Bad: Non-deterministic timeout
await waitFor(() => {
expect(screen.getByText('Success')).toBeInTheDocument();
}, { timeout: 1000 }); // Might fail on slow CI
// Good: Use explicit waits with longer timeout
await screen.findByText('Success', {}, { timeout: 5000 });
❌ Giant Test Cases
// Bad: One test does too much
test('user workflow', async () => {
// 100 lines testing signup, login, profile update, logout...
});
// Good: Focused tests
test('user can sign up', async () => { /* ... */ });
test('user can login', async () => { /* ... */ });
test('user can update profile', async () => { /* ... */ });
When starting a new project or feature:
templates/test-plan-template.md)For detailed code examples: See references/code-examples.md
Skill Version: 1.0.0 Last Updated: 2025-10-31 Maintained by: AI Agent Hub Team