Testy
test/no-fixed-wait
Tests wait for conditions, never for a fixed time (no waitForTimeout, cy.wait(ms) or setTimeout sleeps).
umiarkowanastatycznefe-testing
Dlaczego
A fixed wait is either too short on a slow CI machine (the test flakes) or too long everywhere else (the suite crawls). Flaky tests teach the team to rerun and ignore failures.
Poprawka
Wait for what the user waits for: Playwright web-first assertions (await expect(locator).toBeVisible(), toHaveText, toHaveURL), Cypress route aliases (cy.intercept(...).as('save') then cy.wait('@save')) and assertions, Testing Library findBy* queries. In unit tests control time with fake timers (vi.useFakeTimers(), jest.useFakeTimers()).
Przykłady
// bad
await page.waitForTimeout(2000)
// good
await expect(page.getByRole('status')).toHaveText('Saved')Źródła
Fakty
- Identyfikator
test/no-fixed-wait- Waga
- umiarkowana
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
jsx- Tylko w projektach z
vitestjestplaywrightcypress- Uczy jej skill
fe-testingFront-end testing- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain test/no-fixed-wait