Run a single file with npx playwright test tests/login.spec.ts. If it fails, add --headed to watch the browser, or --debug to step through with the Playwright Inspector.
npx playwright test tests/login.spec.ts --headed
npx playwright test tests/login.spec.ts --debug
What Playwright Waits For Automatically
goto waits for the load event (configurable via waitUntil).
Clicks wait for the element to be visible, stable, and enabled.
Assertions like toBeVisible() retry until pass or timeout.
Common Mistakes
Using brittle CSS selectors instead of getByRole or getByLabel on the first test.
Not awaiting click() before asserting on the result page.
Asserting immediately with a plain string compare instead of expect().toHaveURL().
Testing against production instead of a local or staging environment.
Key Takeaways
Plan user steps in English, then map each to a Playwright API call.
Role and label locators make first tests readable and resilient.
Use --headed and --debug while learning, headless in CI.
Pro Tip
After your first test passes, run npx playwright codegen http://localhost:3000/login and compare its locators to yours — adjust toward the generated patterns when they are clearer.
Continue with Playwright vs Cypress to build on what you learned here.