Skip to content

[await-async-utils] false positive promise all #227

Closed
@Mikeysauce

Description

@Mikeysauce

Hello,

Take the following example:

await Promise.all([
    waitFor(() =>
      expect(getByText('first-item')).toBeTruthy()
    ),
    waitFor(() =>
      expect(getByText('second-item')).toBeTruthy()
    ),
  ]);

This is flagged up as an error: "Promise returned from waitFor must be handled", which I believe is a false positive, as the Promise is indeed being handled by the Promise.all.

Thanks

Activity

gndelia

gndelia commented on Sep 8, 2020

@gndelia
Collaborator

Hi Mikey!
If you are waiting for of those two to appear, perhaps you could consider findByText as an alternative

await Promise.all([findByText('first-item'), findByText('second-item')])

As of the code itself, yeah it sounds like a bug

Thanks for opening the ticket!

Mikeysauce

Mikeysauce commented on Sep 8, 2020

@Mikeysauce
Author

Thanks gndelia,

I'm in agreement with you regarding findBy being more suitable here with it having a built in waitFor behaviour, but some colleagues find the intent of waitFor to be more explicit and so here we are unfortunately. I appreciate the quick reply!

self-assigned this
on Oct 6, 2020
added a commit that references this issue on Oct 12, 2020
6ce0140
Belco90

Belco90 commented on Oct 12, 2020

@Belco90
Member

🎉 This issue has been resolved in version 3.9.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingreleased

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @gndelia@Mikeysauce@Belco90

    Issue actions

      [await-async-utils] false positive promise all · Issue #227 · testing-library/eslint-plugin-testing-library