title: how to resolve async await inside a unit test - javascript
body: <p>I have a lambda for which I'd like to write unit tests for. I'm using async await but I'm getting issues with resolve promises. I'd like to test the different conditions, how can I write the test to resolve and stop seeing the timeouts?</p>
  
  <p>Thanks in advance.</p>
  
  <blockquote>
    <p>Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure
    "done()" is called; if returning a Promise, ensure it resolves.</p>
  </blockquote>
  
  <p>--- unit </p>
  
  <pre><code>describe('tests', function() {
  
      describe('describe an error', () =&gt; {
          it('should return a 500', (done) =&gt; {
              handler('', {}, (err, response) =&gt; {
                  expect(err.status).to.eq('failed')
                  done()
              })
          })
      })
  
  });
  </code></pre>
  
  <p>-- handler</p>
  
  <pre><code>export const handler = async (event, context, callback) =&gt; { 
  
   return callback(null, status: 500 )
  
  })
  </code></pre>