Testing

test/no-fixed-wait

Tests wait for conditions, never for a fixed time (no waitForTimeout, cy.wait(ms) or setTimeout sleeps).

moderatestaticfe-testing

Why

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.

Fix

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()).

Examples

// bad
await page.waitForTimeout(2000)
// good
await expect(page.getByRole('status')).toHaveText('Saved')

Sources

Facts

Id
test/no-fixed-wait
Severity
moderate
Check
static checked in the source by audit
Applies to
jsx
Only in projects with
vitest jest playwright cypress
Taught by the skill
fe-testing Front-end testing
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain test/no-fixed-wait