intermediate

Playwright and Cypress

Automate browser journeys with stable locators, controlled data, network expectations, retries used sparingly, and artifacts for debugging.

Playwright and Cypress automate real browsers for E2E. Playwright offers multi-browser parallelism, auto-waiting, and strong network interception; Cypress provides an interactive runner and time-travel debugging with a opinionated in-browser architecture.

Use stable locators (`getByRole`, `data-testid` as last resort), seed data via API or DB fixtures, and capture traces/screenshots on failure.

On interviews: compare Playwright's cross-browser CI story with Cypress component testing and when retries are acceptable.

Common pitfalls: hard sleeps instead of assertions, shared environments without isolation, and retry masks that hide real flakes.

The trade-off is rich browser fidelity versus flakiness and maintenance cost of full journeys.

Checklist:

  • Prefer role-based locators and explicit waits.
  • Control test data per run.
  • Limit E2E to critical paths only.