Socket
Socket
Sign inDemoInstall

@stryker-mutator/karma-runner

Package Overview
Dependencies
4
Maintainers
4
Versions
96
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stryker-mutator/karma-runner


Version published
Maintainers
4
Created

Changelog

Source

3.0.0 (2020-03-11)

Bug Fixes

  • api: allow for different api versions of File (#2042) (9d1fcc1), closes #2025
  • mocha: support mutants with "runAllTests" (#2037) (a9da18a), closes #2032

Features

  • api: Document StrykerOptions in JSON schema (4bdb7a1)
  • config: Allow a stryker.conf.json as default config file. (#2092) (2279813)
  • core: exit code 1 when error in initial run (49c5162)
  • Dashboard reporter: upload full html report by default (#2039) (e23dbe1)
  • excludedMutations: remove deprecated mutation names (#2027) (6f7bfe1)
  • HtmlReporter: include the html reporter in the core package and add it to the default reporters (#2036) (09702d9), closes #1919
  • Initializer: Initialize config file as JSON by default (#2093) (e07d953), closes #2000
  • jest-runner: support Jest 25 (b45e872), closes #1983
  • karma-runner: disable client.clearContext (#2048) (27c0787)
  • karma-runner: use ChromeHeadless as the default browser (#2035) (18bf9b6)
  • promisified fs: use node 10 promisified functions (#2028) (1c57d8f)
  • react: change react to create-react-app (#1978) (7f34f28)
  • Reporter.onScoreCalculated: remove deprecated onScoreCalculatedevent (#2026) (9fa4175)

BREAKING CHANGES

  • core: Stryker now exists with exitCode 1 if an error of any kind occurs.
  • karma-runner: The @stryker-mutator/karma-runner will now use ChromeHeadless by default (instead of PhantomJS)
  • Reporter.onScoreCalculated: Please use the onMutationTestReportReady event and the mutation-testing-metrics npm package to calculate the mutation testing report metrics.

This

class MyReporter {
  onScoreCalculated(scoreResult) {
    // => do stuff with score result
  }
}

Becomes this:

import { calculateMetrics } from 'mutation-testing-metrics';
class MyReporter {
  onMutationTestingReportReady(report) {
    const reportMetrics = calculateMetrics(report.files);
    // => do stuff with report metrics
  }
}
  • HtmlReporter: the html reporter is now enabled by default. If you don't want to use it, be sure to override the reporters configuration option.
{
  "reporters": ["progress", "clear-text"]
}
  • Dashboard reporter: The dashboard reporter will now upload a full report by default. If you don't want that, you can disable it with:
{
  "dashboard": {
    "reportType": "mutationScore"
  }
}
  • excludedMutations: removes auto-fix for the old names of mutations.

Migrating:

Almost every mutator has been renamed and/or split. Stryker will warn you about any deprecated mutator names in the mutator.excludedMutations section of your config.

To migrate, please run stryker to see if your project is affected. If this is the case, please take a look at the mutator types on the handbook (see above).

These are the changes:

| Old mutation | New mutation(s) | | ---------------------- | ----------------------------------------------------- | | ArrayLiteral | ArrayDeclaration | | ArrayNewExpression | ArrayDeclaration | | BinaryExpression | ArithmeticOperator, EqualityOperator, LogicalOperator | | Block | BlockStatement | | BooleanSubstitution | BooleanLiteral | | DoStatement | ConditionalExpression | | ForStatement | ConditionalExpression | | IfStatement | ConditionalExpression | | PrefixUnaryExpression | UnaryOperator, UpdateOperator, BooleanLiteral | | PostfixUnaryExpression | UpdateOperator | | SwitchCase | ConditionalExpression | | WhileStatement | ConditionalExpression |

New mutations

Due to the migration, some new mutations were added to the javascript mutator.

  • The mutation ArrayDeclaration will now mutate new Array() to new Array([])
  • The mutation ArrayDeclaration will now mutate [] to ["Stryker was here"]

These mutations were already performed by the typescript mutator.

  • promisified fs: removed fsAsPromised from @stryker-mutator/util

Readme

Source

Mutation testing badge 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-mutator/karma-runner locally within your project folder, like so:

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

Bring your own test runner

The @stryker-mutator/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-mutator/karma-runner using the stryker.conf.js (or stryker.conf.json) config file.

// Stryker.conf.js
module.exports = {
    // ...
    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-mutator/karma-runner to use karma start.
  • "angular-cli": configure @stryker-mutator/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-mutator/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'
        // ...
    });
}

Keywords

FAQs

Last updated on 11 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc