Reputation: 5660
var stub = sinon.stub(object, "method");
Sinon tutorial explains stub but it, how to modify the above line to invoke/stub 'method' with a specified 'param' else do not stub it.
Upvotes: 0
Views: 145
Reputation: 11905
You can use stub.withArgs
to stub a method with the expected arguments.
const stub = sinon.stub(object, 'method');
stub.withArgs(42).returns(1);
stub.withArgs(1).throws('BOOM!');
Upvotes: 5