尝试测试使用System.import()
的文件时,在Jest测试中遇到以下错误。
* Test suite failed to run
ReferenceError: System is not defined
> 1 | System.import('./Foo.jsx');
| ^
2 |
at Object.<anonymous> (src/Bar.jsx:1:1)
at Object.<anonymous> (src/__tests__/Bar.test.jsx:1:1)
这是我的.babelrc
配置:
{
"presets": [
"react",
"es2015"
],
"plugins": [
"transform-exponentiation-operator",
"transform-object-rest-spread",
"transform-class-properties",
"transform-async-to-generator"
],
"env": {
"test": {
"plugins": [
"dynamic-import-node",
"syntax-dynamic-import"
]
}
}
}
我正在使用以下软件包:
"babel-core": "6.26.0",
"babel-jest": "20.0.3",
"babel-plugin-dynamic-import-node": "^2.0.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-dynamic-import": "^2.0.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-react": "6.24.1",
我已经在互联网上寻找了类似的问题,但是没有帮助: