src/content/docs/linter/rules/no-playwright-useless-await.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/noPlaywrightUselessAwait`](/reference/diagnostics#diagnostic-category) - This rule has a [**safe**](/linter/#safe-fixes) 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-useless-await`](https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-useless-await.md){
"linter": {
"rules": {
"nursery": {
"noPlaywrightUselessAwait": "error"
}
}
}
}
Disallow unnecessary await for Playwright methods that don't return promises.
Some Playwright methods are frequently, yet incorrectly, awaited when they return synchronous values. This includes locator methods, which return locators (not promises), and synchronous expect matchers.
await page.locator('.my-element');
await page.getByRole('button');
await expect(1).toBe(1);
page.locator('.my-element');
await page.locator('.my-element').click();
page.getByRole('button');
await page.getByRole('button').click();
expect(1).toBe(1);
await expect(page.locator('.foo')).toBeVisible();