Skip to content

noPlaywrightWaitForTimeout (JavaScript)

Language JavaScript (and super languages)
biome.json
{
"linter": {
"rules": {
"suspicious": {
"noPlaywrightWaitForTimeout": "error"
}
}
}
}

Disallow using page.waitForTimeout().

Playwright provides methods like page.waitForLoadState(), page.waitForURL(), and page.waitForFunction() which are better alternatives to using hardcoded timeouts. These methods wait for specific conditions and are more reliable than arbitrary timeouts.

await page.waitForTimeout(5000);
code-block.js:1:7 lint/suspicious/noPlaywrightWaitForTimeout ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Unexpected use of page.waitForTimeout().

> 1 │ await page.waitForTimeout(5000);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

ℹ Hardcoded timeouts are flaky and make tests slower. Use conditions that wait for specific events.

ℹ Prefer using built-in wait methods like page.waitForLoadState(), page.waitForURL(), or page.waitForFunction() instead.

ℹ Consider using web-first assertions like expect(locator).toBeVisible() which auto-wait for conditions.

await page.waitForTimeout(1000);
code-block.js:1:7 lint/suspicious/noPlaywrightWaitForTimeout ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Unexpected use of page.waitForTimeout().

> 1 │ await page.waitForTimeout(1000);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

ℹ Hardcoded timeouts are flaky and make tests slower. Use conditions that wait for specific events.

ℹ Prefer using built-in wait methods like page.waitForLoadState(), page.waitForURL(), or page.waitForFunction() instead.

ℹ Consider using web-first assertions like expect(locator).toBeVisible() which auto-wait for conditions.

await page.waitForLoadState();
await page.waitForURL('/home');
await page.waitForFunction(() => window.innerWidth < 100);