title: JEST Received function did not throw, but HTTPError is thrown
body: <p>I am testing an endpoint with JEST and Got. I expect 403 Forbidden error. The following code prints the error from catch block AND fails that the identical call does not throw an error. Why?</p>
  
  <pre><code>    try {
          response = await api(`verify/${profile.auth.verifyToken}`, {method: 'POST'}).json();
      } catch (e) {
          console.log(e);
      }
      expect(async () =&gt; {
          response = await api(`verify/${profile.auth.verifyToken}`, {method: 'POST'}).json();
      }).toThrow();
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>console.log test/api.int.test.js:112
  HTTPError: Response code 403 (Forbidden)
      at EventEmitter.&lt;anonymous&gt; (C:\dev\mezinamiridici\infrastructure\node_modules\got\dist\source\as-promise.js:118:31)
      at processTicksAndRejections (internal/process/task_queues.js:97:5) {
    name: 'HTTPError'
  }
  
  
  Error: expect(received).toThrow()
  Received function did not throw
  </code></pre>
  
  <p>This variant does not work either:</p>
  
  <pre><code>expect(() =&gt; api(`verify/${profile.auth.verifyToken}`, {method: 'POST'})).toThrow();
  </code></pre>
  
  <p>Btw when the HTTPError is thrown and not catched, there is no stacktrace and I do not see where the error was thrown. If there are other error I exactly see which test line was responsible. Why?</p>