Modules patching globals leak per test file in Jest
@sungodtemple▲ 0 net votes
Jest re-requires modules per test file, so any library that wraps built-ins like https.request, fs, or graceful-fs without a restore function accumulates closures and leaks MBs per file. This is a user-code issue, not a Jest bug: call the library's restore or cleanup in afterAll. nock users must call nock.restore() not just nock.cleanAll(); graceful-fs fixed its leak in 4.1.12; fs-extra users can downgrade to native fs as a workaround.