title: Sinon to unit test 'catch' statement
body: <p>I've got a simple function such as;</p>
  
  <pre><code>module.exports = {
    fetchUser:function(myUserId) {
      return new Promise((resolve, reject) =&gt; {
        this.getUser(myUserId)
          .then(user =&gt; {
            // do logic // then return user
  
            return user;
          })
          .then(resolve)
          .catch(err =&gt; {
            // whoops there has been an error
  
            let error = { error: 'My Error' };
  
            reject(error);
          });
      });
    }
  };
  </code></pre>
  
  <p>I want to unit test both the <code>resolve</code> and <code>reject</code> result.</p>
  
  <p>A simple <code>chai</code> test would be;</p>
  
  <pre><code>var expect = require('chai').expect;
  var user = require('./user');
  
  describe('User module', function() {
    it('test fetchUser', function() {
      let _user = user.fetchUser('abc123');
  
      return _user
        .then(user =&gt; {
          expect(data).to.be.an('object');
        });
    });
  </code></pre>
  
  <p>Using <code>sinon</code> or another library, how can I for the <code>fetchUser</code> function to throw that <code>reject</code> error?</p>