React Native Environment Info:
System:
OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver)
CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Memory: 1.53 GB / 11.63 GB
Shell: 5.4.2 - /bin/zsh
Binaries:
Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
Yarn: 1.19.0 - /usr/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.3/bin/npm
npmPackages:
react: 16.8.3 => 16.8.3
react-native: ^0.59.8 => 0.59.10
我有以下配置:
//babel.config.js
module.exports = {
presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
plugins: [
"@babel/plugin-proposal-class-properties"
]
};
//jest.config.js
module.exports = {
preset: 'react-native',
setupFilesAfterEnv: ['<rootDir>/setup-tests.js'],
};
//package.json
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/preset-env": "^7.6.2",
"@babel/runtime": "^7.4.5",
"babel-jest": "^24.9.0",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"jest": "^24.9.0",
"jest-enzyme": "^7.1.1",
"metro-react-native-babel-preset": "^0.54.1",
"prettier": "^1.18.2",
"react-dom": "^16.10.1",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
},
这是我得到的错误:
我已经阅读了许多github问题,但是它们与babel和jest的早期版本太旧了,其中大多数都带有.bablerc
。我该如何解决这个问题?