src/content/docs/linter/rules/no-playwright-force-option.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/noPlaywrightForceOption`](/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-force-option`](https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-force-option.md){
"linter": {
"rules": {
"nursery": {
"noPlaywrightForceOption": "error"
}
}
}
}
Disallow usage of the { force: true } option.
Playwright's force option bypasses actionability checks and can lead to unreliable tests.
Instead of using { force: true }, you should fix the underlying issue that requires forcing the action.
await page.locator('button').click({ force: true });
await page.locator('check').check({ force: true });
await page.locator('input').fill('text', { force: true });
await page.locator('button').click();
await page.locator('check').check();
await page.locator('input').fill('text');