title: jest asynchronous test ignoring expect() function
body: <p>server.js is a simple express.js file that uses jwt tokens. I currently want to test a simple route that will only return the string "Hello World" as shown below</p>
  
  <pre><code>app.get("/", (req, res) =&gt; {
    res.send("Hello World");
  });
  </code></pre>
  
  <p>The code below is my jest file that is using supertest to send the request along with the valid jwt token</p>
  
  <pre><code>const supertest = require("supertest");
  
  let server, request;
  const serverStart = new Promise(resolve =&gt; {
    server = require("../server.js");
    request = supertest(server);
    server.on("app_started", () =&gt; {
      resolve();
    });
  });
  
  beforeAll(async () =&gt; {
    await serverStart;
  });
  
  afterAll(() =&gt; {
    server.close();
  });
  
  describe("When testing the server.js", () =&gt; {
    it("Should connect successfully and be able to return a response", async () =&gt; {
      const response = await request
        .get("/")
        .set("Authorization", `bearer ${process.env.AUTHTOKEN}`);
  
      expect(response.text).toBe("Hello World");
      console.log(response.text);
    });
  });
  </code></pre>
  
  <p>When running this jest (after it's timeout of 5 seconds) says <code>Timeout - Async callback was not invoked within the 5000ms timeout specified</code> however, the console.log that I have added after the expect function outputs "Hello World" to the console meaning the request is made and returns a value but it carriers on with the code but is just skipping the expect function</p>
  
  <p>I've also tried this with <code>done()</code> and also using a <code>then()</code> but got the same error both times and I've console logged the time before and after the call and found it only takes a few milliseconds to return a value, so why does the expect not seem to complete the test?</p>