Jest Runner

Installation

Install @stryker-mutator/jest-runner locally within your project folder, like so:

npm i --save-dev @stryker-mutator/jest-runner

Peer dependencies

The @stryker-mutator/jest-runner is a plugin for Stryker to enable Jest as a test runner. As such, you should make sure you have the correct versions of its dependencies installed:

  • jest
  • @stryker-mutator/core

For the minimum supported versions, see the peerDependencies section in the package.json.

Configuration

Make sure you set the testRunner option to "jest" and set coverageAnalysis to "off" in your Stryker configuration.

{
"testRunner": "jest",
"coverageAnalysis": "off"
}

The @stryker-mutator/jest-runner also provides a couple of configurable options using the jest property in your Stryker config:

{
"jest": {
"projectType": "custom",
"configFile": "path/to/your/custom/jestConfig.js",
"config": {
"testEnvironment": "jest-environment-jsdom-sixteen"
},
"enableFindRelatedTests": true,
}
}

jest.projectType ["string"]

Default: "custom"

Configure where jest should get its configuration from.

jest.configFile] [string]

Default: undefined

The path to your Jest config file.

jest.config [object]

Default: undefined

Custom Jest config. This will override file-based config.

jest.enableFindRelatedTests [boolean]

Default: true

Whether to run jest with the --findRelatedTests flag. When true, Jest will only run tests related to the mutated file per test. (See --findRelatedTests).