Skip to main content

Cookbooks

Each cookbook is a runnable .ts file under tests/saucedemo/ plus a docs page that explains the patterns. Read the doc, then open the file to see the working code.

Index

CookbookWhat it teachesSource
Inline configtag, annotation, mode, retries, timeout — everything you can pass inline to test() / test.describe()inline-config.cookbook.ts
FixturesCustom fixtures, worker scope, auto-use, compositionfixtures.cookbook.ts
Networkroute, fulfill, abort, modify responses, waitForRequestnetwork.cookbook.ts
AssertionsWeb-first, soft, expect.poll, custom matchers, aria snapshotsassertions.cookbook.ts
AuthenticationstorageState, worker auth, multi-user, cookie injectionauth.cookbook.ts
Page ObjectsClassic POM, component objects, fixture-powered page objectspage-objects.cookbook.ts

Reading order

If you're new to Playwright, read in this order:

  1. Inline config — understand what test() accepts
  2. Assertions — the most important API to internalize
  3. Fixtures — the dependency-injection system
  4. Network — mock the network for deterministic tests
  5. Authentication — skip login on every test
  6. Page Objects — structure tests as the suite grows

How to run a cookbook

Each cookbook file is a real Playwright spec. Run individually:

npx playwright test tests/saucedemo/inline-config.cookbook.ts --project=chromium

Or just run the lot:

make test

Cookbook tests are tagged so they run alongside the real tests. To exclude them from CI, add to playwright.config.ts:

testIgnore: ['**/*.cookbook.ts'],