Skip to content

How to understand a Playwright end-to-end tests codebase

End-to-end tests describe what users actually do, step by step, in a real browser. They are one of the quickest ways to learn the important flows of an unfamiliar product, as long as you understand the fixtures and setup that run before each test.

How to tell it's Playwright end-to-end tests

  • playwright.config.ts and @playwright/test in devDependencies
  • An e2e/ or tests/ folder with test(...) calls using page
  • Fixtures defined with test.extend and auth state files

Where things usually live

playwright.config.ts
Base URL, browsers (projects), retries, the webServer that starts the app.
e2e/*.spec.ts
Test files, usually one per flow.
e2e/fixtures.ts
Custom fixtures such as a logged-in page or seeded data.
e2e/pages/
Page objects wrapping selectors and actions.
e2e/auth.setup.ts
Logs in once and saves storageState for other tests.

Conventions, not rules. Real projects rename and move things, so confirm against the repository.

Where to start reading

  1. The config, especially webServer and projects
  2. Setup projects and fixtures
  3. The spec for the flow you care about

How a request moves through the code

  1. 1Playwright starts the app with webServer if configured.
  2. 2Setup projects run first, often signing in and saving storage state.
  3. 3Each test gets fixtures, opens pages and performs user actions.
  4. 4Assertions such as expect(locator).toBeVisible() retry until they pass or time out.

Questions to ask about the repository

  • Which user flows are covered end to end?
  • How do tests log in, and with which test accounts?
  • Which flows are missing coverage?

What trips people up

  • Tests depend on fixture setup that runs elsewhere; reading a spec alone can miss the starting state.
  • Selectors tied to CSS classes break often; role- and test-ID-based locators are more stable.