Last Updated: 2026-03-15 | Version: 1.5.0
We use a testing pyramid approach:
- Many fast unit tests at the bottom
- Fewer integration tests in the middle
- Select E2E tests for critical user flows at the top
| Type | Tool | Config |
|---|---|---|
| Unit Tests | Jest + ts-jest | jest.config.js |
| Integration Tests | Jest + Prisma | With test database |
| E2E Tests | Playwright | playwright.config.ts |
| Coverage | Jest Coverage | 80% target |
| Category | Target |
|---|---|
| Overall | 80% |
Utilities (src/lib/) |
90% |
Services (src/services/) |
85% |
| API Routes | 70% |
| Components | 60% |
# Unit tests
npm run test
# Watch mode (TDD)
npm run test:watch
# Coverage report
npm run test:coverage
# E2E tests (Playwright)
npm run test:e2e
# Run specific test file
npm test -- goalService.test.ts
# Run tests matching name
npm test -- --testNamePattern="streak"src/
βββ __tests__/
β βββ unit/
β β βββ lib/
β β β βββ crypto.test.ts
β β β βββ totp.test.ts
β β βββ services/
β β βββ streakService.test.ts
β β βββ goalService.test.ts
β βββ integration/
β βββ api/
β βββ tracker.test.ts
β βββ goals.test.ts
βββ e2e/
βββ auth.spec.ts
βββ dashboard.spec.ts
βββ goals.spec.ts
# .env.test
DATABASE_URL=postgresql://user:pass@localhost:5432/progresstracker_test
NEXTAUTH_SECRET=test-secret-min-32-characters-long
ENCRYPTION_KEY=test-encryption-key-min-32-chars