Jest tests hanging even after running server.close() on my express app
The problem is that server
is undefined
in afterAll
because it's assigned in another scope as const server = http.createServer(app)
. Instead, it should be:
server = http.createServer(app);
There should be an exception, so done
is never get called in afterAll
. Currently Jest suppresses errors from afterAll
, there's Jest open issue that addresses afterAll
bug.