Running mocha tests result in "Unexpected reserved word" error

Viewed 1506

STEP: npm test

ERROR: "Unexpected reserved word"

I had this working earlier today and am not aware of anything I changed that could have caused a regression. When I run npm test I get "Unexpected reserved word" and it points to an ES6 import statement. My understanding is --compilers js:babel-register should resolve that issue.

I have tried installing babel-core both globally and locally and using babel-core/register instead. Same result.

Here is my 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 is 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/

Again, I was successfully executing tests with this script earlier today.

1 Answers
Related