Trying to unit test reactjs application using mocha but getting error from es6 features (import/export) used inside node_modules
folder. The application in question is transpiled using babel but since one of react component is using a module from node_modules
its throwing error Syntax Error:Unexpected token export
. I am aware that babel ignores node_modules folder by default, but not sure how to approach this. Any help would be appreciated. Thanks.
Test Command :-
"test": "SET NODE_ENV=test&& mocha --require @babel/register --require ignore-styles -r jsdom-global/register \"./src/**/*.test.js\"",
babel.config.js :-
module.exports = function (api) {
const presets = ["react-app"];
const plugins = [
"@babel/plugin-transform-modules-commonjs",
"inline-react-svg"
];
const ignore = [/node_modules/]
api.cache(false);
return {
presets,
plugins,
ignore
}
};