0.24.1 • Published 5 years ago

stryker-karma-runner v0.24.1

Weekly downloads
140
License
Apache-2.0
Repository
github
Last release
5 years ago

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: {
            projectType: 'custom', // or 'angular-cli'
            configFile: 'path/to/karma.conf.js' // default `undefined`
            config: { // default `undefined`
                browsers: ['ChromeHeadless'] // override config settings
            }
        }
    });
}

karma.projectType "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.

karma.ngConfig.testArguments object

Default: undefined

Add ng test arguments. For example, specify an alternative project with:

karma: {
    projectType: 'angular-cli',
    ngConfig: {
        testArguments: {
            project: 'my-lib'
        }
    }
}

This will run ng test with --project argument: ng test --project=my-lib.

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: {
            projectType: 'angular-cli',
            karma: {
                configFile: 'src/karma.conf.js'
            },
            ngConfig: {
                // Override ng arguments here
                testArguments: {
                    project: 'my-lib'
                }
            }
        }
        // ...
    });
}

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'
        // ...
    });
}
0.24.1

5 years ago

0.24.0

5 years ago

0.23.0

5 years ago

0.22.0

5 years ago

0.21.1

5 years ago

0.21.0

5 years ago

0.20.3

6 years ago

0.20.2

6 years ago

0.20.1

6 years ago

0.20.0

6 years ago

0.19.0

6 years ago

0.18.3

6 years ago

0.18.2

6 years ago

0.18.1

6 years ago

0.18.0

6 years ago

0.17.1

6 years ago

0.17.0

6 years ago

0.16.5

6 years ago

0.16.4

6 years ago

0.16.3

6 years ago

0.16.2

6 years ago

0.16.1

6 years ago

0.16.0

6 years ago

0.15.3

6 years ago

0.15.2

6 years ago

0.15.1

6 years ago

0.15.0

6 years ago

0.14.4

6 years ago

0.14.3

6 years ago

0.14.2

6 years ago

0.14.1

6 years ago

0.14.0

6 years ago

0.13.0

6 years ago

0.12.5

6 years ago

0.12.4

6 years ago

0.12.3

6 years ago

0.12.2

6 years ago

0.12.1

6 years ago

0.12.0

6 years ago

0.11.3

6 years ago

0.11.2

6 years ago

0.11.1

7 years ago

0.11.0

7 years ago

0.10.0

7 years ago

0.9.1

7 years ago

0.9.0

7 years ago

1.0.0

7 years ago

0.8.0

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.5

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.4.0-0

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

8 years ago

0.3.0-rc5

8 years ago

0.3.0-rc4

8 years ago

0.3.0-rc3

8 years ago

0.3.0-rc2

8 years ago

0.3.0-rc1

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago