-
Notifications
You must be signed in to change notification settings - Fork 142
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
stub also verified warning when using ignoreExtraArgs #181
Comments
This particular warning has been discussed in a lot of other threads if you want more on my thinking about this. But I would suggest based on the other thread we were in yesterday that your use of the library is far enough outside the workflow I had in mind when designing it that you'll want to toggle the |
Just to be clear, this issue isn't about the warning in general; I understand and agree with it. My point is that there is somewhat inconsistent behavior around the warning when using eg:
It seems the warning isn't taking into account the |
This is indeed inconsistent and I can't explain it. |
After a verification is made, a warning can be produced to signal that the verification call matches a stub on the same testdouble. This behavior is improved to test the verification against the stubbing using the stubs matchers and config options. This closes: stub also verified warning when using ignoreExtraArgs testdouble#181 completed with @tinney
After a verification is made, a warning can be produced to signal that the verification call matches a stub on the same testdouble. This behavior is improved to test the verification against the stubbing using the stubs matchers and config options. This closes: stub also verified warning when using ignoreExtraArgs testdouble#181 completed with @tinney
@ackerdev Thanks for reporting the inconsistencies! Here is my feeling about these cases: // 1
// This should warn since the verify call foo() matches the stubbing exactly.
// Already working as expected.
td.when(foo(), { ignoreExtraArgs: true }).thenReturn()
foo()
td.verify(foo())
// 2
// This should not warn since the verification call doesn't match the stubbing.
// Already working as expected.
td.when(bar(anything()), { ignoreExtraArgs: true }).thenReturn()
bar()
td.verify(bar())
// 3
// This should warn since the verification matches the stubbing.
// Not currently working.
td.when(baz(), { ignoreExtraArgs: true }).thenReturn()
baz(1)
td.verify(baz(1)) This PR addresses case 3, which is inconsistent and currently failing. Check out the test cases, and please respond with any other edge cases that seem incorrect. For more information on why case 2 doesn't match, please check the docs here. |
i'm content with Sam's reasoning & PR above. |
When attempting to create reusable doubles, I found an oddity with the behavior of the "test double was both stubbed and verified" warning when using
ignoreExtraArgs
.As a simple (contrived) example:
The intention behind this is to stub behavior of foo that consistently returns bar, regardless of arguments, while the verify call is to ensure that foo was called with 0 arguments. Because the stubbing is defined without arguments, the warning is displayed, even though
ignoreExtraArgs
should imply that these invocations are not 1-to-1 identical. It is possible to work around this withtd.matchers.anything()
in the stubbing, though not ideal.My usecase for this is creating a reusable double to stand in for a somewhat complex third party interface that is passed in as an argument to my function; specifically, hapi's
reply
interface.This is seems somewhat related to #180, a functionality limited by the stubbing api, though I think it's a distinct issue worth documenting.
The text was updated successfully, but these errors were encountered: