dimanche 7 mai 2017

React Mocha - `Missing class properties transform`

I'm starting to use es6 with my mocha tests, but its failing with: Missing class properties transform.

Test

"test": "BABEL_ENV=test nyc mocha --watch tap 'test/**/*.spec.js'",

Component

class SignIn extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            email: 'as',
            pw: 'as'
        };

        this.logIn = this.logIn.bind(this);
        this.changed = this.changed.bind(this);
    }

    changed = ( e ) => {
        let newDeets = {};
        newDeets[e.target.name] = e.target.value;
        this.setState(newDeets);
    };

.babelrc

{
  "presets": ["es2015", "react","react-hmre"],
  "ignore": [
    "public/**/*.js"
  ],
}

package.json

"autoprefixer": "^6.4.0",
"babel-core": "^6.11.4",
"babel-eslint": "^4.1.6",
"babel-jscs": "^2.0.5",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.11.1",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-stage-0": "^6.5.0",

Error

> BABEL_ENV=test nyc mocha --watch tap 'test/**/*.spec.js'

/var/www/http://ift.tt/2pjqfCe
      throw err;
      ^

SyntaxError: /var/www/http://ift.tt/2qG0h0l: Missing class properties transform.
  17 |   }
  18 | 
> 19 |   changed = ( e ) => {
     |   ^
  20 |     let newDeets = {};
  21 |     newDeets[e.target.name] = e.target.value;
  22 |     this.setState(newDeets);

Aucun commentaire:

Enregistrer un commentaire