-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mocha runner does not support require "esm" #3014
Labels
🐛 Bug
Something isn't working
Comments
The solution is to change your Stryker config to also require {
"$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
"testRunner": "mocha",
+ "testRunnerNodeArgs": ["--require", "esm"],
"mochaOptions": {
"spec": ["test/*.ts", "test/*.js"],
- "require": ["esm", "ts-node/register"]
+ "require": ["ts-node/register"]
}
} We should throw an error from the mocha runner, explaining how to fix it. |
Maybe interesting to know: |
nicojs
added a commit
that referenced
this issue
Jul 22, 2021
Provide a clear error message when users configure `mochaOptions.require` to include `"esm"`. You should provide it as a node argument instead. ```diff { "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json", "testRunner": "mocha", "mochaOptions": { - "require": ["esm"] }, + "testRunnerNodeArgs": ["--require", "esm"] } ``` Fixes #3014
We released |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
When using a mocha project with esm, you might run into this error:
The reason for this is that mocha has an exception in place for
--require esm
:https://github.com/mochajs/mocha/blob/6eb3c3cda72102144ef2f2dd9b90ddc2d074c9b6/bin/mocha#L88-L94
In order to make this work in Stryker, you would need to rebuild this yourself
Stryker config
Test runner config
Stryker environment
(5.2.2 or earlier)
The text was updated successfully, but these errors were encountered: