← ClaudeAtlas

csp-tddlisted

Test-Driven Development: write failing test first, minimal code to pass, then refactor. Enforces Red-Green-Refactor cycle with 80%+ coverage across unit, integration, and E2E tests. Use when implementing any feature, fixing bugs, or refactoring code.
maythyai/code-skills-package · ★ 1 · Testing & QA · score 70
Install: claude install-skill maythyai/code-skills-package
| Test Layer | Scope | When to Write | |------------|-------|---------------| | **Unit** | Individual functions, component logic, pure helpers | Always | | **Integration** | API endpoints, database operations, service interactions | Always | | **E2E** | Critical user flows (Playwright/Cypress) | Critical paths | ## Coverage Requirements - Minimum **80%** coverage (branches, functions, lines, statements) - All edge cases covered - Error scenarios tested - Boundary conditions verified ```bash npm run test:coverage # Verify 80%+ achieved ``` ## Edge Cases You MUST Test 1. **Null/Undefined** input 2. **Empty** arrays/strings 3. **Invalid types** passed 4. **Boundary values** (min/max) 5. **Error paths** (network failures, DB errors) 6. **Race conditions** (concurrent operations) 7. **Large data** (performance with 10k+ items) 8. **Special characters** (Unicode, emojis, SQL chars) ## Test File Organization ``` src/ ├── components/ │ └── Button/ │ ├── Button.tsx │ └── Button.test.tsx # Unit tests ├── app/api/markets/ │ ├── route.ts │ └── route.test.ts # Integration tests └── e2e/ └── markets.spec.ts # E2E tests ``` ## Mocking External Services ```typescript // Supabase mock jest.mock('@/lib/supabase', () => ({ supabase: { from: jest.fn(() => ({ select: jest.fn(() => ({ eq: jest.fn(() => Promise.resolve({ data: [], error: null })) })) })) } })) ``` Always mock: external APIs, database