Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

await-interactions false positive in case of userEvent.setup function suggested by v14 api #132

Open
boonya opened this issue Jul 10, 2023 · 5 comments

Comments

@boonya
Copy link

boonya commented Jul 10, 2023

Describe the bug

Latest version of user-event lib recommends to use a little bit different API. Instead of using userEvent.click they suggest to create user-event instance first by invoking const events = userEvent.setup(). And then use any event available e.g. await events.click(). userEvent.setup returns an object directly without promise, so it shouldn't be awaiten. But the rule "storybook/await-interactions" reports an issue there.

To Reproduce

  1. Install latest version of @storybook/testing-library (0.2.0 in my case)
  2. Import userEvent constructor.
  3. Define play function to any story you need.
  4. Declare userEvent.setup(); statement as it recommended in latest user-event section.
  5. See the validation error.

Expected behavior
Validation error should not be triggered on setup method.

Screenshots
image

@yannbf
Copy link
Member

yannbf commented Jul 16, 2023

Hey @boonya thanks a lot for flagging this! Would you be open to making a PR that fixes it? Thanks!

@boonya
Copy link
Author

boonya commented Jul 19, 2023

Hey @boonya thanks a lot for flagging this! Would you be open to making a PR that fixes it? Thanks!

With pleasure... When I have a time and inspiration ;)

@moeyashi
Copy link

moeyashi commented Sep 8, 2023

I tried to work on this issue, but I was frustrated because I am new to eslint plugin development.
The existing API determines the userEvent object by its name, so I couldn't figure out how to determine the variable created in userEvent.setup.
I'll try some more when I have time, but I'd be happy if there were contributions from experts until then.

@boonya
Copy link
Author

boonya commented Sep 25, 2023

This is what I have so far #142
But I am a little bit stuck, caue I don't see how to integrate expectation of await before the variable created by userEvent.setup(). I'll try a bit later, but may be someone has some suggestion or idea.

@boonya
Copy link
Author

boonya commented Sep 29, 2023

Looks like this is something related testing-library/eslint-plugin-testing-library#817

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants