Mocha with ES6 using Babel 7.x#

npm install --save-dev @babel/core mocha @babel/preset-env @babel/register

add the following to .babelrc

{
  "presets": ["@babel/preset-env"]
}

add this to package.json

"scripts": {
  "test": "mocha --require @babel/register"
}

run tests:

npm run test

References:

  • https://github.com/mochajs/mocha/wiki/compilers-deprecation
  • https://babeljs.io/docs/en/babel-register/
  • https://babeljs.io/docs/en/babel-preset-env