noPlaywrightWaitForTimeout (JavaScript)
Language JavaScript (and super languages)
Summary
Section titled “Summary”- Rule available since:
v2.4.2 - Diagnostic Category:
lint/suspicious/noPlaywrightWaitForTimeout - This rule isn’t recommended, so you need to enable it.
- This rule doesn’t have a fix.
- The default severity of this rule is warning.
- This rule belongs to the following domains:
- Sources:
- Same as
playwright/no-wait-for-timeout
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "suspicious": { "noPlaywrightWaitForTimeout": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”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);Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.