lev-kazakov / jest-leak-fixer

Jest memory leak fixer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jest Memory Leak Fixer

Inspired by @Telokis comment in jest/issues/6399.

Fixes leaks in:

PRs are welcome.

Install

yarn add --dev jest-leak-fixer

Apply

Via CLI

package.json

{
  ...
  "scripts": {
    ...
    "test": "jest-fixer-apply && yarn test:detect-leaks; test_exit_code=$? && jest-fixer-restore; exit $test_exit_code",
    "test:detect-leaks": "jest --detectLeaks",
  }
}
Via globalSetup/globalTeardown configuration

globalSetup.js

'use strict'
const jestLeakFixer = require('jest-leak-fixer')
...

module.exports = () => {
    jestLeakFixer.apply()
    ...
}

globalTeardown.js

'use strict'
const jestLeakFixer = require('jest-leak-fixer')
...

module.exports = () => {
    ...
    jestLeakFixer.restore()
}

About

Jest memory leak fixer

License:MIT License


Languages

Language:JavaScript 100.0%