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
Warn when arity of stubbing or verification doesn't match function.length #3
Comments
Hey @Schoonology what do you think of this given your hatred of function.length? |
I don't know what value this provides over our other messages (like the new "report" that tells you of missed stubbings). Do you run into this case often? |
The value of this is it's one of the (in JS, very very) few places where we can give people a heads up that the contract between a subject and a dependency are out of sync with one another. Example: a dependency |
I'm inclined to agree with @Schoonology. Many JS functions have a "dynamic arity", or no explicitly defined arity at all. It seems like that feature would implicitly make the argument that "dynamic arity = bad", given the opinionated (for good reason) nature of other limitations in the library. |
@samjonester two reactions:
Of course, how I intend for people to use test doubles (designing clean, isolated units that are decoupled from third party APIs) and how people actually use test doubles (mocking every third-party thing they can get their hands on), this warning would be triggered all the time and most often by people who aren't using the library as I intended, which I'm sure would lead to dozens more "this warning is bad, make it go away" issues, like we've seen in the case of "don't verify stubs" |
If I do a test double func:
Then setting up a stubbing with a different arity should warn:
This warning should be able to be muted on a case-by-case basis since function
.length
is unreliable.The text was updated successfully, but these errors were encountered: