title: Async/Await test with Jest not working in Node js
body: <p>I'm trying to test an <code>async</code> call with Jest in Node like this:</p>
  <pre><code>   it('testing to sign up feature', async (done) =&gt; {
          await expect(request(app).post('/signUp', {body:{a:1, b:3}})).resolves.toBe('created successful')
      });
  </code></pre>
  <p>However, it throws this error:</p>
  <pre><code>expect(received).resolves.toBe(expected) // Object.is equality
  
  Expected: &quot;created successful&quot;
  Received: {&quot;header&quot;: {&quot;connection&quot;: &quot;close&quot;, &quot;content-length&quot;: &quot;18&quot;, &quot;content-type&quot;: &quot;text/html; charset=utf-8&quot;, &quot;date&quot;: &quot;Fri, 03 Jul 2020 09:35:39 GMT&quot;}, &quot;req&quot;: {&quot;data&quot;: undefined, &quot;headers&quot;: {&quot;user-agent&quot;: &quot;node-superagent/3.8.3&quot;}, &quot;method&quot;: &quot;POST&quot;, &quot;url&quot;: &quot;http://127.0.0.1:53456/signUp&quot;}, &quot;status&quot;: 200, &quot;text&quot;: &quot;created successful&quot;}
  
    70 | 
    71 |      it('testing to sign up feature', async (done) =&gt; {
  &gt; 72 |              await expect(request(app).post('/signUp', {body:{a:1, b:3}})).resolves.toBe('created successful')
       |                                              
  </code></pre>
  <p>I'm not sure how I should mock the <code>text</code> of the response under <code>resolves.toBe...</code></p>
  <p><strong>EDIT</strong><br />
  Tried this</p>
  <pre><code>    const response = await request(app).post('/signUp', {body:{a:1, b:3}})
      expect(response).resolves.toEqual('created successful')
  </code></pre>
  <p>but this resulted in the same error</p>
  <p>In case it's relavant. My signUp APIs look like this:</p>
  <pre><code> signUp(req, res) {
      log.info('User signed up request received');
      postRequest('/signUp', JSON.stringify(req.body)).then((resp) =&gt; {
          res.status(&quot;200&quot;).send(resp);
      });
  }
  
  
  
   async function postRequest(path, param) {
      try {
           return await mockCall(path, param);
      } catch (err) {
          throw err;
      }
  }
  
  
  
   function mockCall(path, param) {
          // A mimic
         const magicNumber = 2000;
          return new Promise((resolve) =&gt; {
              setTimeout(() =&gt; {
                  resolve(&quot;created successful&quot;);
              }, magicNumber);
          });
  }
        
  </code></pre>