To fix Babel unexpected token import when running mocha tests with JavaScript, we add the @babel/preset-env library.
To install it, we run
npm install @babel/preset-env --save-dev
Then in the .babelrc file, we add
{
"presets": ["@babel/preset-env"]
}
to add the Babel preset to clear the syntax error.