title: Jest how to test express API POST request?
body: <p>I need to test if my POST request to my endpoint works properly with a Jest test. I had the idea of first getting the count of my Services table (I'm using sequelize orm), then to send a new post request and to finally get the new count and compare if the old count + 1 will equal to the new count, if true then the POST request works just fine. </p>
  
  <pre><code>test('Create a valid Service', async (done) =&gt; {
  const service = {
      name: "cool",
      description: "description"
  };
  
  await Service.count().then(async function (count) {
  
      await request(app)
          .post('/api/services')
          .send(service)
          .then(async () =&gt; {
              await Service.count().then(function (newcount) {
                  expect(newcount).toBe(count + 1);
              });
          })
          .catch(err =&gt; console.log(`Error ${err}`));
  });
  </code></pre>
  
  <p>});</p>
  
  <p>For me the test looks fine, but when I run it I get:</p>
  
  <pre><code>Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.
  </code></pre>
  
  <p>Is something missing or is there even a better way to test a POST request? with Jest?</p>