noPlaywrightWaitForTimeout
此内容尚不支持你的语言。
Summary
Section titled “Summary”- Rule available since:
v2.4.2 - Diagnostic Category:
lint/nursery/noPlaywrightWaitForTimeout - This rule doesn’t have a fix.
- The default severity of this rule is information.
- 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": { "nursery": { "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/nursery/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.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
await page.waitForTimeout(1000);code-block.js:1:7 lint/nursery/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.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
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.