someApprentice / Crypter

3 stars 1 forks source link

Jest test keep running async operations wich keeping it from exit #9

Closed someApprentice closed 5 years ago

someApprentice commented 5 years ago

Literally to say Jest keeps opened the express server and to work around this issue need ran tests with --force-exit option.

Need to find a way to shutdown the server after all test is done.

    //Jest has detected the following 1 open handle potentially keeping Jest from exiting:
    // > 60 | server.listen(PORT, () => {
    //      |        ^
    //   61 |   console.log(`Node server listening on http://localhost:${PORT}`);
    //   62 | });
    // at Function.listen (node_modules/express/lib/application.js:618:24)
    // at Object.<anonymous> (server.ts:60:8)
someApprentice commented 5 years ago

Problem solved due https://github.com/someApprentice/Crypter/commit/c6ed10605ac54faa13253fd115720889f8a5c807. But despite the fact that the option --detectOpenHandles does not show any asynchronous process, the test process cannot stop.

--force-exit is still a solution, but the console still gives an error

Have you considered using `--detectOpenHandles` to detect async operations that
kept running after all tests finished?