eslint-plugin-playwright icon indicating copy to clipboard operation
eslint-plugin-playwright copied to clipboard

Warn about missing expect and locators being awaited pointlessly

Open AlexDaniel opened this issue 3 years ago • 0 comments

Bad:

await page.locator('.hello-world')

The code above is wrong because it doesn't do anything. We just await a locator and then throw it away, but that doesn't test anything.

Good:

await expect(page.locator('.hello-world')).toBeVisible()

or

await page.locator('.hello-world').waitFor()

or anything else, as long as you actually use the locator for something.

AlexDaniel avatar Jul 26 '22 16:07 AlexDaniel