I am trying to run with some unit test with mocha on ES6 modules with the following command:
node --experimental-modules .\node_modules\mocha\bin\mocha --reporter progress "client/assets/utils/url-utils.test.mjs"
But I get the following error:
(function (exports, require, module, __filename, __dirname) { export class URLUtils {
^^^^^^
SyntaxError: Unexpected token export
Isn't the --experimental-modules
param supposed to let me use ES6 modules? I would prefer to avoid using Babel or other transpilers for this.
Node version: 11.7.0
Mocha version: 5.2.0
In order to run mocha with experimental modules, you should:
npm install mocha-esm --only-dev
npx mocha client/assets/utils/url-utils.test.mjs -r esm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With