eslint-plugin-playwright
eslint-plugin-playwright copied to clipboard
/missing-playwright-await > silent rule when using it in Promises
Having the following block produce a missing-playwright-await error

await Promise.all([
expect(previewLessonPage.relatedContent.title).toBeHidden(),
expect(previewLessonPage.relatedContent.items).toHaveCount(0),
]);
Those cases should not produce errors considering that we're handling them into a Promise already and that promise it's being awaited.
What's the use case? Your example could just as easily be written like so:
await expect(previewLessonPage.relatedContent.title).toBeHidden()
await expect(previewLessonPage.relatedContent.items).toHaveCount(0)
Yes, agreed that it could be easily done in that way, the real use case it's that for many tests in our project we're running bulk assertions into several pages by using the following concept:
Promise.all() + several soft assertions, we call them basic_navigation.spec.js, those are intended to run for every view of our app in order to know that there's no white screen after deployments, and by using soft assertions we're able to run all of them at the same time getting results for every assertion without interrupting the execution if something fails (because they are soft) and in order to improve performance we are wrapping them into Promise.all so they run faster (avoiding sequential execution).
As we need our tests running ASAP after deployments for this particular suite time matters and using Promise.all we add some speed up.
Here's a real case of us:
await Promise.all([
expect.soft(contentPackagePage.list).toBeVisible(),
expect.soft(contentPackagePage.searchBar).toBeVisible(),
expect.soft(contentPackagePage.allLesson.first()).toBeVisible(),
[...and many more...]
]);
In order to clarify we made this assertions only when the loading time between the elements asserted is shared and they all are supposed to load and be ready at the same time, we've many places where we place one-time assertions without using the soft validation, and using explicit awaits.
Interesting, that seems like a really niche use case, but adding support for promise.all shouldn't be to difficult.
Thank you, we'll appreciate a lot this addition 🙌🏻
Nice, thank you @mskelton 🙌🏻 🚀