More details on using Mocha with Babel here
Three possibilities:
- Avoid features which require runtime support (including new Built-ins and generators)
- Require
@babel/runtime
directly, allowing usage of generators, but not polyfills which would modify the global environment - Require
@babel/polyfill
as a peer dependency and document that the consuming app must require it
This example app does not use features which require runtime support.
npm run compile
- compile the ES6 Babel into the/lib
directorynpm test
- run the tests using the local.mocharc.yaml
config file. The config includes the Babel transpilation hook@babel/register
. We have the babel config set inside.babelrc
.