-
Notifications
You must be signed in to change notification settings - Fork 142
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
False positives for find*
queries from react-test-renderer
#673
Comments
Couldn't we just get away with explicitly excluding |
I'm afraid not because that would silence legit custom queries named like that. |
Just making a note to whomever will fix this bug, there's another issue related to |
Indeed. Does this function already exist? Is it capable of tracking the origin of the |
No, not yet. |
findBy*
queries from react-test-rendererfind*
queries from react-test-renderer
find*
queries from react-test-rendererfind*
queries from react-test-renderer
After @notjosh's clarification on #703 I'm repurposing this ticket, so we just exclude |
Taking care of this one! |
I've closed my original PR #709 since such workaround could lead to other problems. I don't have enough time to implement the ideal fix, but I've updated the issue again with more details about how it should be done. As a temporary workaround, I'll create a PR to mention this in the Troubleshooting section. |
Sorry to be dense, but I'm seeing false positives for I've really tried following the Troubleshooting section mentioned in this comment, but I can't figure it out. What exactly would I have to add in my eslint configuration to exempt Edit: I got it, just do:
|
Have you read the Troubleshooting section?
Yes
Plugin version
v5.7.2
ESLint version
v8.25.0
Node.js version
16.15.0
package manager and version
n/a
Operating system
n/a
Bug description
The
react-test-renderer
library provides several utils which match thefind*
query pattern:findByType
,findByProps
,findAll
,findAllByType
,findAllByProps
.These methods are provided from a
react-test-renderer
instance, or any React Native Testing Library query. They should be ignored, so they are not treated as Testing Library queries (since they actually aren't).This should apply to all rules, so it must be implemented in the
isQuery
internal helper. This function should ignore the queries listed before if they were imported fromreact-test-renderer
or@testing-library/react-native
. Checking the imports from the latter it's important sincereact-native-testing-library
queries return nodes with the mentioned utils, so it's possible to do something likegetByRole('modal').findByProps('bar')
, hence ignoringreact-test-renderer
utils if coming from@testing-library/react-native
Steps to reproduce
This example extracted from React docs to cover the
react-test-renderer
import:Example to cover the
@testing-library/react-native
import:It would be interesting to check the test cases added in this PR.
Error output/screenshots
findByType
,findByProps
, and otherreact-test-renderer
utils are reported by the plugin (e.g.,await-async-queries
complains about they must be awaited).ESLint configuration
n/a
Rule(s) affected
All rules reporting on queries are affected, but
await-async-queries
is the most obvious one.Anything else?
This was originated by #671 and #703
Do you want to submit a pull request to fix this bug?
No
The text was updated successfully, but these errors were encountered: