STEP: npm test
ERROR: "Unexpected reserved word"
I had it before, and I don’t know anything that I changed, which could cause regression. When I start npm test, I get an "Unexpected Reserved Word" and point to an ES6 import statement. My understanding --compilers js:babel-registershould solve this problem.
I tried to install babel-coreboth globally and locally and use it instead babel-core/register. The same result.
Here is mine package.json.
{
"name": "fresh",
"version": "0.0.1",
"private": true,
"scripts": {
"remotedev": "remotedev --hostname=localhost --port=8000",
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "mocha --compilers js:babel-register 'test/**/*.test.js'",
"test:watch": "npm run test -- --watch --watch-extensions jsx"
},
"dependencies": {
"immutable": "^3.7.6",
"lodash": "^4.5.1",
"ramda": "^0.19.1",
"react-native": "^0.21.0",
"react-native-router-flux": "^2.3.8",
"react-native-sortable-listview": "0.0.5",
"react-redux": "^4.4.0",
"redux": "^3.3.1",
"redux-saga": "^0.9.1",
"reselect": "^2.0.3"
},
"devDependencies": {
"babel-register": "^6.7.2",
"chai": "^3.5.0",
"chai-immutable": "^1.5.3",
"mocha": "^2.4.5",
"redux-devtools-filter-actions": "^1.1.0",
"remote-redux-devtools": "^0.1.2",
"remotedev-server": "0.0.3"
}
}
Here are 2 tutorials indicating this should work.
https://onsen.io/blog/mocha-chaijs-unit-test-coverage-es6/
http://jamesknelson.com/testing-in-es6-with-mocha-and-babel-6/
, script .