You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a mocha project with esm, you might run into this error:
20:15:50 (21474) ERROR DryRunExecutor One or more tests resulted in an error:
SyntaxError: Cannot use import statement outside a module
/home/nicojs/github/mocha-esm-ts-node/.stryker-tmp/sandbox7723690/test/say-hello.spec.ts:2
import assert from 'assert';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at new Script (vm.js:102:7)
at createScript (vm.js:263:10)
at Object.runInThisContext (vm.js:311:10)
at wrapSafe (internal/modules/cjs/loader.js:989:15)
at Module._compile (internal/modules/cjs/loader.js:1049:27)
The reason for this is that mocha has an exception in place for --require esm:
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
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: