通过代码覆盖失败的开玩笑测试可能与babel转换问题有关

时间:2018-06-14 09:56:09

标签: jestjs babel-jest

当覆盖标志打开而没有覆盖标记所有测试通过时,某些jest测试失败。

Test suite failed to run
   'with' in strict mode (5:0)
        3 | var __t, __p = '', __j = Array.prototype.join;
        4 | function print() { __p += __j.call(arguments, '') }
        5 | with (obj) {
          | ^
        6 |
        7 |  value = _isArray(value) ? value.join(', ') : value ;
        8 | __p += '\n<div class="field-input ' +


babel配置

"babel": {
    "presets": [
      [
        "env",
        {
          "targets": {
            "node": "current"
          }
        }
      ],
      "stage-2",
      "react"
    ],
    "plugins": [
      "dynamic-import-node",
  "transform-decorators-legacy",
    "transform-class-properties",
    "add-module-exports"
    ]
  }

注意:在实际代码中,没有一次使用with语句,但是在编译后,超过1000+ with语句就在构建中。

0 个答案:

没有答案