Supertest POST request hangs

Viewed 189

I am running supertest on Jest and trying to test a simple POST request:

test('A simple POST', done => {
    const appHttpServer = app.getHttpServer();
    const _request = request(appHttpServer);

    return _request
      .post(`my-post-url`)
      .type('json')
      .send(someData)

      .expect(HttpStatus.ACCEPTED, done);
  });

The test passes as expected, however it stays hang. Running with --detectOpenHandles results with: Jest did not exit one second after the test run has completed.

If I try a non-post request, everything works as expected and the test exits correctly.

What am I doing wrong in this case?

0 Answers
Related