我正在运行jest / react测试并收到以下错误:
/Users/sn/Documents/react-testing-with-jest-master/starter/CountdownTimer/jest.config.js:2
"moduleFileExtensions": [
^
SyntaxError: Unexpected token :
npm ERR! Test failed. See above for more details.
这是我的jest.config.js:
{
"moduleFileExtensions": [
"js",
"jsx"
],
"moduleNameMapper": {
"Clock": "<rootDir>/app/components/Clock.jsx",
"CountdownForm": "<rootDir>/app/components/CountdownForm.jsx",
"Countdown": "<rootDir>/app/components/Countdown.jsx"
}
}
答案 0 :(得分:0)
由于您已将文件命名为jest.config.js
而不是jest.config.json
,因此您需要导出有效的JavaScript对象。
或者:
jest.config.json
或 jest.config.js
:
{
moduleFileExtensions: [
"js",
"jsx"
],
moduleNameMapper: {
Clock: "<rootDir>/app/components/Clock.jsx",
CountdownForm: "<rootDir>/app/components/CountdownForm.jsx",
Countdown: "<rootDir>/app/components/Countdown.jsx"
}
}