-
Notifications
You must be signed in to change notification settings - Fork 238
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
[prefer-expect-assertions] Addition of an "ifPromisesUsed" option #481
Comments
There are 2 use cases for That said, I'm not against the option you're suggesting. @G-Rath thoughts? |
I'm in a similar boat as you @SimenB - I've actually typed this out a couple of times as I ran through & ruled out the possible advantages. I think you've hit the nail w/ i.e You want it in all promise/callback tests, b/c they could be more easily broken via refactoring; but that concern is already covered by the rules you mentioned. Hence I don't see a major use for this, especially vs the possible issues we could hit in trying to ensure detection of methods that are promise resolvers. That said, I'm not against reviewing an PR showing the advantage over |
Jest will gladly run a test case where no assertions are called because something deep in the code that you're testing is triggering some case, causing those assertions to not be run (like in the case of a promise not resolving or rejecting as it should). By requiring And I think by allowing I'm happy to work on a PR. |
re the burden of writing
Granted you can't use that if you're using tools other than
I completely agree, but it's the conditions that I'm not convinced we can accurately match enough of w/o edge cases and generally ending up attempting to do the job of a static analyzer - that's why it's generally best practice to always stick The focus of my review will be the complexity of the implementation vs what it actually covers, and what it doesn't cover (i.e "if you import None of this is meant to discourage you from making a PR if you want to have a go; I just want to share some of my thoughts & concerns 🙂 |
What are thoughts on option for detecting |
I'm pretty sure this was sorted via #677, so going to close this :) |
I really like the
prefer-expect-assertions
rule, but requiring a test file to be covered in eitherexpect.assertions(n)
orexpect.hasAssertions()
calls when assertions aren't nested inside promises gets a little messy.It would be rad to be able to have an
ifPromisesUsed
option on the rule that when enabled, would only throw the rule if:expect()
calls inside of the Promises resolve or reject methods.The text was updated successfully, but these errors were encountered: