eslint-plugin-storybook
eslint-plugin-storybook copied to clipboard
await-interactions false positive in case of userEvent.setup function suggested by v14 api
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
- Install latest version of
@storybook/testing-library(0.2.0 in my case) - Import
userEventconstructor. - Define play function to any story you need.
- Declare
userEvent.setup();statement as it recommended in latest user-event section. - See the validation error.
Expected behavior
Validation error should not be triggered on setup method.
Screenshots
Hey @boonya thanks a lot for flagging this! Would you be open to making a PR that fixes it? Thanks!
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 ;)
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.
This is what I have so far https://github.com/storybookjs/eslint-plugin-storybook/pull/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.
Looks like this is something related https://github.com/testing-library/eslint-plugin-testing-library/pull/817