Jest - React チュートリアルに従って、React コンポーネントをテストしました。
残念ながら、Jest は次のようにスローします。
SyntaxError: /Users/mishamoroshko/react-playground/src/search-panel/questions/__tests__/questions-test.js: /Users/mishamoroshko/react-playground/src/search-panel/questions/questions.js: Unexpected token ILLEGAL
at Contextify.sandbox.run (/Users/mishamoroshko/react-playground/node_modules/jest-cli/node_modules/jsdom/node_modules/contextify/lib/contextify.js:12:24)
at JSDomEnvironment.runSourceText (/Users/mishamoroshko/react-playground/node_modules/jest-cli/src/JSDomEnvironment.js:108:22)
at Object.runContentWithLocalBindings (/Users/mishamoroshko/react-playground/node_modules/jest-cli/src/lib/utils.js:341:23)
再現するには:
git clone git@github.com:SEEK-Jobs/react-playground.git
cd react-playground
npm install
npm test
何か案は?
更新 1:
問題は、Jest が ES6 を認識していないことでしょうか6to5-jest
。
で2つのプリプロセッサを指定する方法はありますpackage.json
か?
"jest": {
"rootDir": "src",
"scriptPreprocessor": "../preprocessor.js",
"unmockedModulePathPatterns": [
"../node_modules/react"
]
}