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.
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 stubName.getCall(0).thisValue.$$paramName;
Most helpful comment
For anyone looking, here is the answer by @mroderick himself.