This project follows a pragmatic testing approach that balances code quality with development velocity.
- Overall: ~16% coverage
- Critical Path (optimizer.ts): ~90% coverage ✅
- Hooks: ~97% coverage ✅
- UI Components: 0% coverage (tested manually + via Vercel previews)
- Start with realistic thresholds (current: 13-16%)
- Gradually increase as the codebase matures
- Target: 50% overall coverage by v2.0
High Priority (Must have tests):
- Business logic (optimizers, algorithms)
- Data transformations
- Utility functions
- Custom hooks
Medium Priority (Nice to have):
- Complex UI components
- API integrations
- State management
Low Priority (Can rely on manual/E2E):
- Simple UI components
- Static pages
- Style-only components
npm test # Run all tests
npm test -- --coverage # With coverage report
npm test -- --watch # Watch mode for TDD- Test complete user flows
- Verify optimizer outputs with real data
- API endpoint testing
- Critical user journeys
- Cross-browser compatibility
- Performance benchmarks
{
branches: 13, // Goal: 50%
functions: 11, // Goal: 40%
lines: 16, // Goal: 50%
statements: 16, // Goal: 50%
}lib/optimizer.ts: 85%+ coverage requiredlib/hooks/*.ts: 95%+ coverage required- New utility functions: 80%+ coverage expected
- Write tests BEFORE implementation (TDD)
- Ensure critical paths have tests
- Add integration tests for complex features
- Write a failing test that reproduces the bug
- Fix the bug
- Ensure test passes
- Focus on behavior, not implementation
- Test user interactions
- Verify accessibility
Tests run automatically on:
- Every push to main
- All pull requests
- Pre-deployment checks
- Coverage below threshold: Add tests or adjust thresholds with justification
- Test failures: Fix immediately, don't skip tests
- Flaky tests: Investigate root cause, don't ignore
- Keep tests fast (<5 seconds for unit tests)
- Make tests deterministic (no random data without seeds)
- Test behavior, not implementation
- Use descriptive test names
- Follow AAA pattern (Arrange, Act, Assert)
describe('ComponentName', () => {
describe('when condition is true', () => {
it('should behave in expected way', () => {
// Arrange
const input = setupTestData()
// Act
const result = functionUnderTest(input)
// Assert
expect(result).toMatchExpectedOutput()
})
})
})- Basic unit tests for core logic
- Coverage reporting setup
- CI/CD integration
- Increase coverage to 30%
- Add integration tests
- Component testing with React Testing Library
- E2E tests with Playwright
- Performance benchmarks
- Visual regression tests
- 50% coverage target
- Automated accessibility tests
- Load testing for optimizer
When contributing, please:
- Include tests for new features
- Maintain or improve coverage
- Run tests locally before pushing
- Update this document if testing strategy changes