Todos los packs
StableTestingplaywright
Playwright E2E Testing
Operationalizes reliable E2E testing with Playwright: deterministic waits, resilient selectors, and test isolation practices that keep E2E suites fast and non-flaky.
playwrighte2ebrowser-testingselectorsflakiness
Principios
- · PW1 — Use Playwright's auto-waiting locators (getByRole, getByText, getByLabel) instead of fixed sleep/waitForTimeout.
- · PW2 — Prefer role/label/text-based selectors over CSS class or XPath selectors — resilient to markup changes and doubles as an accessibility check.
- · PW3 — Each test is independent: no test depends on another test's execution or leftover state; use fixtures/beforeEach for setup.
- · PW4 — Tests wait on application state (element visible, network response, specific text), never on arbitrary durations.
- · PW5 — Flaky tests are debugged via trace/video capture, root-caused, and fixed — not retried into passing.
Patrones
- · Grep for waitForTimeout/sleep in test files — each is a candidate for a proper state-based wait.
- · A selector like .css-x7f3a or a deep div > div > span chain → switch to getByRole/getByText/getByLabel.
- · A test failing only in CI, not locally → suspect timing/resource contention; check for auto-waiting bypass or missing await.
- · Two tests failing together but passing individually → shared state leak; check for missing isolation/cleanup.
- · A retry count set high to "make CI green" → the tests are flaky and need root-causing, not more retries.
Riesgos
- · Sleep-driven waits — await page.waitForTimeout(2000) scattered through tests, slow and still occasionally too short.
- · Brittle CSS selectors — .MuiButton-root-482 style auto-generated class selectors breaking on every library upgrade.
- · Shared mutable test fixtures — tests that pass individually but fail when run together due to shared database rows/state.
- · Retry-until-green — raising retry counts to mask flakiness instead of fixing the root cause.
- · E2E test explosion — hundreds of E2E tests covering every UI permutation, making CI take an hour and every test a maintenance burden.
Checklist
- [ ] No fixed sleep/waitForTimeout in test code. (PL1)
- [ ] Role/label/text-based selectors used by default. (PL2)
- [ ] Tests isolated, no shared mutable state across tests. (PL3)
- [ ] Trace/video capture enabled on CI failure. (PL4)
- [ ] E2E coverage scoped to critical journeys. (PL5)
- [ ] Test data seeded per-test via API/fixtures. (PL6)
Fuentes
En la bibliografía AKOS
Este pack cita las siguientes fuentes registradas en el índice bibliográfico:
Explorar todas las fuentes →