-
Notifications
You must be signed in to change notification settings - Fork 147
Disallow the use of queryBy*
queries for assertions
#269
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
I think it would make sense to be part of |
This should be really easy to implement on v4, but it hasn't been refactored yet. |
@Belco90 I'll refactor the rule and add the enhancement then 🙌 |
That would be awesome. I'm gonna put that rule on WIP assigned to you on #198 then. Please double check that issue as that rule has a side note to remove its option, which is not necessary anymore. You can check
Let me know if you have any questions or need help to hook the rule with the new detection mechanism! |
I was about to implement that enhancement, and there's something that bugged me. The goal of this enhancement is to disallow this kind of statement:
It can happen if someone is mistaken about Then, maybe that rule should be implemented in What do you think, @Belco90? |
Mmm not sure to be honest, but definitely something to be handled combining I think we should just suggest in Thoughts? |
I agree, each rule should take care of their own purpose (one about not using the query in isolation, the other about preferring one query over the other) and then if they want the combinated result, they should enable both. In that sense, we should probably recommend both to be enabled together (maybe link each other in the readme), if they are not part of the base recommended ruleset |
That makes sense! I won't have the bandwidth to work on that right now, but I'll do it at some point 🙂 |
Closing due to inactivity. |
I've seen people using
queryBy
as assertions in their tests:This is not the right way to use it because the test won't fail whether the text is there or not.
Would it be possible to extend the
prefer-explicit-assert
rule in order to disallow the use ofqueryBy
as assertions as well?The text was updated successfully, but these errors were encountered: