Ir al contenido

noPlaywrightUselessAwait

Esta página aún no está disponible en tu idioma.

biome.json
{
"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');
code-block.js:1:1 lint/nursery/noPlaywrightUselessAwait  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Unnecessary await expression.

> 1 │ await page.locator(‘.my-element’);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

This method does not return a Promise.

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.

Safe fix: Remove unnecessary await

1 │ await·page.locator(‘.my-element’);
------
await page.getByRole('button');
code-block.js:1:1 lint/nursery/noPlaywrightUselessAwait  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Unnecessary await expression.

> 1 │ await page.getByRole(‘button’);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

This method does not return a Promise.

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.

Safe fix: Remove unnecessary await

1 │ await·page.getByRole(‘button’);
------
await expect(1).toBe(1);
code-block.js:1:1 lint/nursery/noPlaywrightUselessAwait  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Unnecessary await expression.

> 1 │ await expect(1).toBe(1);
^^^^^^^^^^^^^^^^^^^^^^^
2 │

This method does not return a Promise.

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.

Safe fix: Remove unnecessary await

1 │ 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();