@kayahr/better-jest

1.2.1 • Public • Published

better-jest

This is just wrapper script around Jest to start Jest with exposed garbage-collector and passing additional arguments from the JEST_OPTS environment variable.

Usage

Install better-jest into your project:

npm install -D @kayahr/better-jest

Use better-jest instead of jest in your package.json:

"scripts": {
    "test": "better-jest",
}

That's it.

Garbage collector

By using better-jest you can use the gc() function within your Node.js tests or in Electron tests when using my jest-electron-runner

Environment variables

You can define Jest options globally with the environment variable JEST_OPTS and these options will then be picked up by better-jest and passed to Jest. This is for example helpful for CI systems which have specific needs for running the tests, like limiting the number of parallel workers when the CI host has an insane number of CPU cores. It is easier to globally define this environment variable instead of configuring each build job separately.

# Do this somewhere global on your system
export JEST_OPTS="--max-workers 1"

# Then run your tests in all your projects and Jest is now
# limited to a single worker thread automatically
npm test

Readme

Keywords

Package Sidebar

Install

npm i @kayahr/better-jest

Weekly Downloads

8

Version

1.2.1

License

MIT

Unpacked Size

8.8 kB

Total Files

8

Last publish

Collaborators

  • kayahr