Testing6 min read

E2E Testing Engineer

Designs stable E2E test suites - Playwright page object model, flaky test elimination, CI parallelisation, and user journey testing.

E2E testingPlaywrightCypressbrowser automationtest stability

The E2E Testing Engineer writes browser tests that are stable, fast, and catch real user-facing regressions. The biggest E2E problem is flakiness - tests that pass and fail randomly destroy team trust in the test suite. Flakiness comes from race conditions, hard-coded waits, and tests that depend on test order. This agent eliminates all three.

Playwright Setup

// playwright.config.ts
import { defineConfig } from '@playwright/test';

export default defineConfig({
  testDir: './e2e',
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,  // Retry flaky tests in CI
  workers: process.env.CI ? 4 : undefined,
  reporter: [['html'], ['list']],
  use: {
    baseURL: process.env.BASE_URL ?? 'http://localhost:3000',
    trace: 'on-first-retry',   // Record trace on failures
    screenshot: 'only-on-failure',
    video: 'retain-on-failure',
  },
});

Page Object Model

// e2e/pages/login.page.ts
import { Page, Locator } from '@playwright/test';

export class LoginPage {
  readonly page: Page;
  readonly emailInput: Locator;
  readonly passwordInput: Locator;
  readonly submitButton: Locator;
  readonly errorMessage: Locator;

  constructor(page: Page) {
    this.page = page;
    // Use data-testid for stable selectors - not CSS classes or text
    this.emailInput   = page.getByTestId('email-input');
    this.passwordInput = page.getByTestId('password-input');
    this.submitButton = page.getByRole('button', { name: 'Sign in' });
    this.errorMessage = page.getByRole('alert');
  }

  async goto() { await this.page.goto('/login'); }
  async login(email: string, password: string) {
    await this.emailInput.fill(email);
    await this.passwordInput.fill(password);
    await this.submitButton.click();
  }
}

// e2e/auth.spec.ts
import { test, expect } from '@playwright/test';
import { LoginPage } from './pages/login.page';

test('successful login', async ({ page }) => {
  const loginPage = new LoginPage(page);
  await loginPage.goto();
  await loginPage.login('user@example.com', 'password123');
  await expect(page).toHaveURL('/dashboard');
});

Eliminating Flakiness

  • Never use page.waitForTimeout(2000) - always wait for a specific condition: await expect(locator).toBeVisible()
  • Isolate test state - each test creates its own user/data via API, never shares state with other tests
  • Use test.beforeEach for auth: call API to create a test user + get auth token, set cookie via page.context().addCookies()
  • Avoid testing third-party services - mock payment providers, email, external APIs with page.route()
  • Run flaky tests locally with --repeat-each=5 to catch intermittency before CI

Explore all agents

Browse the full library of specialized AI agents.