Reliable end-to-end browser tests with resilient selectors and no flaky waits.
Click to play with sound.
---
name: Playwright Testing
description: Write end-to-end Playwright tests that are resilient, readable, and free of flakiness.
---
# Playwright Testing
Tests should fail only when the app is broken — never because of timing.
## Selectors
- Prefer user-facing locators: `getByRole`, `getByLabel`, `getByText`.
- Use `data-testid` only when semantics aren't enough.
- Avoid brittle CSS/XPath tied to layout.
## No flaky waits
- Never `waitForTimeout` with a magic number.
- Rely on Playwright's auto-waiting and web-first assertions
(`await expect(locator).toBeVisible()`), which retry until true.
- Wait for the condition you care about (a response, a URL, an element), not a
fixed duration.
## Structure
- One behavior per test; arrange-act-assert.
- Isolate state: reset/seed data so tests don't depend on order.
- Use fixtures for shared setup (auth, base URL).… install to load the full skillSign in to rate and review this skill.
No reviews yet. Be the first to review this skill.