【发布时间】:2019-04-18 10:05:29
【问题描述】:
我很想运行我的 jest 测试,但不断收到以下错误,我怎样才能运行我的 jest 测试?
● 测试套件无法运行 需要 Babel "^7.0.0-0",但加载的是 "6.26.3"。如果你确定你有一个兼容的@babel/core 版本,很可能你的构建过程中加载了错误的版本。检查此错误的堆栈跟踪以查找第一个未提及“@babel/core”或“babel-core”的条目,以查看调用 Babel 的内容。 在 throwVersionError (node_modules/@babel/helper-plugin-utils/lib/index.js:65:11)
我已经按照这里的指示进行了操作,但仍然没有快乐。
https://jestjs.io/docs/en/getting-started.html#using-babel
我的 package.json:
{
"name": "rgcalendar",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"test:watch": "npm test -- --watch"
},
"jest": {
"preset": "react-native"
},
"dependencies": {
"fsevents": "^1.2.4",
"googleapi": "^1.0.2",
"jest-cli": "^23.6.0",
"moment": "^2.22.2",
"native-base": "^2.8.1",
"node-google-calendar": "^1.1.1",
"prettier": "^1.13.7",
"prop-types": "^15.6.2",
"react": "16.3.1",
"react-dom": "^16.5.0",
"react-native": "^0.57.4",
"react-native-autoreheight-webview": "^1.1.1",
"react-native-calendars": "^1.20.0",
"react-native-events-calendar": "^1.0.8",
"react-native-fontawesome": "^5.7.0",
"react-native-google-signin": "^1.0.0-rc6",
"react-native-iphone-x-helper": "^1.0.3",
"react-native-responsive-fontsize": "^0.1.2",
"react-native-responsive-image": "^2.3.1",
"react-native-vector-icons": "^4.6.0",
"react-navigation": "^2.5.5",
"react-navigation-redux-helpers": "^2.0.2",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"watchman": "^1.0.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0-beta.49",
"@babel/core": "^7.1.6",
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.49",
"@babel/plugin-syntax-dynamic-import": "^7.0.0-beta.49",
"@babel/preset-env": "^7.0.0-beta.49",
"@babel/preset-flow": "^7.0.0-beta.49",
"@babel/preset-react": "^7.0.0-beta.49",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "8.2.3",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.0-beta",
"babel-plugin-module-resolver": "^3.1.1",
"enzyme-adapter-react-16": "^1.5.0",
"eslint": "^5.0.1",
"jest": "23.2.0",
"jest-enzyme": "^6.0.4",
"react-native-mock": "^0.3.1",
"react-test-renderer": "16.3.1",
"regenerator-runtime": "^0.12.1"
}
}
babelrc:
{
"presets": ["env", "react"],
"plugins": [
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-syntax-dynamic-import"
]
}
【问题讨论】:
标签: javascript reactjs jestjs