-
Notifications
You must be signed in to change notification settings - Fork 147
Please provide an option to remove the matching of findBy queries by the prefer-explicit-assert rule #449
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
Alternatively, as I see there's no option in the existing rules, maybe we can make these 2 use cases 2 separate rules? What do you think? |
Hi @julienw! Thanks for your suggestion, I think it definitely makes sense to have this as a rule option, but I'd like to mention something:
I think this is debatable, since could end up in the same problem as using This could be applied to For this reason, I wouldn't say adding |
Yeah, I fully agree for the Would you rather have it as an option or as 2 different rules? My concern with having an option is that as far as I know nothing is done yet for options, neither in the code or in the tests :-) |
I'd have it as a rule option enabled by default.
I don't get this bit tho. |
Just me missing that we already use options elsewhere, including for this rule. Forget about this remark! I'll see if I can make this work. |
@julienw no worries! Would you like to work on this improvement then? |
Yes, I already started with a failing test :-) |
That's amazing! Let us know if you need help or guidance with anything ✨ |
…refer-explicit-assert rule A recent patch implemented matching findBy* queries by the prefer-explicit-assert rule. This patch makes it possible to disable it in cases where it's too distracting. Fixes testing-library#449
…refer-explicit-assert rule A recent patch implemented matching findBy* queries by the prefer-explicit-assert rule. This patch makes it possible to disable it in cases where it's too distracting. Fixes testing-library#449
…refer-explicit-assert rule A recent patch implemented matching findBy* queries by the prefer-explicit-assert rule. This patch makes it possible to disable it in cases where it's too distracting. Fixes testing-library#449
🎉 This issue has been resolved in version 4.11.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What rule do you want to change?
prefer-explicit-assert
Does this change cause the rule to produce more or fewer warnings?
Fewer warnings
How will the change be implemented?
An option
matchFindByQueries
will be added, true by default.When it's set to
false
the rule won't match these queries.Example code
How does the current rule affect the code?
The current rule will report an error for such code, but I'd like to be able to exempt it easily.
How will the new rule affect the code?
When the new option is set to
false
, this code won't be flagged.When the new option is absent or set to
true
the code will still be flagged as it is now, so it wouldn't be a breaking change.Anything else?
My 2 cents: it's common I use
findBy
assertions in my test code, not to assert that they're here, but rather to ensure we're waiting for something to be displayed before moving forward, so that the test isn't flaky. Therefore addingexpect
calls in these cases brings distractions :/References: #409 #421
Do you want to submit a pull request to change the rule?
Yes
The text was updated successfully, but these errors were encountered: