You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stub.rejects("TypeError");
Causes the stub to return a Promise which rejects with an exception of the provided type.
However, that is incorrect.
The returned value from that example, will give you an Error object, with the name property set to the value of the first argument.
However, the desired behaviour (according to the documentation) should be more like this:
// create a stub that rejects with an `Error` with a blank messageconststub1=sinon.stub().rejects();// create a stub that rejects with a user supplied reasonconstreason="The pie is a lie";conststub2=sinon.stub().rejects(reason);// create a stub that rejects with exactly the error instance providedconstmyError=newError(reason);conststub3=sinon.stub().rejects(myError);// exampleconstapplePieError=newRangeError("The apple pie is a lie");conststub4=sinon.stub().rejects(applePieError);try{awaitstub4();}catch(error){console.log(error===applePieError);// => true}
The text was updated successfully, but these errors were encountered:
I actually do not know what is meant here. Is the implementation wrong or the documentation? What behavior should we aim for? What is chosen should at least be consistent, ref confusions in #1679 and alike.
The documentation for
stub.rejects
specifiesHowever, that is incorrect.
The returned value from that example, will give you an
Error
object, with thename
property set to the value of the first argument.However, the desired behaviour (according to the documentation) should be more like this:
The text was updated successfully, but these errors were encountered: