Skip to content

Latest commit

Β 

History

History
101 lines (75 loc) Β· 2.01 KB

01-testing-strategy.md

File metadata and controls

101 lines (75 loc) Β· 2.01 KB

πŸ§ͺ Testing Strategy

Last Updated: 2026-03-15 | Version: 1.5.0

🎯 Testing Philosophy

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

πŸ—οΈ Testing Stack

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

πŸ“Š Coverage Targets

Category Target
Overall 80%
Utilities (src/lib/) 90%
Services (src/services/) 85%
API Routes 70%
Components 60%

πŸš€ Running Tests

# 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"

πŸ“ Test File Locations

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

πŸ”§ Test Environment

# .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

πŸ“Ž Related Docs