Stops the HTTP server and runs shutdown lifecycle hooks such as
onModuleDestroy, which is where modules like TypeORM close their connectionsapp.close() closes the server and runs the shutdown lifecycle hooks:
• onModuleDestroy
• beforeApplicationShutdown
• onApplicationShutdown
Modules like TypeORM close their connections in these hooks, so the connection pools are released.
The option "Nothing, unless app.enableShutdownHooks() was called in the test" is wrong. enableShutdownHooks() is only needed to run those hooks on OS signals like SIGTERM. A direct app.close() runs them anyway.
The option "Only stops the HTTP server" is wrong for the same reason: the hooks close the database connections too.
Forgetting app.close() is a common reason why Jest reports open handles.
Read more