Skip to main content

Cucumber Runner

A plugin to use CucumberJS in StrykerJS

🥒 💖 👽

Note: this plugin only supports the @cucumber/cucumber nodejs test runner. If you're running cucumber with Jest or Karma, be sure to use those respective test runners instead.

Install

Install @stryker-mutator/cucumber-runner locally within your project folder, like so:

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

Peer dependencies

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

  • @cucumber/cucumber
  • @stryker-mutator/core

You can find the peerDependencies in @stryker-mutator/cucumber-runner's package.json file.

Configuring

You can configure the cucumber test runner in the stryker.config.json (or stryker.config.js) file.

{
"testRunner": "cucumber",
"cucumber": {
"profile": "stryker",
"features": ["my-features/my-feature.feature"],
"tags": ["my-tag"]
}
}

The cucumber runner supports loading cucumber profiles from your cucumber.js configuration file. The default profile will automatically be loaded if none was specified.

cucumber.profile [string]

Default: "default"

Choose which profile to run. See cucumber profiles

cucumber.features [string[]]

Default: ["features"]

Choose which features to load. See Running specific features.

cucumber.tags [string[]]

Default: undefined

Choose which tags to focus. See Tags.

Coverage analysis

The @stryker-mutator/cucumber-runner plugin supports coverage analysis, test filtering and test location reporting. This means that --coverageAnalysis perTest (which is the default) is supported and will yield the best performance.

Non-standard feature file locations

As of @stryker-mutator/cucumber-runner version 6.1, non-standard feature file locations are supported out of the box.

TypeScript

If you're using ts-node to just-in-time transpile your TypeScript code with native ESM using a custom --loader, you will also need to add that to Stryker. For example, if you use this setup:

{
"scripts": {
"test": "cross-env NODE_OPTIONS=\"--loader ts-node/esm\" cucumber-js",
"test:mutation": "stryker run"
}
}

You will also need to add the --loader to your 'stryker.config.json' file:

{
"testRunnerNodeArgs": ["--loader", "ts-node/esm"],
"testRunner": "cucumber"
}