How to measure common coverage for Polymer components + .js files?

三世轮回 提交于 2019-12-03 08:49:43

For Polymer, you would normally use web-component-tester (WCT) to test your components, and the web-component-tester-istanbul plugin for code coverage. You'd configure wct.conf.json in the root of your project with something like this:

{
  "suites": [
    "test/components/my-view1/my-view1.html"
  ],
  "plugins": {
    "istanbul": {
      "dir": "./build/coverage",
      "reporters": [
        "text-summary",
        "lcov"
      ],
      "include": [
        "*.js",
        "*.html"
      ],
      "exclude": []
    }
  }
}

And then run wct, which outputs something like this:

Unfortunately, a recent upgrade in WCT has made the coverage plugin incompatible, such that the plugin never gets called, so coverage is always shown as 100% (0/0) (no lines covered, no lines seen).

For Polymer components there is a solution to measure common coverage with karma-coverage: split to .js files and include it to components. Example is here

@tony19, this PR fixes the web-component-tester-istanbul plugin to support WCT >= 6.4.0 https://github.com/thedeeno/web-component-tester-istanbul/pull/45

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!