Testing Overview
Run end-to-end tests with Playwright and unit tests with Vitest in your MakerKit application.
MakerKit ships with a production-ready testing setup: Playwright for end-to-end tests and Vitest for unit tests. Both are pre-configured and ready to use.
The test suite covers authentication flows (sign up, sign in, MFA, password reset), organization management (members, invitations, roles), admin features, and core business logic. E2E tests run against a real PostgreSQL database with seeded data, giving you confidence that user flows work correctly in production.
Quick Start
Run all tests with a single command:
# Run E2E tests (requires running web server)pnpm --filter web build:test && pnpm --filter web start:testpnpm --filter web-e2e test:slow# Run all unit tests across packagespnpm test:unitWhat's Included
The testing infrastructure covers:
- E2E tests for authentication, organizations, members, settings, and admin flows
- Unit tests for business logic in packages like RBAC, billing, auth, and organization services
- Page Object pattern for maintainable E2E tests
- Bootstrap helpers for fast test setup without UI interaction
- Global database seeding before E2E test runs
Topics
- E2E Testing with Playwright - Browser-based testing for user flows
- Unit Testing with Vitest - Fast, isolated tests for business logic
- Writing Your Own Tests - Patterns and best practices
Testing Strategy
We recommend this approach:
- Unit tests for pure functions, validators, and business logic (fast feedback)
- E2E tests for critical user flows: authentication, payments, core features (confidence in production)
- Skip integration tests unless you have specific external service integrations
E2E tests in MakerKit run against a real database with seeded data. This catches issues that mocks would miss, like database constraints and auth session handling.
Environment Setup
E2E tests require:
- A running PostgreSQL database (use
pnpm compose:dev:upfor Docker) - Environment variables configured in
apps/e2e/.envorapps/e2e/.env.local - Mailpit running for email verification tests
Unit tests run in isolation with no external dependencies.
Common Pitfalls
Watch out for these when running tests:
- Database not running: Start Docker containers with
pnpm compose:dev:upbefore running E2E tests - Stale build: Run
pnpm --filter web build:testafter code changes - Port conflicts: Ensure nothing else is running on port 3000
- Flaky tests: Run with
--workers=1to isolate timing issues - Missing seed data: Global setup seeds the database, but if you reset it manually, run
pnpm seedfirst