我開始使用ES6與我的摩卡測試缺少類的屬性,但它與失敗: Missing class properties transform.
陣營摩卡 - `transform`
測試
"test": "BABEL_ENV=test nyc mocha --watch tap 'test/**/*.spec.js'",
組件
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",
錯誤
> BABEL_ENV=test nyc mocha --watch tap 'test/**/*.spec.js'
/var/www/kindred.com/node_modules/babel-core/lib/transformation/file/index.js:590
throw err;
^
SyntaxError: /var/www/kindred.com/src/components/Signin/index.js: Missing class properties transform.
17 | }
18 |
> 19 | changed = (e) => {
| ^
20 | let newDeets = {};
21 | newDeets[e.target.name] = e.target.value;
22 | this.setState(newDeets);
謝謝隊友:)不幸的是,這兩個東西同樣的錯誤增加了。 –