-
Notifications
You must be signed in to change notification settings - Fork 147
False positives with testing-library/prefer-presence-queries #518
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
Comments
Thanks for reporting this @domarmstrong. Interesting issue, it seems it's reporting false positives when the Testing Library query is nested into something else. We will have to take a look at this at some point. |
Another case of a false positive for @Belco90 Does this relate enough, or should I open a new issue? 🤔 |
Hey @josias-r, this is a different problem. Could you move it to a different issue? Thanks. |
I'm having the same problem as @domarmstrong - at the very least it would be nice to make this rule configurable so that we could disable the "Use |
@themagickoala Introducing some config to the rule would be nice. We would be more than happy to receive some PR to address that, or fixing the original issue! |
I will try and make time for this if I can, but it's unlikely as I've come down with Covid and still having to look after my 2 kids/try and work when I can! I've done a little investigation and I'm going to make some notes here in case somebody else finds it and wants to have a go (this is from the perspective of somebody who has never written anything to do with eslint before):
Like I said, I'll try and make time for this, but it's unlikely to be for a few weeks if that. |
I've had a quick stab at the config version (part 1 above) here: #557 |
@themagickoala thanks for your contribution! I'll take a look at the PR in a bit, then we can take care of fixing the actual bug around |
* fix: support configuration for prefer-presence-queries (#518) * test(prefer-presence-queries): destructure options in the params of create Co-authored-by: Michaël De Boey <[email protected]> Co-authored-by: Rory Jennings <[email protected]> Co-authored-by: Michaël De Boey <[email protected]>
@Belco90 has any work been done to look into fixing the false positive here? Just wanted to check in on it all! |
I'm afraid not 😞. Hopefully, I can take a look during this month. |
@Belco90: I started looking into this issue, and there's something wrong with For example... // This is just pseudo code, I'm getting this result from running rule unit tests and printing out this stuff
const a = rtl.within('foo').getByRole('button')
const rtlNode = ... // get this somehow
getDeepestIdentifierNode(rtlNode).name // returns 'rtl', not 'getRoleButton' as the JS Doc says Any ideas what is happening? |
Not sure if I understood your example correctly. I'm confused about the The JSDoc description is correct, so you should get the identifier for the last chained node. If that's not the case, we have a bug, but I didn't fully understand your example.
They are! It's difficult to spot that. If you go to the |
Sorry about vagueness and/or unclear example. I meant that when I call
So we have a bug 🐛
Yay for unit testing helpers! Hmmn, I think I'll need some time to dug deeper into that test file, and probably write some notes (to myself and others) how to unit test helper functions with this file. I'll ask if I get stuck 😅 |
But what is |
If you are obtaining the That util is supposed to be used with call expressions and that kind of nodes, not the identifiers themselves. |
🎉 This issue has been resolved in version 5.11.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This issue has been resolved in version 6.0.0-alpha.15 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Plugin version
v5.0.0
ESLint version
v8.2.0
Node.js version
14.18.0
npm/yarn version
1.22.17
Operating system
Big Sur
Bug description
Generally I like this rule but we have to disable it in quite a few places due to false positives with toBeNull.
Steps to reproduce
Examples:
Error output/screenshots
No response
ESLint configuration
Rule(s) affected
testing-library/prefer-presence-queries
Anything else?
No response
Do you want to submit a pull request to fix this bug?
No
The text was updated successfully, but these errors were encountered: