-
-
Notifications
You must be signed in to change notification settings - Fork 771
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
How do we verify stub called with argument that is an array #953
Comments
We are trying to keep the GitHub issues list tidy and focused on bugs and feature discussions. This ticket looks like a usage question, please post it to the Sinon.JS mailinglist, so the bigger community can help answer your questions. If you feel that your topic is an issue with Sinon.JS, please open a new ticket and follow the guidelines for reporting an issue. |
thanks. I will contact the forum, thanks for your time. sinon is cool btw :) |
For anyone looking, here is the answer by @mroderick himself. var expectedValue = [1, 2, 3];
var myStub = sinon.stub;
// let's pretend this is the call you want to verify
myStub(expectedValue);
var firstArgument = myStub.getCall(0).args[0];
assert.equal(firstArgument, expectedValue); |
Or |
argument = ["1","2","3"] to a sinon stub.
I wish to check the argument and return value. I am unable to do the same using
stub.withArgs(argument).return(value); // its unable to match
stub.withArgs(sinon.match.array).return(value); // able to match
stub.withArgs(sinon.match.array.and(sinon.match.has("length", 3) // able to match
I am able to debug using WebStorm and verify that argument is passed to the stub.
Please help.
The text was updated successfully, but these errors were encountered: