How does one stub promise with sinon?

At current sinon version v2.3.1, you can use stub.resolves(value) and stub.rejects(value) function

For example, you can stub myClass.myFunction with following code

sinon.stub(myClass, 'myFunction').resolves('the value you want to return');

or

sinon.stub(myClass, 'myFunction').rejects('the error information you want to return');

Leave a Comment