我试图对我的React应用程序进行单元测试,当我运行npm run jest时,它失败了
Plugin/Preset files are not allowed to export objects, only functions. In /node_modules/babel-preset-react/lib/index.js
试图通过@ babel / preset-env和@ babel / preset-react进行npm安装
请在package.json中找到我的玩笑,babel配置
"jest": {
"moduleNameMapper": {
"^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/test/jest/mocks/fileMock.js",
"^.+\\.(css|styl)$": "identity-obj-proxy"
},
"setupFilesAfterEnv": [
"<rootDir>/test/jest/config.js"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"setupFiles": [
"<rootDir>/test/jest/enzyme.js"
],
"testPathIgnorePatterns": [
"<rootDir>/(node_modules)/"
]
},
"babel": {
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"dynamic-import-node"
]
},
"dependencies": {
"@babel/preset-env": "^7.3.1",
"@babel/preset-react": "^7.0.0"
}
请建议启动并运行测试,并消除node_modules中的错误