This project contains end-to-end tests using Playwright. This guide covers both Docker-based and local execution.
Running via Docker Compose
The recommended approach for running E2E tests is using the compose.sh script, which handles fetching the correct PostgreSQL image with seeded test data.
Prerequisites
Before running Docker Compose locally, authenticate with Namespace:
nsc login
nsc docker login
CI Mode (Full Test Run)
Builds all services, runs tests, and exits with the test result code:
./backend/docker/e2e/scripts/compose.sh --ci seeded
Local Development Mode
Starts all services and follows logs (useful for debugging):
./backend/docker/e2e/scripts/compose.sh seeded
Tear Down
Stop and remove all containers:
./backend/docker/e2e/scripts/compose.sh down
Image Types
seeded (default): PostgreSQL image pre-loaded with test data
empty: Empty PostgreSQL image
Running Locally
Generally, we recommend using the Docker Compose configuration instead of running locally. This ensures a clean and reproducible environment.
1. Install Shared Dependencies
2. Install E2E Dependencies
cd e2e
pnpm install
npx playwright install
3. Create Environment File
In the root of the e2e directory, create a .env file using .env.template:
Fill in the values with your test user credentials and base URL of the application.
4. Seed the Local Database
To import customer data for testing:
- Set
USE_LOCAL_DOCUMENT_STORAGE = True in backend/server/settings/development.py (DO NOT COMMIT)
- Run the following commands:
just generate-fixtures
just intg load-customers-specific mrc_ma
5. Start Required Services
Ensure the following services are running before executing tests:
just run-server # Django backend (port 8000)
just run-celery # Celery workers
cd frontend && pnpm start # Frontend (http://localhost:3000)
6. Run the Tests
pnpm run tests:ma4 # Run MA4 test suite
pnpm run tests:parallel # Run all tests in parallel
pnpm run tests:single # Run all tests with single worker
pnpm run tests:report # View test report
Test Configuration
Environment Variables
| Variable | Description |
|---|
BASE_URL | Base URL of the application under test |
TEST_USER_EMAIL | Email for test user authentication |
TEST_USER_PASSWORD | Password for test user authentication |
Available Test Scripts
| Script | Description |
|---|
tests:ma4 | MA4 E2E tests (default for CI) |
tests:parallel | All tests with parallel workers |
tests:single | All tests with single worker |
tests:parallel-ui | All tests with browser visible |
tests:single-ui | Single worker with browser visible |
Adjusting Test Scope
To run a subset of tests, use Playwright’s filtering:
# Run specific test file
npx playwright test tests/my-test.spec.ts
# Run tests matching a pattern
npx playwright test -g "capital call"
Writing E2E Tests
E2E tests are located in the e2e/tests directory. Use Playwright’s testing API:
import { test, expect } from '@playwright/test';
test('example test', async ({ page }) => {
await page.goto('/');
await expect(page.locator('h1')).toContainText('Welcome');
});
Debugging Tests
Run in Headed Mode
pnpm run tests:parallel-ui
# or
npx playwright test --headed
Use Playwright Inspector
npx playwright test --debug
View Test Report
After running tests:
Using VS Code Playwright Extension
For a better local development experience, use the Playwright Test for VS Code extension:
- Install the extension from the VS Code marketplace
- Open the
e2e folder in VS Code
- Use the Testing sidebar to browse, run, and debug individual tests
- Click the green play button next to any test to run it
- Use the “Show Browser” checkbox to watch tests execute in a visible browser
- Set breakpoints in test files for step-by-step debugging