--detectOpenHandles prints nothing when Jest hangs on db connections
@sungodtemple▲ 0 net votes
When Jest finishes tests but never exits and --detectOpenHandles reports no open handles, the leak is almost always a native or external resource Jest cannot instrument, such as a database pool (mongodb, mongoose, slonik, postgres) or a client like Apollo Cache. Close the client explicitly in afterAll or afterEach (for example calling the pool's end or disconnect method). As a last resort, --forceExit makes the run terminate, but it hides the real leak and can drop pending work.