Overview
Documenso uses Playwright for end-to-end (E2E) testing. Tests are organized by type and run in parallel to ensure fast feedback during development.Test Stack
- Framework: Playwright 1.56.1
- Test Location:
packages/app-tests/e2e/ - Configuration:
packages/app-tests/playwright.config.ts - Test Types: API tests, UI tests, License tests
Test Organization
Tests are organized into three categories:API Tests
- Location:
packages/app-tests/e2e/api/**/*.spec.ts - Purpose: Test API endpoints and tRPC routes
- Workers: 10 parallel workers
- Run faster: No browser rendering required
UI Tests
- Location:
packages/app-tests/e2e/**/*.spec.ts(excluding api/ and license/) - Purpose: Test user interface and workflows
- Workers: Dynamic (2-6 workers based on CPU cores)
- Browser: Desktop Chrome (1920x1200 viewport)
License Tests
- Location:
packages/app-tests/e2e/license/**/*.spec.ts - Purpose: Test enterprise license features
- Workers: 1 (serial execution due to shared license file)
- Browser: Desktop Chrome
Running Tests
Quick Start
Ensure services are running
Start the development environment:The application must be running on http://localhost:3000 before running tests.
Test Commands
Test Projects
Playwright is configured with three test projects:API Tests Project
- Fastest tests (no browser)
- 10 parallel workers
- Tests HTTP endpoints and tRPC routes
UI Tests Project
- Browser-based tests
- Dynamic workers (2-6 based on CPU)
- Tests user interactions and workflows
License Tests Project
- Serial execution (1 worker)
- Tests enterprise features
- Requires license file setup
Playwright UI Mode
The Playwright UI provides an interactive testing experience:Writing Tests
Test File Structure
Tests should follow this structure:API Test Example
UI Test Example
Test Configuration
The Playwright configuration is located atpackages/app-tests/playwright.config.ts.
Key Configuration Options
Timeouts
- Test timeout: 60 seconds (entire test)
- Action timeout: 15 seconds (individual actions)
- Navigation timeout: 30 seconds (page navigation)
Retries
- CI: 4 retries on failure
- Local: 1 retry on failure
Trace & Video
Traces and videos are captured on test failures for debugging:Environment Variables for Tests
Test-specific environment variables are defined in.env:
Test Helpers and Fixtures
Common test utilities and fixtures should be created for reusable functionality:Authentication Fixture Example
Debugging Tests
Debugging Failed Tests
Use Playwright Inspector
The Playwright Inspector allows you to:
- Step through test execution
- Inspect page state
- View console logs
- Modify selectors in real-time
Common Debugging Commands
Continuous Integration
Tests run automatically in CI/CD pipelines:CI Command
- Builds the Remix application
- Runs all E2E tests
CI Configuration
In CI environments:- Tests fail fast (stop on first failure)
- 4 retries per test
- Traces and videos captured on failure
- Test reports uploaded as artifacts
Performance Optimization
Worker Calculation
The UI test workers are calculated based on CPU cores:Test Isolation
Each test runs in isolation:- Separate browser context
- Clean database state (via test fixtures)
- No shared state between tests
Best Practices
Test Writing
-
Use data-testid attributes for stable selectors:
-
Wait for explicit conditions:
-
Avoid hard-coded waits:
-
Clean up test data:
Test Organization
- Group related tests in
describeblocks - Use descriptive test names
- Keep tests focused and atomic
- Share setup logic via fixtures
Troubleshooting
Tests Timing Out
Increase timeouts for slow operations:Flaky Tests
-
Add explicit waits:
- Disable animations: The config already disables animations via cookie.
-
Use retry logic for network requests:
