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

Migrate from fireEvent to user-events #2637

Open
codyebberson opened this issue Aug 7, 2023 · 1 comment
Open

Migrate from fireEvent to user-events #2637

codyebberson opened this issue Aug 7, 2023 · 1 comment
Labels
good first issue Good for newcomers

Comments

@codyebberson
Copy link
Member

While trying to write tests for <CopyButton> (#2634), I found it quite difficult to properly test the hover events and delayed effects. I looked into how Mantine tests those things, and it turns out internally they use user-event:

https://testing-library.com/docs/user-event/intro/#difference-to-fireevent

When to use userEvent.click and when to use fireEvent

Behind the scenes, userEvent uses the fireEvent. You can consider fireEvent being the low-level api, while userEvent sets a flow of actions.

Here is the code for userEvent.click

You can see that depending of which element you are trying to click, userEvent will do a set of different actions (e.g. if it's a label or a checkbox).

There are probably many cases in react and app that could benefit from this.

@Paul-Taiwo
Copy link
Contributor

@codyebberson I would like to work on this.

@rahul1 rahul1 added this to the Milestone Quality milestone Sep 22, 2023
@rahul1 rahul1 added the good first issue Good for newcomers label Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
Status: No status
Development

No branches or pull requests

3 participants