src/content/docs/linter/rules/no-playwright-wait-for-timeout.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: ## Summary - Rule available since: `v2.4.2` - Diagnostic Category: [`lint/nursery/noPlaywrightWaitForTimeout`](/reference/diagnostics#diagnostic-category) - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - This rule belongs to the following domains: - [`playwright`](/linter/domains#playwright) - Sources: - Same as [`playwright/no-wait-for-timeout`](https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-wait-for-timeout.md){
"linter": {
"rules": {
"nursery": {
"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);
await page.waitForTimeout(1000);
await page.waitForLoadState();
await page.waitForURL('/home');
await page.waitForFunction(() => window.innerWidth < 100);