好了,这几天我一直在为这件事发疯。因此,我最后将向StackOverflow的优秀人员寻求非常需要的帮助:)
Here is the error I'm getting => Identifier 'global' has already been declared
And it seems to not recognize the require keyword
所以目前,50%的测试套件通过了测试。
它似乎只在调用redux reducers的测试中抛出。因为对于几乎所有失败的测试,错误都是相同的。
这是我当前的babel.config.js
module.exports = function(api) {
const isTest = api.env('test')
const presets = [
isTest && [
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
[
'next/babel',
{
'preset-env': {},
'transform-runtime': {},
'styled-jsx': {},
'class-properties': {},
},
],
].filter(Boolean)
const plugins = ['babel-plugin-styled-components']
return {
presets,
plugins,
sourceType: 'unambiguous',
}
}并且依赖项在
"devDependencies": {
"@babel/core": "^7.3.3",
"@babel/preset-env": "^7.3.1",
"@cypress/snapshot": "^2.0.1",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.1.0",
"babel-plugin-styled-components": "^1.10.0",
"cross-env": "^5.2.0",
"cypress": "^3.1.5",
"eslint": "^5.14.1",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^4.0.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jest": "^22.2.2",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-react-hooks": "^1.0.1",
"husky": "^1.3.1",
"jest": "^24.1.0",
"jest-canvas-mock": "^1.1.0",
"jest-dom": "^3.1.2",
"next-progressbar": "^1.0.0",
"nock": "^10.0.6",
"node-sass": "^4.11.0",
"nodemon": "^1.18.10",
"prettier": "1.16.1",
"pretty-quick": "^1.10.0",
"react-testing-library": "^5.9.0",
"redux-mock-store": "^1.5.3",
"require-all": "^3.0.0"
}发布于 2019-04-03 16:50:34
好了,我现在已经解决了,这不是jest或巴别塔的问题。我有我想要的,一个保留的名称作为一个变量,它会抛出一个令人困惑的错误,因为自上一次巴别塔以来。

https://stackoverflow.com/questions/54781944
复制相似问题