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

New rule: await-user-event to await methods of userEvent #647

Closed
bennettdams opened this issue Sep 16, 2022 · 1 comment
Closed

New rule: await-user-event to await methods of userEvent #647

bennettdams opened this issue Sep 16, 2022 · 1 comment
Labels
duplicate This issue or pull request already exists new rule New rule to be included in the plugin triage Pending to be triaged by a maintainer

Comments

@bennettdams
Copy link

bennettdams commented Sep 16, 2022

Name for new rule

await-user-event

Description of the new rule

Now that the userEvent's methods are all async (with v14), wouldn't it make sense to add a rule to enfore await when using them?

A similar rule already exists for awaiting fireEvent.

Testing Library feature

All usage of userEvent with v14.

Testing Library framework(s)

I guess all of them?

What category of rule is this?

Warns about a potential error

Code examples

import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
...
// click the button to reload the page
const reloadPageButton = screen.getByText('Reload page')
userEvent.click(reloadPageButton)

Instead, it should enforce using await:

- userEvent.click(reloadPageButton)
+ await userEvent.click(reloadPageButton)

Anything else?

I'm not sure if this is even possible to integrate, as this rule should only be active for userEvent usage of v14.

Do you want to submit a pull request to make the new rule?

No

@bennettdams bennettdams added new rule New rule to be included in the plugin triage Pending to be triaged by a maintainer labels Sep 16, 2022
@bennettdams bennettdams changed the title New rule: await-user-event New rule: await-user-event to await methods of userEvent Sep 16, 2022
@Belco90
Copy link
Member

Belco90 commented Sep 16, 2022

Thanks for your submission @bennettdams! We are actually planning to do that in the next major: #626

@Belco90 Belco90 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2022
@MichaelDeBoey MichaelDeBoey added the duplicate This issue or pull request already exists label Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists new rule New rule to be included in the plugin triage Pending to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants