ReferenceError:系统未定义

时间:2018-08-28 10:15:27

标签: jestjs babel-jest

尝试测试使用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",

我已经在互联网上寻找了类似的问题,但是没有帮助:

0 个答案:

没有答案
相关问题