Skip to content

Commit

Permalink
feat(cucumber): support native esm (#3596)
Browse files Browse the repository at this point in the history
Add support for native ESM to the cucumber runner. This means that [hot-reload is supported](https://stryker-mutator.io/blog/stryker-js-v6-expeditious-superior-mutations/#-hot-reload). Unfortunately, this does mean we had to drop support for cucumber 7 and lower.

How to use native ESM with cucumber is documented here: https://github.com/cucumber/cucumber-js/blob/main/docs/esm.md

BREAKING CHANGE: The `@stryker-mutator/cucumber-runner` now requires `@cucumber/cucumber` v8 or up.
  • Loading branch information
nicojs committed Jun 25, 2022
1 parent bd98b87 commit 4eaf713
Show file tree
Hide file tree
Showing 31 changed files with 3,111 additions and 2,339 deletions.
44 changes: 3 additions & 41 deletions docs/cucumber-runner.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ As such, you should make sure you have the correct versions of its dependencies
* `@cucumber/cucumber`
* `@stryker-mutator/core`

You can find the [`peerDependencies` in @stryker-mutator/cucumber-runner's package.json file](https://github.com/stryker-mutator/stryker-js/blob/master/packages/cucumber-runner/package.json#L36).

## Configuring

You can configure the cucumber test runner in the `stryker.conf.json` (or `stryker.conf.js`) file.
Expand Down Expand Up @@ -60,50 +62,10 @@ Default: `undefined`

Choose which tags to focus. See [Tags](https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md#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

Your feature files might be located in a directory other than `features`. For example: `my-features`. In that case, you might have your default profile in cucumber.js config file defined as:

```js
module.exports = {
default: 'my-features/**/*.feature'
}
```

And use this StrykerJS configuration

```json
{
"testRunner": "cucumber"
}
```

This will work. Stryker will use your default profile and load any options you provide there. Unfortunately [this will remove this plugins ability to filter tests](https://github.com/cucumber/cucumber-js/issues/1712), meaning that pretty much all the tests are executed for each mutant.

A solution is to specify a _shadow profile_ and use that for Stryker:

```diff
module.exports = {
default: 'my-features/**/*.feature',
+ stryker: ''
}
```

And use this StrykerJS configuration

```diff
{
"testRunner": "cucumber",
+ "cucumber": {
+ "profile": "stryker",
+ "features": ["my-features/**/*.feature"]
+ }
}
```

This will make sure your feature files are run during the dry run and still allow the plugin to filter specific tests during the mutation testing phase.
As of `@stryker-mutator/cucumber-runner` version 6.1, non-standard feature file locations are supported out of the box.

0 comments on commit 4eaf713

Please sign in to comment.