Playwright·Cookbook Field Manual
Part 04 · Architecture, Auth & Data Card 25

Default Conventions

Card 25: Default conventions (index)

This card does not add new code; it lists the default conventions from the cookbook and points to the card that demonstrates each.

ConventionCard
Tests describe behavior; they don’t know selectors12-locators-actions-flows
Selectors: getByRole/getByLabel first; data-testid for repeated/dynamic UI13-scoped-queries
Every interaction has a done signal (URL/response/toast/state change)15-done-signals
No waitForTimeout in committed code(policy; see 15-done-signals)
Page/region objects expose assertLoaded() and stay small12-locators-actions-flows, 14-region-objects
Cross-page actions return next page object12-locators-actions-flows (PersonPage.open)
Auth via storageState + one UI login smoke test19-auth-storage-state
Test data via API factories; UI setup only when testing that UI20-api-seeding-cleanup
Trace on first retry, screenshot on failure; test.step for major actions21-app-driver-fixture, 22-failure-artifacts
Axe (or similar) for accessibility17-accessibility-axe
Scoped queries to avoid wrong element13-scoped-queries, 18-stability-techniques
Cleanup that always runs (finally)20-api-seeding-cleanup
Unique naming for parallel runs20-api-seeding-cleanup
API-only tests use request fixture (no browser)23-api-only-tests
Same logic, multiple inputs: parameterize with a loop24-parameterized-tests

Live Demo

👇 This component is what the Playwright test interacts with:

Loading…

Run This Example

pnpm test src/25-default-conventions