Skip to main content
Build confidence in your application with thorough testing practices.

Testing philosophy

Test pyramid:
  1. Integration tests (70%): Test utilities, helpers, business logic
  2. E2E tests (20%): Test critical user flows
  3. Manual testing (10%): Exploratory and edge cases
What to test:
  • ✅ Critical user flows (auth, payments, core features)
  • ✅ Business logic and data transformations
  • ✅ Error handling and edge cases
  • ✅ Security features (input validation, authorization)
What not to test:
  • ❌ Implementation details (how, not what)
  • ❌ Third-party libraries (trust they’re tested)
  • ❌ Trivial code (getters, setters)
  • ❌ UI styling (unless critical to functionality)

Integration testing with Vitest

Test structure

__tests__/utils.test.ts

Testing Server Actions

__tests__/actions.test.ts

Testing utilities

__tests__/lib/utils.test.ts

E2E testing with Playwright

Authentication flows

tests/e2e/auth.spec.ts

Form validation

tests/e2e/forms.spec.ts
tests/e2e/navigation.spec.ts

Test fixtures and helpers

Reusable fixtures

tests/fixtures/users.ts

Test helpers

tests/helpers/auth.ts

Testing error states

Network errors

__tests__/api-errors.test.ts

Edge cases

__tests__/edge-cases.test.ts

CI/CD integration

GitHub Actions workflow

.github/workflows/test.yml

Testing checklist

  • Test utility functions
  • Test data transformations
  • Test validation logic
  • Test error handling
  • Mock external dependencies
  • Test authentication flows
  • Test critical user paths
  • Test form submissions
  • Test navigation
  • Test error states
  • Tests are independent
  • Tests clean up after themselves
  • Descriptive test names
  • Tests are deterministic
  • Fast execution
  • Critical paths covered
  • Edge cases tested
  • Error handling verified
  • Security features tested
  • CI/CD integration

Next steps

Local Testing

Run tests locally

Code Organization

Structure your test files