testing-library / testing-library/testing-library-docs
[userEvent/fireEvent]: fireEvent docs say to use userEvent, but all React code samples use fireEvent
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 479
- Forks
- 740
- PR merge metrics
- No merged PRs in 30d
Description
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 use fireEvent or userEvent.
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 for fireEvent give an impression that userEvent is more useful in most projects.
Thanks!
To Reproduce:
- Observe all code samples in https://testing-library.com/docs/react-testing-library/intro use
fireEvent - Observe
fireEventAPI documentation recommendsuserEvent
Expected behavior:
The userEvent API is present in React code samples
Screenshots:
N/A
Desktop:
N/A
Smartphone:
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the React documentation examples linked in the issue, including the example intro, API/AsFragment page, cheatsheet, and intro, alongside the DOM Testing Library fireEvent guidance. Update the relevant examples so the relationship between fireEvent and userEvent is consistent and clear, then verify the documentation examples show the expected userEvent API usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation, testing
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100