Switch branches/tags
v0.5.9 v0.5.8 v0.5.7 v0.5.6 v0.5.5 v0.5.4 v0.5.3 v0.5.2 v0.5.1 v0.5.0 v0.4.5 v0.4.4 v0.4.3 v0.4.2 v0.4.1 v0.4.0 v0.3.2 v0.3.1 v0.3.0 v0.2.1 v0.2.0 v0.1.0 v0.0.0 stryker@0.27.1 stryker@0.27.0 stryker@0.26.2 stryker@0.26.1 stryker@0.26.0 stryker@0.25.1 stryker@0.25.0 stryker@0.24.2 stryker@0.24.1 stryker@0.24.0 stryker@0.23.0 stryker@0.22.4 stryker@0.22.3 stryker@0.22.2 stryker@0.22.1 stryker@0.22.0 stryker@0.21.1 stryker@0.21.0 stryker@0.20.1 stryker@0.20.0 stryker@0.19.4 stryker@0.19.3 stryker@0.19.2 stryker@0.19.1 stryker@0.19.0 stryker@0.18.2 stryker@0.18.1 stryker@0.18.0 stryker@0.17.2 stryker@0.17.1 stryker@0.17.0 stryker@0.16.0 stryker@0.15.6 stryker@0.15.5 stryker@0.15.4 stryker@0.15.3 stryker@0.15.2 stryker@0.15.1 stryker@0.15.0 stryker@0.14.1 stryker@0.14.0 stryker@0.13.0 stryker@0.12.0 stryker@0.11.2 stryker@0.11.1 stryker@0.11.0 stryker@0.10.3 stryker@0.10.2 stryker@0.10.1 stryker@0.10.0 stryker@0.9.3 stryker@0.9.2 stryker@0.9.1 stryker@0.9.0 stryker@0.8.0 stryker@0.7.0 stryker@0.6.7 stryker@0.6.6 stryker@0.6.4 stryker@0.6.3 stryker@0.6.2 stryker@0.6.0 stryker@0.6.0-2 stryker-webpack-transpiler@0.6.3 stryker-webpack-transpiler@0.6.2 stryker-webpack-transpiler@0.6.1 stryker-webpack-transpiler@0.6.0 stryker-webpack-transpiler@0.5.2 stryker-webpack-transpiler@0.5.1 stryker-webpack-transpiler@0.5.0 stryker-webpack-transpiler@0.4.0 stryker-webpack-transpiler@0.3.4 stryker-webpack-transpiler@0.3.3 stryker-webpack-transpiler@0.3.2 stryker-webpack-transpiler@0.3.1 stryker-webpack-transpiler@0.3.0 stryker-webpack-transpiler@0.2.0
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
.vscode
src
test
testResources
.npmignore
.npmrc
CHANGELOG.md
LICENSE
README.md
package.json
run-angular.d.ts
tsconfig.json
tslint.json

README.md

Build Status NPM Node version Gitter

Stryker Karma Runner

A plugin to use the karma test runner (or @angular/cli's ng test) in Stryker, the JavaScript mutation testing framework

Install

Install stryker-karma-runner locally within your project folder, like so:

npm i --save-dev stryker-karma-runner

Bring your own test runner

The stryker-karma-runner is a plugin for stryker to enable karma as a test runner. However, it does not come packaged with it's own version of karma, instead it uses your very own karma version. It can also work with @angular/cli, see Configuring

Note: karma v2.0.3 has a known issue which makes it impossible to use it with Stryker. please upgrade to 2.0.4 or higher.

Configuring

You can configure the stryker-karma-runner using the stryker.conf.js config file.

// Stryker.conf.js
module.exports = function (config) {
    config.set({
        // ...
        testRunner: 'karma',
        // ...
        karma: {
            project: 'custom', // or 'angular-cli'
            configFile: 'path/to/karma.conf.js' // default `undefined`
            config: { // default `undefined`
                browsers: ['ChromeHeadless'] // override config settings
            }
        }
    });
}

karma.project ["custom" | "angular-cli"]

Default: "custom"

Specify which kind of project you're using. This determines which command is used to start karma

  • "custom": configure stryker-karma-runner to use karma start.
  • "angular-cli": configure stryker-karma-runner to use ng test (see configuring for angular-cli).

karma.configFile [string]

Default: undefined

Specify a 'karma.conf.js' file to be loaded. Options specified directly in your stryker.conf.js file using karma.config will overrule options in your karma.conf.js file.

karma.config [any]

Default: undefined

Specify karma configuration options directly. Options specified here will overrule any options in your karma.conf.js file.

Non overridable options

The browser's life cycle is determined by stryker-karma-runner. I.e. these settings cannot be overridden:

{
  browserNoActivityTimeout: 1000000,
  autoWatch: false,
  singleRun: false,
  detached: false
}

The coverage plugin will also be removed (not needed for mutation testing).

Configure angular cli

Note: this requires v6.1.0-rc0 or higher of the @angular/cli

This is an example for a configuration of stryker using the angular cli:

// stryker.conf.js
exports = function(config){
    config.set({
        // ...
        karma: {
            project: 'angular-cli',
            karma: {
                configFile: 'src/karma.conf.js'
            }
        }
        // ...
    });
}

Debugging

As Stryker runs karma in its own process, its logging output will be consumed by Stryker.

To see all logging from karma, set the log level to trace in stryker.conf.js.

// stryker.conf.js
exports = function(config){
    config.set({
        // ...
        logLevel: 'trace'
        // ...
    });
}