testing-library / testing-library/eslint-plugin-testing-library

Support React Native events in prefer-user-event

Open
#957 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
1.1k
Forks
168
Avg merge
15h 44m
Merged PRs (30d)
14

Description

What rule do you want to change?

prefer-user-event

Does this change cause the rule to produce more or fewer warnings?

More warnings

How will the change be implemented?

Add more fireEvent -> userEvent mappings.

React Native Testing Library has its own fireEvent function and the same idea of proposing to use userEvent if possible.

According to the docs, it's recommended to use:

  • User Event press instead of fireEvent.press
  • User Event type instead of fireEvent.changeText
  • User Event scrollTo instead of fireEvent.scroll
Example code
fireEvent.press(screen.getByText('Press me'))
How does the current rule affect the code?

It doesn't suggest any changes to fireEvent calls for React Native projects.

How will the new rule affect the code?

It'll suggest to use User Event as per the docs.

Anything else?

No response

Do you want to submit a pull request to change the rule?

Yes

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

Start with the prefer-user-event rule and the React Native Testing Library fire-event documentation linked in the issue. Check the existing fireEvent-to-userEvent mappings and add coverage for press, changeText, and scroll; done means the example calls produce the intended suggestions.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
mobile-dev, testing-qa, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.