2017-04-08 5 views
0

私はreact-tool-boxでアプリを作成しようとしています。また、試験のためにJestを試してみます。React Jest es6(残り広がり演算子)babel設定が動作しない

このテストは失敗します。 Jestのes6構成の問題のようです。

●テストスイートを実行することができなかった

/home/user/project/react-tool-box/react-toolbox-example/src/frontend/components/PurpleAppBar.js: Unexpected token (5:34) 
    3 | import theme from './PurpleAppBar.css'; 
    4 | 
    > 5 | const PurpleAppBar = ({ children, ...other }) => (
     |         ^
    6 | <AppBar {...other} theme={theme}> 
    7 |  Hello developer! 
    8 |  {children} 

jest.config.js

{ 
"moduleFileExtensions": [ 
    "js", 
    "jsx" 
], 
"scriptPreprocessor": "<rootDir>/node_modules/babel-jest", 
"moduleNameMapper": { 
    "App": "<rootDir>/src/frontend/components/App.js" 
} 

}

.bablerc

{ 
    "presets": [ 
    "react", 
    "es2015" 
    ] 
} 

package.jsonスクリプト:

...  
"scripts": { 
     "start": "node_modules/.bin/cross-env NODE_ENV=development node_modules/.bin/webpack-dev-server --colors --config webpack.config.js", 
     "build": "node_modules/.bin/cross-env NODE_ENV=production UV_THREADPOOL_SIZE=100 webpack --config webpack.config.js", 
     "deploy": "gh-pages -d build", 
     "test": "jest --config jest.config.js" 
     }, 
... 

答えて

0

回答が見つかったhere

.babelrcする "ステージ3" を追加します。

{ 
    "presets": ["es2015", "stage-3", "react"] 
} 
関連する問題