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.
| Convention | Card |
|---|---|
| Tests describe behavior; they don’t know selectors | 12-locators-actions-flows |
| Selectors: getByRole/getByLabel first; data-testid for repeated/dynamic UI | 13-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 small | 12-locators-actions-flows, 14-region-objects |
| Cross-page actions return next page object | 12-locators-actions-flows (PersonPage.open) |
| Auth via storageState + one UI login smoke test | 19-auth-storage-state |
| Test data via API factories; UI setup only when testing that UI | 20-api-seeding-cleanup |
| Trace on first retry, screenshot on failure; test.step for major actions | 21-app-driver-fixture, 22-failure-artifacts |
| Axe (or similar) for accessibility | 17-accessibility-axe |
| Scoped queries to avoid wrong element | 13-scoped-queries, 18-stability-techniques |
| Cleanup that always runs (finally) | 20-api-seeding-cleanup |
| Unique naming for parallel runs | 20-api-seeding-cleanup |
API-only tests use request fixture (no browser) | 23-api-only-tests |
| Same logic, multiple inputs: parameterize with a loop | 24-parameterized-tests |
Live Demo
👇 This component is what the Playwright test interacts with:
Loading…
Run This Example
pnpm test src/25-default-conventions