Testy
test/web-first-assertions
Playwright tests assert with auto-retrying web-first matchers (toBeVisible, toHaveText), not on values read once.
umiarkowanastatycznefe-testing
Dlaczego
expect(await locator.isVisible()).toBe(true) reads the page once, at whatever moment the line runs. If the element appears 50 ms later the test fails, so it passes on a fast machine and flakes in CI.
Poprawka
Use the matcher that waits: await expect(locator).toBeVisible(), toHaveText, toHaveValue, toHaveAttribute, toHaveCount, toBeChecked, toHaveURL. Locate with user-facing locators (getByRole, getByLabel, getByText).
Przykłady
// bad
expect(await page.getByRole('status').isVisible()).toBe(true)
// good
await expect(page.getByRole('status')).toBeVisible()Źródła
Fakty
- Identyfikator
test/web-first-assertions- Waga
- umiarkowana
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
jsx- Tylko w projektach z
playwright- Uczy jej skill
fe-testingFront-end testing- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain test/web-first-assertions