Objective: API checks that live inside your Playwright suite — and assertions that actually mean something.
⏱ ≈65 min full lesson · English edition — Español · العربية · বাংলা in translation
Three jobs: SETUP at machine speed (seed state via API instead of clicking — A-03's door), VERIFICATION beneath the UI (screen says “order placed”; the API says whether an order with the right total EXISTS), and CONTRACT checks (shape, semantics, refusal behavior).
Amateur: assert status = 200, stop. Professional ladder: STATUS semantically (201 for create, 404 for missing, 400 for nonsense — not 500) → SHAPE (required fields, right types; extra fields tolerated) → VALUES THAT MATTER (totals reconcile, IDs echo) → REFUSALS (401 unauthenticated, 403/404 for another user's resource).
Asserting an ENTIRE payload byte-for-byte makes the test a change-detector for every edit — including harmless ones. That's flake by design (A-07). Assert the contract; tolerate growth.
Auth under the standing rules: customer-provided TEST account on STAGING. Credentials in ENVIRONMENT VARIABLES only — never code. A credential in a test file is in every clone, every CI log, every tutorial screenshot. Suites SHOW process.env placeholders; they never contain secrets.
The HYBRID pattern: each surface does what it's most truthful at. UI stays short because the API did the commuting. Most “slow UI suite” rescues are this pattern, applied with discipline.
Take one page with a known API behind it (your browser's Network tab reveals it). Write the four ladder levels for one endpoint on paper: status, shape, two values that matter, one refusal. That page of notes is an API test plan a developer would respect.
Hybrids mastered. Next: debugging and flake control — the taxonomy.