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
Using callThrough with a mock expectation throws an 'apply' of undefined error. #1442
Comments
I've encountered the same error, as well as an additional one to go with it, so I distilled it down to as small an example as I could. The following example shows the error @jamespedid cites above, as well as shows that
stack trace
So both the |
A little more poking around has shown this to be specific to |
OK, so I worked around the problem in a way that should give someone a little more knowledgeable in the sinon codebase something to go on. Everything on my end seems to work if this ends in a crash:
while this behaves exactly as expected:
So it seems, IMHO, the https://github.com/sinonjs/sinon/blob/master/lib/sinon/behavior.js#L146 This code should perhaps traverse up the In he meantime, call |
bump. Any thoughts from maintainers/contributors here? |
Thanks for taking the time to dig into this, Tony! Not intentionally meaning to leave you hanging. It's just that stuff like this is time consuming to debug, and when it doesn't affect oneself there are often other issues that are more compelling (ie more issues closed per day). I don't have time to look into this right now, but if you manage to make a PR that fixes the issue then it's easier to reason around anyway. |
I think when expectation is initiated and the method is wrapped, I believe that var expectation = mockExpectation.create(method); should be rewritten to var expectation = mockExpectation.create(method);
extend(expectation, this.object[method]); |
What did you expect to happen?
The mock expectation should support the full stub API, including callThrough. The mocked expectation should invoke the actual app code.
What actually happens
An error is thrown trying to use the callThrough method because this.stub.wrappedMethod appears to be undefined.
How to reproduce
Stack Trace
The text was updated successfully, but these errors were encountered: