我正在尝试将Jest应用于react-redux代码,但现在我陷入了环境设置。似乎该错误与babel有关。尽管互联网上有很多有关“意外令牌”的信息,但我仍然无法解决问题。我的设置已列出以供参考。
任何建议都值得赞赏。
package.json中的脚本(我使用“ npm run test”启动测试),
"scripts": {
"test": "jest",
"test:watch": "jest --watch",
"test:clear": "jest --clearCache"
},
小节显示波纹管,
"babel": {
"env": {
"test": {
"presets": [
"env"
],
"only": [
"./**/*.js",
"node_modules/jest-runtime"
]
}
},
}
devDependencies(与babel有关的所有东西都在这里)
"devDependencies": {
"@babel/core": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/runtime": "^7.4.4",
"babel-core": "^6.26.3",
"babel-jest": "^24.8.0",
"babel-preset-env": "^1.7.0",
"bili": "^4.8.0",
"jest": "^24.8.0",
"regenerator-runtime": "^0.13.2"
},
笑话部分
"jest": {
"setupFilesAfterEnv": [
"<rootDir>/__tests__/setup/setupEnzyme.js"
],
"testPathIgnorePatterns": [
"<rootDir>/__tests__/setup/"
]
},
答案 0 :(得分:0)
我指的是https://www.freecodecamp.org/news/how-to-set-up-jest-enzyme-like-a-boss-8455a2bc6d56/来建立环境。错误可能与隐藏的配置文件有关。