Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.
Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.
Test-Driven Development Workflow
This skill ensures all code development follows TDD principles with comprehensive test coverage.
When to Activate
Writing new features or functionality
Fixing bugs or issues
Refactoring existing code
Adding API endpoints
Creating new components
Core Principles
1. Tests BEFORE Code
ALWAYS write tests first, then implement code to make tests pass.
2. Coverage Requirements
Minimum 80% coverage (unit + integration + E2E)
All edge cases covered
Error scenarios tested
Boundary conditions verified
3. Test Types
Unit Tests
Individual functions and utilities
Component logic
Pure functions
Helpers and utilities
Integration Tests
API endpoints
Database operations
Service interactions
External API calls
E2E Tests (Playwright)
Critical user flows
Complete workflows
Browser automation
UI interactions
TDD Workflow Steps
Step 1: Write User Journeys
As a [role], I want to [action], so that [benefit]
Example:
As a user, I want to search for markets semantically,
so that I can find relevant markets even without exact keywords.
Step 2: Generate Test Cases
For each user journey, create comprehensive test cases:
// Resilient to changesawait page.click('button:has-text("Submit")');
await page.click('[data-testid="submit-button"]');
❌ WRONG: No Test Isolation
// Tests depend on each othertest('creates user', () => {
/* ... */
});
test('updates same user', () => {
/* depends on previous test */
});
✅ CORRECT: Independent Tests
// Each test sets up its own datatest('creates user', () => {
const user = createTestUser();
// Test logic
});
test('updates user', () => {
const user = createTestUser();
// Update logic
});
Continuous Testing
Watch Mode During Development
npm test -- --watch
# Tests run automatically on file changes
Pre-Commit Hook
# Runs before every commit
npm test && npm run lint