Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server is not closed properly with Jest #31

Open
fabiopaiva opened this issue Jun 29, 2020 · 0 comments
Open

Server is not closed properly with Jest #31

fabiopaiva opened this issue Jun 29, 2020 · 0 comments

Comments

@fabiopaiva
Copy link

fabiopaiva commented Jun 29, 2020

When used with Jest, it keeps complaining about keeping the server alive.

A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --runInBand --detectOpenHandles to find leaks.

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
jest --runInBand --detectOpenHandles
Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  TCPSERVERWRAP

      29 |     };
      30 |     server = http.createServer(requestHandler);
    > 31 |     url = await listen(server);
         |                 ^
      32 |   });
      33 | 
at Promise (node_modules/test-listen/index.js:4:7)
      at module.exports (node_modules/test-listen/index.js:1:51)
      at Object.<anonymous> (pages/api/status/__tests__/status.test.ts:31:17)

this is my code

beforeAll(async () => {
    server = http.createServer(requestHandler);
    url = await listen(server);
});

afterAll((done: () => void) => {
    server.close(done);
  });

any idea why it's not closing the server?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant