README
Jest-Bench
Run benchmark with Jest, write benchmark files along your test files and benchmark using any existing test environment you're using. This package rely on the excellent benchmark
package to function.
Which version to install
Some environments such as jest-electron
are only useable with Jest version 27, therefore this package take its version after jest version for easy installation:
Jest version | Jest-Bench version |
---|---|
26.x.x | 26.x.x |
27.x.x | 27.x.x |
For contributors, branch main
works with Jest version 27, while branch v26
works with Jest version 26.
How to use
Install
npm i -D jest-bench
Create a jest config file just for running benchmarks. You can use name such as jest-bench.config.json
.
{
// Jest-bench need its own test environemtn to function
"testEnvironment": "jest-bench/environment",
"testEnvironmentOptions": {
// still Jest-bench environment will run your environment if you specify it here
"testEnvironment": "jest-environment-jsdom",
"testEnvironmentOptions": {
// specify any option for your environment
}
},
// always include "default" reporter along with Jest-bench reporter
// for error reporting
"reporters": ["default", "jest-bench/reporter"],
// will pick up "*.bench.js" files or files in "__benchmarks__" folder.
"testRegex": "(/__benchmarks__/.*|\\.bench)\\.(ts|tsx|js)