-
Notifications
You must be signed in to change notification settings - Fork 721
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
[userEvent/fireEvent]: fireEvent docs say to use userEvent, but all React code samples use fireEvent #963
Comments
Our thought was that maybe the code samples need an update - we're unsure, but just wanted to point out our initial confusion on this topic. Thanks for taking a look! Perhaps the primary location for it would be in the cheatsheet? Or at least a disclaimer in the cheatsheet? |
Yes! As @vapurrmaid said, we were confused on which should be used. We're more than happy to raise a PR to update the docs! |
Hi @vapurrmaid and @jsjoeio, thanks for taking the time to open this :) |
We should reconsider this when #980 is merged |
@ph-fritsche |
I've got the impression that more people than we probably like to admit do not take the time to read the docs. They take the first example that vaguely might depict their problem and copy it into their test. I think a bad test is worse than no test, as the false confidence gained per this test might present another obstacle in rewriting the component under test. We won't be able to change how people approach this, but we might be able to steer them in the right direction by presenting them best practices at first glance. |
Description:
Hey there 👋 - our team is newer to
testing-library/react
, and just had a bit of confusion in PR review whereby we went back and forth on whether to usefireEvent
oruserEvent
.All of the code examples in the react documentation:
https://testing-library.com/docs/react-testing-library/example-intro
https://testing-library.com/docs/react-testing-library/api/#asfragment
https://testing-library.com/docs/react-testing-library/cheatsheet/
use
fireEvent
, but then my colleague saw this:from the core API https://testing-library.com/docs/dom-testing-library/api-events
We're wondering if maybe some of the code examples in the React documentation should use
userEvent
, given that the API docs forfireEvent
give an impression thatuserEvent
is more useful in most projects.Thanks!
To Reproduce:
fireEvent
fireEvent
API documentation recommendsuserEvent
Expected behavior:
The
userEvent
API is present in React code samplesScreenshots:
N/A
Desktop:
N/A
Smartphone:
N/A
The text was updated successfully, but these errors were encountered: