mocha test.js --require=@babel/register
scripts/babel.config.jspackage.jsonHow can I get this to work without adding a new file or moving my Babel config?
What version of mocha/babel etc?
How does your app point to that babel config? Does that work?
Any reason you did not want to place the config in root (or package.json), which i believe is the recommended approach?
"scripts": {
"build": "babel lib/ --config-file=./scripts/babel.config.js --out-dir=lib-cjs/ --source-maps"
}
I prefer not to have too many files in the project root.
@stevenvachon you may need a new file to load babel and specify the config value, see below. AFAIK there is no way to pass a babel cli option from mocha cli directly.
mocha config
require: 'scripts/register-babel.js'
scripts/register-babel.js
require("@babel/register")({
configFile: "./scripts/babel.config.js"
});
Does that help?
Does that help?
Yup! Thanks!
I didn't use a mocha config file, though; instead opting for the --require CLI option.
Most helpful comment
@stevenvachon you may need a new file to load babel and specify the config value, see below. AFAIK there is no way to pass a babel cli option from mocha cli directly.
mocha config
scripts/register-babel.js
Does that help?