title: Handle promise rejection with Chai
body: <p>I have the following validation function checking if a user exists:</p>
  
  <pre><code>validate.user = async (user, password) =&gt; {
      const matches = await bcrypt.compare(password, user.password);
      if (matches) return user;
      if (!matches) {
          return validate.logAndThrow('User password does not match');
      }
      return validate.logAndThrow('Error in bcrypt compare');
  };
  </code></pre>
  
  <p>The following test using Chai should test this:</p>
  
  <pre><code>chai.use(sinonChai);
  const { expect } = chai;
  
      describe('#user', () =&gt; {
          it('show throw if user is undefined', () =&gt; {
              expect(() =&gt; validate.user(undefined, 'pass')).to.throw('User does not exist');
          });
  </code></pre>
  
  <p>The error does get thrown, however mocha shows the following in the console:</p>
  
  <blockquote>
    <p>2) show throw if user is undefined
    (node:18587) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: User does not exist</p>
  </blockquote>
  
  <p>So my question is, how I can rewrite the test such that it does catch promise rejections? </p>