Skip to main content
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

cd shared
npm install

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:
cp .env.template .env
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:
  1. Set USE_LOCAL_DOCUMENT_STORAGE = True in backend/server/settings/development.py (DO NOT COMMIT)
  2. 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

VariableDescription
BASE_URLBase URL of the application under test
TEST_USER_EMAILEmail for test user authentication
TEST_USER_PASSWORDPassword for test user authentication

Available Test Scripts

ScriptDescription
tests:ma4MA4 E2E tests (default for CI)
tests:parallelAll tests with parallel workers
tests:singleAll tests with single worker
tests:parallel-uiAll tests with browser visible
tests:single-uiSingle 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:
pnpm run tests:report

Using VS Code Playwright Extension

For a better local development experience, use the Playwright Test for VS Code extension:
  1. Install the extension from the VS Code marketplace
  2. Open the e2e folder in VS Code
  3. Use the Testing sidebar to browse, run, and debug individual tests
  4. Click the green play button next to any test to run it
  5. Use the “Show Browser” checkbox to watch tests execute in a visible browser
  6. Set breakpoints in test files for step-by-step debugging