Objective: Journeys that begin mid-story: logged in, cart loaded, data seeded — and leave no wreckage.
⏱ ≈53 min full lesson · English edition — Español · العربية · বাংলা in translation
Real journeys start from a PRECONDITION: “as a logged-in customer with two items in the cart…” That precondition is STATE. The tool for it is the FIXTURE: named, reusable setup a test DECLARES instead of performs. Playwright's page and request are fixtures; custom ones extend the idea to your world.
Seed state through the FASTEST HONEST DOOR. Login as SETUP → API (fast). Login as the SUBJECT of the test → UI (the clicking is what's being tested). Confusing the two is how suites get slow and journeys get fake.
Fixtures authenticate with dedicated TEST accounts on STAGING — never real accounts, never live purchases. A fixture that logs in as a real customer is an incident with a schedule. (The product's standing rule, not a preference.)
Whatever setup created, teardown removes — with a finally-guarantee that runs even when the test fails halfway. Tests that pollute shared state make the NEXT tests liars, and layering (A-02) collapses without independence. Independence is manufactured here.
Four kinds of state — identity (logged-in user), data (products, listings), progress (half-filled form), environment (flags, locale). For one journey, write its STATE CONTRACT: each kind, the door you'd create it through, the teardown that removes it. That contract is 80% of the implementation.
State tamed. Next: forms deep — validation matrices and the staging submission.