Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

stryker-mocha-runner

stryker-mutator2.6kApache-2.00.17.1TypeScript support: included

A plugin to use the mocha test runner in Stryker, the JavaScript mutation testing framework

stryker, stryker-plugin, mocha, stryker-test-runner

readme

Build Status NPM Node version Gitter

Stryker Mocha Runner

A plugin to use Mocha in Stryker, the JavaScript mutation testing framework.

IMPORTANT: Starting from `stryker-mocha-runner@0.4.0the test framework has been moved to a separate module. Please also installstryker-mocha-framework` if you've previously used this module.

Install

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

npm i --save-dev stryker-mocha-runner

Peer dependencies

The stryker-mocha-runner is a plugin for stryker to enable mocha as a test runner. As such, you should make sure you have the correct versions of its dependencies installed:

  • mocha
  • stryker-api

Configuring

You can configure the mocha test runner in the stryker.conf.js file.

// stryker.conf.js
module.exports = function (config) {
    config.set({
        // ...
        testRunner: 'mocha',
        // ...
        mochaOptions: {
            // Optional mocha options
            files: [ 'test/**/*.js' ]
            opts: 'path/to/mocha.opts',
            ui: 'bdd',
            timeout: 3000,
            require: [ /*'babel-register' */],
            asyncOnly: false,
            grep: /.*/
        }
    });
}

mochaOptions.files [string or string[]]

Default: 'test/**/*.js'

Choose which files to include. This is comparable to mocha's test directory although there is no support for --recursive.

If you want to load all files recursively: use a globbing expression ('test/**/*.js'). If you want to decide on the order of files, use multiple globbing expressions. For example: use ['test/helpers/**/*.js', 'test/unit/**/*.js'] if you want to make sure your helpers are loaded before your unit tests.

mochaOptions.opts [string | false]

Default: 'test/mocha.opts'

Specify a 'mocha.opts' file to be loaded. Options specified directly in your stryker.conf.js file will overrule options from the 'mocha.opts' file. Disable loading of an additional mocha.opts file with false.

The only supported mocha options are used: --ui, --require, --async-only, --timeout, --grep (or their short form counterparts). Others are ignored by the stryker-mocha-runner.

mochaOptions.grep [RegExp]

Default: undefined

Specify a mocha grep command, to single out individual tests.

mochaOptions.ui [string]

Default: undefined

Set the name of your mocha ui

mochaOptions.require [string[]]

Default: []

Set mocha's require option

mochaOptions.asyncOnly [boolean]

Default: false

Set mocha's asyncOnly option

mochaOptions.timeout [number]

Default: undefined

Set mocha's timeout option

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

0.17.1 (2019-02-12)

Note: Version bump only for package stryker-mocha-runner

0.17.0 (2019-02-08)

Features

  • config-editors: Remove side effects from all config editor plugins (#1317) (1f61bed)
  • dependency injection: Add dependency injection for plugins (#1313) (f90cd56), closes #667
  • mocha-runner: Allow empty mochaOptions.opts file (with false) (d9bba6e)
  • port: Deprecate property 'port' (#1309) (2539ee0)
  • test-frameworks: Remove side effects from all test-framework plugins (#1319) (a7160f4)
  • test-runner: Use new plugin system to load TestRunner plugins (#1361) (266247b)
  • transpilers: Remove side effects transpiler plugins (#1351) (9a8b539)

0.16.0 (2018-12-23)

Features

0.15.3 (2018-12-12)

Note: Version bump only for package stryker-mocha-runner

0.15.2 (2018-11-29)

Bug Fixes

  • stryker-api: Update stryker-api peer dependency version (677fc28)

0.15.1 (2018-11-29)

Note: Version bump only for package stryker-mocha-runner

0.15.0 (2018-11-13)

Features

  • mocha-runner: use default mocha.opts file, support relative imports (#1237) (2711c2b), closes #1046

0.14.6 (2018-11-07)

Note: Version bump only for package stryker-mocha-runner

0.14.5 (2018-10-15)

Bug Fixes

  • version: Version bump for failed release (8cf9e87)

0.14.3 (2018-10-03)

Note: Version bump only for package stryker-mocha-runner

0.14.2 (2018-09-14)

Note: Version bump only for package stryker-mocha-runner

0.14.1 (2018-08-21)

Note: Version bump only for package stryker-mocha-runner

0.14.0 (2018-08-19)

Features

  • stryker config: rename config setting reporter to reporters (#1088) (584218a), closes #793

0.13.3 (2018-08-17)

Bug Fixes

  • dependencies: support stryker-api 0.19.0 (#1087) (44ce923)

0.13.2 (2018-08-17)

Note: Version bump only for package stryker-mocha-runner

0.13.1 (2018-08-03)

Bug Fixes

  • mocha-runner: Don't log individual successful tests (#1042) (6732ccf)

0.13.0 (2018-07-20)

Bug Fixes

Features

0.12.3 (2018-07-04)

Note: Version bump only for package stryker-mocha-runner

0.12.2 (2018-05-31)

Note: Version bump only for package stryker-mocha-runner

0.12.1 (2018-05-21)

Note: Version bump only for package stryker-mocha-runner

0.12.0 (2018-04-30)

Features

BREAKING CHANGES

  • node version: Node 4 is no longer supported.

0.11.2 (2018-04-20)

Note: Version bump only for package stryker-mocha-runner

0.11.1 (2018-04-11)

Bug Fixes

0.11.0 (2018-04-04)

Features

  • mocha-runner: implement file discovery in mocha (6ed7a0f)

0.10.8 (2018-03-22)

Bug Fixes

  • peerDependency: update stryker-api requirement to ^0.14.0 (3ce04d4)

0.10.7 (2018-03-22)

Note: Version bump only for package stryker-mocha-runner

0.10.6 (2018-03-21)

Note: Version bump only for package stryker-mocha-runner

0.10.5 (2018-02-07)

Bug Fixes

  • dependencies: update stryker-api requirement to ^0.13.0 (8eba6d4)

0.10.4 (2018-02-07)

Note: Version bump only for package stryker-mocha-runner

0.10.3 (2018-01-19)

Note: Version bump only for package stryker-mocha-runner

0.10.2 (2017-12-21)

Note: Version bump only for package stryker-mocha-runner

0.10.1 (2017-11-27)

Note: Version bump only for package stryker-mocha-runner

0.10.0 (2017-11-13)

Features

  • mocha 4: Add support for mocha version 4 (#455) (de6ae4f)

0.9.1 (2017-10-24)

Note: Version bump only for package stryker-mocha-runner

0.9.0 (2017-10-20)

Bug Fixes

  • mocha framework: Select tests based on name (#413) (bb7c02f), closes #249

Features

  • mocha options: Add support for mocha options (#427) (e0229c8), closes #417

BREAKING CHANGES

  • mocha framework: * Change api of TestFramework. It now provides an array of TestSelection objects, instead of an array of numbers with test ids.

0.8.1 (2017-09-22)

Bug Fixes

  • package.json: Add dependency to tslib. (#387) (fcc8b88)

0.8.0 (2017-09-19)

Features

  • typescript: Add support for TypeScript mutation testing (#376) (ba78168)

BREAKING CHANGES

  • typescript: * Hoist the Mutator interface to a higher abstraction. With this interface it was possible to add mutators for specific ES5 AST nodes. As we're moving away from ES5, this plugin abstraction had to be hoisted to a higher level. It is no longer possible to plugin a specific ES5 node mutator.
  • Update report interface: Rename MutantState.Error => MutantState.RuntimeError.

0.7.0 (2017-08-25)

Bug Fixes

  • MochaTestRunner: Exit with a warning if no tests were executed (#360) (ac52860)

Code Refactoring

  • change ConfigWriter interface name to ConfigEditor (#357) (ec4ae03)

BREAKING CHANGES

  • Public api for ConfigWriter is renamed to ConfigEditor. The corresponding write method is renamed to edit. If you're using custom ConfigWriter plugins you should rename the write method to edit. Please update the stryker-mocha-framework and stryker-karma-runner to the latest versions as they provide the new ConfigEditor plugin.

0.6.0 (2017-08-11)

Features

  • ci-integration: Configurable thresholds based on mutation score (#355) (93f28cc), closes #220

0.5.0 (2017-08-04)

0.4.4 (2017-07-14)

0.4.3 (2017-06-16)

Bug Fixes

  • npmignore: Align npm ignores (#321) (db2a56e)

0.4.1 (2017-06-08)

0.3.0 (2017-04-21)

Bug Fixes

  • deps: Add stryker-api as peerDependency (8b01a66)
  • deps: Add typings as dev-dependency (4ee866a)
  • deps: Fix peer dependency version for mocha (780ca90)
  • deps: Remove unused dependency (121a549)
  • deps: Remove unused dependency (1f6dbba)
  • deps: Set version of stryker api (49a1384)
  • deps: Update out dated dependencies (cc0be9a)
  • deps: Update outdated dependencies (0fc17be)
  • deps: Update version stryker-api (3a1a36c)
  • index: Add file which loads the TestRunner (55fd132)
  • TestRunner: Add try-catch (0c41fbf)
  • tslint: Add linting (9c360b2)

Features

  • es2015-promise: Remove dep to es6-promise (#5) (6f38885)
  • one-pass-coverage: Update test runner (#4) (6716519)
  • ts2: Migrate to typescript 2 (0c9a655)
  • unincluded-files: Support unincluded files (80297bc)

0.2.0 (2016-11-20)

Features

  • one-pass-coverage: Update test runner (#4) (d6aebaa)

0.1.1 (2016-10-03)

Bug Fixes

  • deps: Fix peer dependency version for mocha (aa09049)
  • deps: Remove unused dependency (88530be)
  • deps: Remove unused dependency (f3b4ff4)
  • deps: Set version of stryker api (c772fe0)
  • deps: Update out dated dependencies (c6e166f)
  • deps: Update outdated dependencies (d0e4eaf)
  • deps: Update version stryker-api (a632624)
  • tslint: Add linting (33e4c6e)

Features

  • ts2: Migrate to typescript 2 (bcd4064)

0.1.0 (2016-07-21)

0.0.2 (2016-07-19)

0.0.1 (2016-07-19)

Bug Fixes

  • deps: Add stryker-api as peerDependency (66aec0c)
  • deps: Add typings as dev-dependency (79aeabc)
  • index: Add file which loads the TestRunner (1be6179)
  • TestRunner: Add try-catch (e589e53)

Features

  • unincluded-files: Support unincluded files (00ba196)