e2e-spec-rules
/e2e-spec-rules
Ustala zasady pisania testów E2E w Playwright: niezależność testów, lokatory widoczne dla użytkownika i dokładne asercje.
- Autor
- smooth-deploy ↗
- Repozytorium
- playwright-skills ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 13.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 13.11.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Ustala zasady pisania testów E2E w Playwright: niezależność testów, lokatory widoczne dla użytkownika i dokładne asercje.
Oryginalny opis (EN)
The rules every Playwright E2E spec in this skill set follows, covering self-contained tests, user-facing locators, exact web-first assertions, and the patterns that disqualify a spec. Use when writing, fixing or reviewing a Playwright E2E spec, and whenever e2e-plan or e2e-repro says to follow the spec rules.
Jak działa
SKILL.md bez nagłówków drugiego poziomu · 19 linii, 720 słów
Podgląd SKILL.md
---
name: e2e-spec-rules
description: The rules every Playwright E2E spec in this skill set follows, covering self-contained tests, user-facing locators, exact web-first assertions, and the patterns that disqualify a spec. Use when writing, fixing or reviewing a Playwright E2E spec, and whenever e2e-plan or e2e-repro says to follow the spec rules.
license: MIT
---
# e2e-spec-rules
Rules for a spec that fails when the feature breaks and for no other reason. ENV is the environment file `.e2e/e2e-env.md`.
- **Self-contained.** Every test reads top to bottom as the user's journey: reset (per ENV), `goto` the first page, log in through the UI where the scenario has an account, then reach every later page the way the user does: click the header link, the record's name, the "Proceed to checkout" link. `goto` only for the first page of a test; a second `goto` skips the navigation the user would have done and tests a route the app never shows. Wait on each page's ready signal (per ENV), then the steps. All of it inline, in every test, as plain Playwright steps. No `beforeEach`, no helper functions, no custom fixtures, no `request` fixture: `async ({ page })` is the only signature. Repetition between tests is correct here; a reader of one test needs nothing else.
- **Locators.** `getByRole`, `getByLabel`, `getByText`; `getByTestId` only when nothing user-facing is unique. Scope with `.filter({ has })` or chain from a row or dialog. No CSS, no `.locator(...)`. A chain through generic text (the "1" inside the Cart link) is a guess, and a chain through `getByRole("paragraph")` or `getByRole("strong")` is DOM structure, not something the user names; there the testid from ENV is the locator. A dropdown is `getByRole("combobox", { name })` by its label text, set with `selectOption({ label })` by the option text the user reads, never by value.
- **Ambiguity.** A locator that matches 0 or 2+ elements is fixed from a fresh live snapshot: scoped (`dialog.getByRole("alert")`) or named (`getByRole("status", { name: ... })`). A label that matches two fields (login and register forms on one page) means the testid from ENV. Never `.first()`, never a try/catch.
- **Ready signal.** Asserted like anything else: `await expect(page.getByTestId("cart-page")).toHaveAttribute("data-state", "ready")`.
- **Rows.** Found by the name the user sees (`getByRole("row", { name: "CI pipeline" })`), never by a seed id. A record's own page is reached the way the user reaches it, by clicking its name, never by `goto` with a seed id in the path (`goto("/products/prod-001")`). The id for a `page.request` URL comes from a GET of the list, found by the same name (`keys.find(k => k.name === "CI pipeline").id`), never typed from seed data.
- **Assertions.** Web-first only (`await expect(locator).toBeVisible()`, `toHaveCount(0)`, `toHaveURL`), on the exact element with the exact value: `toHaveText("paid")`, since `toContainText("paid")` also holds for "unpaid", and a `toHaveCount(1)` on generic text proves nothing. `toContainText` is allowed only for a message with a variable part, never for a plan name, a status, a date or an amount. A URL is asserted as the exact string, `toHaveURL("/account")`, never a regex.
- **Transient text** (toast, spinner, "Saving…"). Assert it only when the ticket claims it. To wait for an action, use the durable state it produces (the cart count, the new row).
- **Absence.** `await expect(row.getByRole("button", { name: "Remove" })).toHaveCount(0)` scoped to the row, never an unscoped `getByText`. A hidden element keeps its text, and `toHaveText` passes on text the user cannot see; what the ticket calls hidden, gone or empty is asserted with `toBeHidden()` or `toHaveCount(0)` on that element, never with its leftover text (a badge reading "0" under `hidden` is hidden, not "0").
- **State that must persist or stay unchanged.** A committed state change the ticket says persists (an item added, a member removed, a plan switched): assert the new state as the page shows it, `reload`, wait for ready, assert it again. The first proves the UI reacted, the second proves the server kept it. Unchanged state after an error gets the same pair. One reload per committed change, on the page that shows it; never on a page with a form in progress, and never after a sign-in or a navigation, which changed nothing the ticket claims.
- **Passwords.** `process.env.E2E_PASSWORD_<NAME>`, the variable ENV names. Never the literal value.
- **URLs.** Relative everywhere, `goto("/settings")` and `page.request.delete("/api/...")` alike. The base URL lives in the Playwright config, never in the spec.
Disqualified, each one on its own: `waitForTimeout`, `if (await x.isVisible())`, `.catch(() => ...)` on a locator, regex locators guessing the UI (`/log ?in|sign ?in/`), `page.on("dialog")` for a dialog never seen live, `.first()`/`.last()`/`.nth()` to silence ambiguity, `.or()` to hedge between two guesses (`.and()` and `.filter()` narrow and are fine).
Wersje
W bazie nie ma innych skilli o nazwie e2e-spec-rules.
Migawka bazy z 13.11.2026 · wersja paczki 655e2a11ba56 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 2 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100playwright-testing
Stosuje wzorce testów E2E w Playwright: asercje web-first, locatory widoczne dla użytkownika, przechwytywanie sieci, fixtures, uwierzytelnianie i równoległość; przydaje się też przy migracji z Cypress lub Selenium. - 100playwright
Opisuje framework Playwright do testów E2E: automatyzację przeglądarki, asercje i generowanie testów, w tym lokatory, testy międzyprzeglądarkowe i regresję wizualną. - 100playwright-e2e-testing
Pisze, poprawia i przegląda testy E2E w Playwright dla aplikacji Next.js, w tym lokatory, logowanie i testy niestabilne. - 100playwright-testing
Prowadzi pisanie testów end-to-end w Playwright Test: lokatory, asercje, mockowanie żądań sieciowych, uwierzytelnianie i konfigurację test runnera. - 100writing-playwright-e2e-tests
Opisuje standard testów E2E w Playwright: mapowanie kryteriów na scenariusze, Page Object, lokatory widoczne dla użytkownika i ograniczone limity debugowania. - 95qa-e2e-playwright
Pisze i porządkuje zestawy testów Playwright w TypeScript: konfigurację, lokatory, uwierzytelnianie, mocki i sharding w CI.