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
Using ESM with Mocha #3269
Comments
I’ve managed to make it work by requiring npx -n=require -n=esm wdio It seems like |
I have the same problem.
However, it is not maintained so I want to replace reify with esm. |
@dictav Cool. Never know it works. {
...
specs: ['./test/**/*.js'],
mochaOpts: {
require: ['esm'],
},
...
} |
Looks like this works now as expected, closing. |
@christian-bromann I've got the time to do a testing using Anyone got any luck to get |
Just to update this issue with some other workaround that might work for folks out there. Here's my attempt to instead use /** package.json */
{
"devDependencies": {
"@babel/preset-env": "^7.9.6",
"@babel/register": "^7.9.0"
}
} /** babel.config.json */
{
"presets": [
["@babel/preset-env", {
"targets": {
"node": 12
}
}]
]
} // wdio.config.js
module.exports = {
...
mochaOpts: {
...
require: ['@babel/register'],
},
}; This might increase the install size of your package/ project but this could be another more reliable alternative as compared to using The upside of using So, no more using Hope this helps. |
None of these solutions worked for me on Node v14.4.0, webdriverio v6.4.5. I am able to run ESM unit tests with mocha, just not ESM specs with wdio. Edit: this is how mocha does it: https://github.com/giltayar/mocha/blob/master/lib/esm-utils.js
|
Environment (please complete the following information):
Describe the bug
I’m trying to use ES Modules with Mocha and esm following recommended way - by using Mocha
require
to load ESM loader, and I’m loading it withmochaOpts
but I’m getting error described in log below. Is this normal behavior when using ESM loader? Is this something related to Mocha or WebDriverIO? When using just Mocha to run tests (e.g.mocha --require esm ...
everything works fine).Config of WebdriverIO
Log
The text was updated successfully, but these errors were encountered: