title: Sinon, observing different behaviour using Promise.reject() to stub.rejects()
body: <p>I was having issues running a test (in Node),</p>
  
  <p>I was simulating a promise being rejected, and my code should retry (using <a href="https://www.npmjs.com/package/promise-retry" rel="nofollow noreferrer">promise-retry</a> if that could be relevant).</p>
  
  <p>When I simulated the rejected promise using <code>stub.returns(Promise.reject(error)</code></p>
  
  <p>I was getting a uncaught error warnings (for my <code>dummyErrors</code>), even though I am catching errors where I call my function...</p>
  
  <p>-note, these uncaught errors were only happening in the unit tests not in real calls.</p>
  
  <pre><code>const mockedFunction = sinon.stub();
  
  const dummyError = new Error('Document is locked');
  
  mockedFunction.onCall(0).returns(Promise.reject(dummyError));
  mockedFunction.onCall(0).returns(Promise.reject(dummyError));
  mockedFunction.onCall(0).returns(Promise.reject(dummyError));
  mockedFunction.onCall(1).returns(Promise.resolve({approved: true}));
  </code></pre>
  
  <p>I discovered that by changing to use the <code>stub.rejects()</code> syntax:</p>
  
  <pre><code>mockedFunction.onCall(0).rejects(dummyError);
  mockedFunction.onCall(1).rejects(dummyError);
  mockedFunction.onCall(2).rejects(dummyError));
  mockedFunction.onCall(3).resolves({approved: true});
  </code></pre>
  
  <p>I no longer get the uncaught error warnings.</p>
  
  <p>My issue is solved, however I would like to get a better understand as to why, I looked at the sinon source code and it looks like the implementation of <code>.rejects</code> is no different</p>