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

Support React Native events in prefer-user-event #957

Open
ddrozdov opened this issue Nov 7, 2024 · 3 comments · May be fixed by #958
Open

Support React Native events in prefer-user-event #957

ddrozdov opened this issue Nov 7, 2024 · 3 comments · May be fixed by #958
Labels
enhancement New feature or request triage Pending to be triaged by a maintainer

Comments

@ddrozdov
Copy link

ddrozdov commented Nov 7, 2024

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

@ddrozdov ddrozdov added enhancement New feature or request triage Pending to be triaged by a maintainer labels Nov 7, 2024
ddrozdov pushed a commit to sport24ru/eslint-plugin-testing-library that referenced this issue Nov 7, 2024
@ddrozdov ddrozdov linked a pull request Nov 7, 2024 that will close this issue
1 task
@MichaelDeBoey
Copy link
Member

@ddrozdov This plugin (currently) doesn't support @testing-library/react-native.

I'll let @Belco90 decide what to do with this, but imo we should not add this and add full support in 1 go instead

@ddrozdov
Copy link
Author

ddrozdov commented Nov 7, 2024

Well, it actually works fine out of the box for our project, just some checks are missing which is anyway normal for a linter as there's always room for improvement :)

Or am I missing something important that is required to declare React Native support?

@MichaelDeBoey
Copy link
Member

@ddrozdov I just think we should make sure we take time to check if all rules are supporting RN before say we officially support RN in this plugin

For the least I think it means we would also need to merge #956, but there's probably other things as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage Pending to be triaged by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants