e2e-testing
Installation
SKILL.md
End-to-End (E2E) Testing
E2E tests validate complete user journeys through the real UI, backend and data store. They are the most realistic and the most expensive tests: keep few, make them critical, make them reliable.
Which journeys deserve an E2E test
- Money/conversion: search → cart → checkout → payment sandbox → confirmation (
payment-ecommerce-testing). - Identity: sign-up, sign-in, OAuth redirect, password reset, logout, session expiry.
- Core data mutation: create → edit → save → reload and verify persistence → delete.
- Error recovery: validation errors, network failure banner, retry, empty states.
- Permissions: the same journey per role (admin vs member vs read-only).
Everything else belongs at API/component level (
test-architect). Target a suite you can run in < 15 min with sharding.
Golden rules
- User-facing locators first:
getByRole,getByLabel,getByText; thengetByTestId; avoid brittle CSS/XPath (div > span:nth-child(3)) and styling classes. - Auto-wait, never sleep. Assert on conditions:
await expect(page.getByRole('alert')).toBeVisible(). - Independent tests. Each test sets up its own data via API and starts from a clean context; log in via stored auth state, not the UI, every time.
- Control the world: stub or sandbox third parties, freeze time when relevant, seed deterministic data (
test-environment-management). - Evidence on failure: trace, video, screenshot, console and network logs, retained as CI artifacts.
- One journey per test, with meaningful assertions at each milestone (not 40 clicks then one assert).