E2E Testing
Use this skill for Playwright E2E coverage that behaves like production users and produces useful diagnostics when it fails.
Workflow
- Identify the critical user journey and its acceptance criteria.
- Inspect existing Playwright config, test layout, fixtures, and selector conventions.
- Add or update tests using resilient locators: roles, labels, text, and
data-testidwhere appropriate. - Prefer Page Object Models for repeated page interactions.
- Wait for specific UI, network, or route conditions rather than arbitrary timeouts.
- Run the smallest relevant E2E target first, then broaden if the flow is critical.
- Capture and report artifacts: HTML report, screenshots, videos, traces, console/network notes when relevant.
Recommended Layout
tests/
e2e/
auth/
features/
api/
fixtures/
pages/
playwright.config.ts
Playwright Practices
- Use
await expect(locator).toBeVisible()or semantic assertions instead of implementation details. - Use
page.waitForResponse()only when the response is a meaningful user-flow signal. - Avoid fixed sleeps unless validating debounce behavior and no better signal exists.
- Configure retries in CI, not as a substitute for fixing race conditions.
- Use
trace: "on-first-retry", failure screenshots, and retained videos for diagnostic value.
Config And CI Defaults
- Prefer explicit reporters that preserve an HTML report and machine-readable output in CI.
- Configure
use.screenshot,use.video, anduse.traceso failures leave useful diagnostics. - Add
webServerwhen the app must run locally for tests. - In CI, upload
playwright-report/and other failure artifacts so failures can be inspected later.
Flake Handling
When a test is flaky:
- Re-run with
--repeat-eachor retries to characterize the failure. - Identify the common failure point and likely race.
- Replace brittle selectors or timing assumptions.
- Quarantine with
test.fixme()only when the flow cannot be stabilized immediately, and include the issue/reason.
Report Format
# E2E Test Report
Status: PASSING | FAILING
Command: `<command>`
Summary:
- Total:
- Passed:
- Failed:
- Flaky:
- Skipped:
Artifacts:
- HTML report:
- Screenshots:
- Videos:
- Traces:
Failures:
- `<test>` (`path:line`): <error and recommended fix>