Skip to main content
This playbook is specifically about full-stack browser E2E tests using Playwright in packages/tests-e2e/. For the canonical 4-layer testing taxonomy across the whole monorepo (unit / integration / e2e / smoke) — and to decide whether your test actually belongs at the E2E layer at all — see the Testing Strategy playbook.

Overview

Our full-stack browser E2E suite uses Playwright to ensure critical user workflows function correctly across the application. The tests are organized using the Page Object Model pattern to maintain clean, reusable, and maintainable test code. This playbook outlines the structure, conventions, and best practices for writing e2e tests.

Project Structure

This playbook provides a comprehensive guide for writing e2e tests following the established patterns in your codebase. It covers the Page Object Model structure, test organization, configuration management, and best practices for maintaining reliable e2e tests.

Page Object Model Pattern

Base Page Structure

All page objects extend the BasePage class and follow a consistent structure:

Page Object Guidelines

❌ Don’t do

✅ Do

Test Organization

Test File Structure

Test files should be organized by feature or workflow:

Test Naming Conventions

  • Use descriptive test names that explain the expected behavior
  • Follow the pattern: should [action] [expected result]
  • Include context when relevant

Configuration Management

Environment Configuration

Use the centralized config utility to handle different environments:

Environment Variables

Required environment variables for CI/CD:
  • E2E_INSTANCE_URL: Target application URL
  • E2E_EMAIL: Test user email
  • E2E_PASSWORD: Test user password

Writing Effective Tests

Test Structure

Follow this pattern for comprehensive tests:

Wait Strategies

Use appropriate wait strategies instead of fixed timeouts:

Error Handling

Implement proper error handling and cleanup:

Best Practices

Element Selection

Prefer semantic selectors over CSS selectors:

Test Data Management

Use dynamic test data to avoid conflicts:

Assertions

Use meaningful assertions that verify business logic:

Running Tests

Local Development & Debugging with Checkly

We use Checkly to run and debug E2E tests. Checkly provides video recordings for each test run, making it easy to debug failures.
  • Test results, including video recordings, are available in the Checkly dashboard.
  • You can debug failed tests by reviewing the video and logs provided by Checkly.

Deploying Tests

Manual deployment is rarely needed, but you can trigger it with:
Tests are deployed to Checkly automatically after successful test runs in the CI pipeline.

Debugging Tests

1. Checkly Videos and Reports

When running tests with Checkly, each test execution is recorded and detailed reports are generated. This is the fastest way to debug failures:
  • Video recordings: Watch the exact browser session for any test run.
  • Step-by-step logs: Review detailed logs and screenshots for each test step.
  • Access: Open the Checkly dashboard and navigate to the relevant test run to view videos and reports.

2. VSCode Extension

For the best local debugging experience, install the Playwright Test for VSCode extension:
  1. Open VSCode Extensions (Ctrl+Shift+X)
  2. Search for “Playwright Test for VSCode”
  3. Install the extension by Microsoft
Benefits:
  • Debug tests directly in VSCode with breakpoints
  • Step-through test execution
  • View test results and traces in the Test Explorer
  • Auto-completion for Playwright APIs
  • Integrated test runner

3. Debugging Tips

  1. Use Checkly dashboard: Review videos and logs for failed tests.
  2. Use VSCode Extension: Set breakpoints directly in your test files.
  3. Step Through: Use F10 (step over) and F11 (step into) in debug mode.
  4. Inspect Elements: Use await page.pause() to pause execution and inspect the page.
  5. Console Logs: Add console.log() statements to track execution flow.
  6. Manual Screenshots: Take screenshots at critical points for visual debugging.

Common Patterns

Authentication Flow

Flow Creation and Testing

API Integration Testing

Maintenance Guidelines

Updating Selectors

When UI changes occur:
  1. Update page object getters with new selectors
  2. Test the changes locally
  3. Update related tests if necessary
  4. Ensure all tests pass before merging

Adding New Tests

  1. Create or update relevant page objects
  2. Write test scenarios in appropriate spec files
  3. Follow the established patterns and conventions
  4. Add proper error handling and cleanup
  5. Test locally before submitting

Performance Considerations

  • Keep tests focused and avoid unnecessary steps
  • Use appropriate timeouts (not too short, not too long)
  • Clean up test data to avoid conflicts
  • Group related tests in the same describe block