testing-library / testing-library/testing-library-docs

[userEvent/fireEvent]: fireEvent docs say to use userEvent, but all React code samples use fireEvent

Open
#963 6 comments 0 reactions 0 assignees View on GitHub

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:

firing-events

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:

  1. Observe all code samples in https://testing-library.com/docs/react-testing-library/intro use fireEvent
  2. Observe fireEvent API documentation recommends userEvent

Expected behavior:

The userEvent API is present in React code samples

Screenshots:

N/A

Desktop:

N/A

Smartphone:

N/A

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.