title: Mocha: how to assert a promise rejection?
body: <p>I'm trying to get Mocha to display the error and also assert a rejected promise on my Node code - ...instead of showing a <code>UnhandledPromiseRejectionWarning</code> for an exception which is causing my async function to be rejected.</p>
  
  <p>I've searched and tried many suggestions for dealing with this warning and promise rejections in Mocha, but none of them worked for me. It seems to be a recurrent topic and a very confusing one for many people.</p>
  
  <p>I'm trying to do it by:</p>
  
  <ul>
  <li><p>using lambda function</p></li>
  <li><p>without using <code>done</code></p></li>
  <li><p>using simple asserts (I don't like <code>expect</code> and <code>should</code>)</p></li>
  <li><p>handling errors through try/catch (I don't like chained <code>.then</code> and <code>.catch</code>; and dislike it even more if using <code>.then(res,err)</code>)</p></li>
  </ul>
  
  <p>Something like:</p>
  
  <pre><code>it('should give an error', 
    async ()=&gt; {
      try{
        await generateException()
        assert(true)
      } catch(err) {
        console.err(err)
        assert ??? // how to 'assert' a promise rejection?
      }
    }
  )
  </code></pre>
  
  <p>If it's unavoidable to use any of the things I don't like much, fine. But what is the closer solution to what I would like? </p>
  
  <p>Also, I don't get why the rejected promise wouldn't be caught in the try/catch, as I would expect, since this is exactly the point of using <code>await</code> (making async code work as if they were synchronous).</p>