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
Problem with getStackFrames()[0]
#1066
Comments
This is not sufficient. I don't see any code using Sinon's API at all. You just mention the internals of Sinon, but what about the externals? Waht are you trying to achieve? You can reopen this if you add more info that makes it clear what you are trying to achieve, how, and what is not working. |
I'm able to reproduce this in Chrome 55.0.2883.95 for Mac with Sinon 1.17.6 (the latest available at http://sinonjs.org/). Here's a JSBin with a reduced test case: http://jsbin.com/mufotihiwo/edit?js,console,output Essentially, it seems like when a stub is passed point-free to
I believe this is because the callback is invoked directly by the VM, which means there's nothing in the stack. So when Sinon chops off the first 3 lines (starting at I think a mitigation strategy would be to simply put a defensive check in callStr += ( this.getStackFrames()[0] || 'unknown function' ).replace(/^\s*(?:at\s+|@)?/, " at "); |
This is perhaps a slightly better version that also works in Node: let sinon = require('sinon');
function test() {
let stub1 = sinon.stub().returns( Promise.resolve({}) );
let stub2 = sinon.stub();
function run() {
return stub1().then( stub2 );
}
run()
.then( () => sinon.assert.calledTwice( stub2 ) )
.catch( console.log );
}
setTimeout( test, 0 ); |
What did you expect to happen?
I expected my own error to be reported, not an internal Sinon error.
What actually happens
An internal Sinon error is shown.
How to reproduce
See this for an example
In
sinon/lib/sinon/call.js
, this code is giving me the error thatthis.getStackFrames(...)[0] is undefined
:From the following:
...it appears that the
slice
is returning an empty array.I'm hoping this may be enough for you to go on without a specific code sample. Thanks!
The text was updated successfully, but these errors were encountered: