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
| Cookbook | What it teaches | Source |
|---|---|---|
| Inline config | tag, annotation, mode, retries, timeout — everything you can pass inline to test() / test.describe() | inline-config.cookbook.ts |
| Fixtures | Custom fixtures, worker scope, auto-use, composition | fixtures.cookbook.ts |
| Network | route, fulfill, abort, modify responses, waitForRequest | network.cookbook.ts |
| Assertions | Web-first, soft, expect.poll, custom matchers, aria snapshots | assertions.cookbook.ts |
| Authentication | storageState, worker auth, multi-user, cookie injection | auth.cookbook.ts |
| Page Objects | Classic POM, component objects, fixture-powered page objects | page-objects.cookbook.ts |
Reading order
If you're new to Playwright, read in this order:
- Inline config — understand what
test()accepts - Assertions — the most important API to internalize
- Fixtures — the dependency-injection system
- Network — mock the network for deterministic tests
- Authentication — skip login on every test
- 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'],