fixes https://github.com/facebook/jest/issues/6399
npm install jest-leak-fixerInspired by @Telokis comment in jest/issues/6399.
Fixes leaks in:
* graceful-fs
* agent-base (puppeteer dep)
PRs are welcome.
yarn add --dev jest-leak-fixerjavascript
{
...
"scripts": {
...
"test": "jest-fixer-apply; yarn test:detect-leaks; jest-fixer-restore",
"test:detect-leaks": "jest --detectLeaks",
}
}
`
##### Via globalSetup/globalTeardown configuration
_globalSetup.js_
`javascript
'use strict'
const jestLeakFixer = require('jest-leak-fixer')
...module.exports = () => {
jestLeakFixer.apply()
...
}
`_globalTeardown.js_
`javascript
'use strict'
const jestLeakFixer = require('jest-leak-fixer')
...module.exports = () => {
...
jestLeakFixer.restore()
}
``