Install @stryker-mutator/jest-runner locally within your project folder, like so:
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:
For the minimum supported versions, see the peerDependencies section in the package.json.
Make sure you set the
testRunner option to "jest".
The @stryker-mutator/jest-runner also provides a couple of configurable options using the
jest property in your Stryker config:
Configure where jest should get its configuration from.
"custom": use the
"create-react-app": use react-scripts, for projects created with create-react-app.
"create-react-app-ts": DEPRECATED use react-scripts-ts, for projects created with create-react-app-typescript. DEPRECATED, please follow the migration guide and move to
The path to your Jest config file.
Custom Jest config. This will override file-based config.
Whether to run jest with the
--findRelatedTests flag. When
true, Jest will only run tests related to the mutated file per test. (See --findRelatedTests).
@stryker-mutator/jest-runner plugin supports coverage analysis and test filtering, meaning you can run with
--coverageAnalysis perTest for optimal performance.
"perTest" coverage analysis, this plugin reports mutant coverage by hooking into the jest's test environment. The test environment setting is overridden based on the
"testEnvironment" configuration option in your jest config:
|Jest test environment||Jest runner's override|
As long as you're using one of these test environments, you won't have to do anything.
However, if you choose to override the jest-environment on a file-by-file basis using jest's
@jest-environment docblock, you will have to do the work.
Don't worry; using Stryker's alternative is harmless during regular unit testing.
If you're using a custom test environment, you'll need to mixin the Stryker functionality yourself:
If you're using a different test runner, you're out of luck. Please downgrade to using
"all" coverage analysis. If you think we should support your test runner, please let us know by opening an issue, or by joining our slack channel.