Skip to content
Branch: master
Find file History
Latest commit 478e8fc Mar 4, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
.vscode feat(rename): rename `stryker-xxx-xxx` -> `@stryker-mutator/xxx-xxx` Feb 13, 2019
src feat(jest-runner): disable notifications (#1419) Feb 27, 2019
test
testResources
typings/jest
.npmignore
.npmrc
CHANGELOG.md
LICENSE
README.md docs(readme): remove references to old packages Feb 13, 2019
package.json
stryker.conf.js feat(rename): rename `stryker-xxx-xxx` -> `@stryker-mutator/xxx-xxx` Feb 13, 2019
tsconfig.json feat(rename): rename `stryker-xxx-xxx` -> `@stryker-mutator/xxx-xxx` Feb 13, 2019
tsconfig.src.json
tsconfig.test.json feat(rename): rename `stryker-xxx-xxx` -> `@stryker-mutator/xxx-xxx` Feb 13, 2019

README.md

Build Status Gitter Mutation testing badge

Stryker

@stryker-mutator/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 package.json.

Configuration

Configuring Stryker

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

{
    testRunner: 'jest'
    coverageAnalysis: 'off'
}

Configuring Jest

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

{
    jest: {
        projectType: 'custom',
        config: require('path/to/your/custom/jestConfig.js'),
        enableFindRelatedTests: true,
    }
}
option description default value alternative values
projectType (optional) The type of project you are working on. default default uses the config option (see below)
react when you are using create-react-app
react-ts when you are using create-react-app-typescript
config (optional) A custom Jest configuration object. You could also use require to load it here) undefined
enableFindRelatedTests (optional) Whether to run jest with the --findRelatedTests flag. When true, Jest will only run tests related to the mutated file per test. (See --findRelatedTests) true false

Note: When neither of the options are specified it will use the Jest configuration in your "package.json".
Note: the projectType option is ignored when the config option is specified. Note: Stryker currently only works for CRA-projects that have not been ejected.

The following is an example stryker.conf.js file:

module.exports = function(config) {
  config.set({
    testRunner: "jest",
    mutator: "javascript",
    coverageAnalysis: "off",
    mutate: ["src/**/*.js"]
  });
};

For more information on what these options mean, take a look at the Stryker readme.

Loading the plugin

In order to use the @stryker-mutator/jest-runner it must be loaded in the Stryker mutation testing framework via the Stryker configuration. The easiest way to achieve this, is not have a plugins section in your config file. That way, all node_modules starting with @stryer-mutator/* will be loaded.

Contributing

Make sure to read the Stryker contribution guidelines located in the Stryker mono repository.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.