How can I configure Mocha/Babel to also transform a module in my node_modules
folder when required?
I am developing an application in ES6 with react.
I include an external react component which I installed through npm install
.
When I run the test (mocha --recursive --compilers js:babel/register
) the test fails with an Unexpected token '<'
error from the external module.
The reason is that the external react module needs to be transformed when being loaded. This is specified in the modules package.json
like so:
"browserify": {
"transform": [
"reactify"
]
}
It runs fine for the browser. The source is compiled with browserify -t babelify
. The browserify
information from the package.json
is used and the module is transformed properly when it is loaded.
How can I configure Mocha/Babel to take this also into account?
Or how can I configure Mocha/Babel to also compile the modules in the node_modules
folder?
Or any other way to solve this?