E2E Test Suite Design
What you'll build
A well-structured Playwright E2E test suite for a todo app, with page objects, custom fixtures, parallel configuration, and screenshot-based visual regression tests.
Goals
- Design a Page Object Model architecture
- Create reusable custom fixtures
- Configure parallel test execution
- Add visual regression testing with screenshots
Prerequisites
- Playwright or Cypress basics
- CSS selectors
- Async/await
Steps
- 1
Set up the Page Object Model
Create a TodoPage class that encapsulates all interactions with the todo app page — navigation, adding items, marking complete, deleting. Acceptance: the page object has methods for each user action and properties for key elements.
Hint
class TodoPage { constructor(page) { this.page = page; } async goto() { ... } async addItem(text) { ... } }
- 2
Write core E2E tests
Write tests for the main user flows: add a todo, mark it complete, filter by status, delete a todo. Use the page object. Acceptance: each test passes against a running todo app.
Hint
test('add todo', async ({ page }) => { const todo = new TodoPage(page); await todo.goto(); await todo.addItem('Buy milk'); await expect(todo.item('Buy milk')).toBeVisible(); });
- 3
Create custom fixtures
Extend Playwright's test fixture to automatically create a TodoPage instance and optionally seed data. Acceptance: tests can use
const { todoPage } = fixtureswithout manual construction.Hint
test.extend({ todoPage: async ({ page }, use) => { const tp = new TodoPage(page); await tp.goto(); await use(tp); } })
- 4
Configure parallel execution
Configure playwright.config.ts for parallel test execution with workers, and handle test isolation. Acceptance: tests run in parallel without interference, and the config specifies worker count and retry strategy.
Hint
In playwright.config.ts: workers: process.env.CI ? 4 : 2, retries: 2, and use: { storageState: undefined } for isolation.
- 5
Add visual regression tests
Add a screenshot-based visual test that captures the todo app's appearance and compares it on subsequent runs. Acceptance: the test fails when the UI changes visually, with a diff image generated.
Hint
await expect(page).toHaveScreenshot('todo-empty.png'); — Playwright captures and compares automatically.
Try it yourself
What you learned
You designed a professional E2E test suite architecture — page objects for maintainability, fixtures for reusability, parallel execution for speed, and visual testing for UI regressions. This is the structure behind robust E2E suites.
Related Resources
Related Lessons
- E2E Testing
End-to-end testing.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.