I am trying to update my unit tests by using mocha and enzyme. The code that I am testing is in ES6, using JSX and React.
I have been unable to get mocha to
This has been a very common problem for users of Babel 6, which on its own (babel-core) doesn't do anything. It requires that transforms / plugins are fed to it during transpilation.
Babel offers bundles of common plugins as presets. Common for React projects are babel-preset-2015
, babel-preset-react
and babel-preset-stage-0
. After npm installing them, add a .babelrc
config file that looks something like this:
{
"presets": ["react", "es2015", "stage-0"]
}
For mocha with gulp checkout this stack gulp-mocha how to pass the compilers flag?.
And read here about setting up Babel 6 generally https://babeljs.io/blog/2015/10/31/setting-up-babel-6