Test types
Integration tests (Vitest):- Test utilities and helper functions
- Validate configuration logic
- Check data transformations
- Run fast without external dependencies
- Test complete user workflows
- Verify authentication flows
- Check page navigation
- Test form submissions
Running tests
All tests
Run both integration and E2E tests:Integration tests only
E2E tests only
Writing integration tests
Create tests intests/integration/ or colocate with your code:
__tests__/utils.test.ts
Testing Server Actions
Test server-side logic:__tests__/actions.test.ts
Writing E2E tests
Create tests intests/e2e/:
tests/e2e/auth.spec.ts
Testing protected pages
tests/e2e/protected.spec.ts
Test configuration
Vitest config
vitest.config.ts includes:
- TypeScript support
- Path aliases (@/ imports)
- Coverage reporting
- Fast watch mode
Playwright config
playwright.config.ts includes:
- Multiple browsers (Chromium, Firefox, WebKit)
- Mobile viewport testing
- Screenshot on failure
- Video recording for CI
CI/CD integration
Run tests in your CI pipeline:.github/workflows/test.yml
Best practices
Keep tests focused
Keep tests focused
- Test one thing per test case
- Use descriptive test names
- Group related tests with
describe()
Mock external dependencies
Mock external dependencies
Test error cases
Test error cases
Don’t just test happy paths:
- Invalid inputs
- Network failures
- Permission errors
- Edge cases
Use test fixtures
Use test fixtures
Create reusable test data:

