Testing Stack
Unit Tests
Vitest - Fast unit testing for utilities and business logic
- Tests in
__tests__/ - Run with
npm run test - Coverage reports included
E2E Tests
Playwright - Browser automation for critical user flows
- Tests in
e2e/ - Run with
npm run test:e2e - Cross-browser testing
Test Coverage
What We Test
Unit Tests (__tests__/):
- Business logic (billing calculations, time utilities)
- Data transformations
- Helper functions
- Type utilities
e2e/):
- Authentication flows
- Critical user journeys (create task, approve quote)
- Client portal functionality
- Multi-user workflows
- UI styling/layout
- Third-party libraries
- Database migrations
- Simple CRUD operations
Running Tests
Unit Tests
E2E Tests
Unit Test Examples
Testing Utilities
Testing Date Utilities
Testing T-shirt Sizes
E2E Test Examples
Authentication Flow
Task Creation Flow
Client Portal Flow
Test Configuration
Vitest Config
Playwright Config
CI/CD Integration
Tests run automatically on every pull request:Best Practices
Test Business Logic, Not Implementation
Test Business Logic, Not Implementation
Focus on behavior, not internal details:
Keep Tests Fast
Keep Tests Fast
Unit tests should run in milliseconds:
- No database calls in unit tests
- Mock external dependencies
- Use in-memory data
Use Descriptive Test Names
Use Descriptive Test Names
Test Edge Cases
Test Edge Cases
Don’t just test the happy path:
Debugging Tests
Vitest
Playwright
Coverage Reports
- Business logic: 80%+ coverage
- Utilities: 90%+ coverage
- API routes: Not required (tested via E2E)