使用伊斯坦布尔和声纳qube测试SFC的覆盖率-lcov.info中的源文件路径错误

时间:2018-09-12 15:23:03

标签: javascript vue.js sonarqube istanbul nyc

我使用webpack进行覆盖检查的测试。

"test-with-coverage": "cross-env NODE_ENV=test nyc --report-dir=../../../target/ --reporter=lcov --reporter=text mocha-webpack --require jsdom-global/register --webpack-config webpack.config.test.js \"test/**/*.test.js\""

使用NYC CLI和伊斯坦布尔

  "nyc": {
    "require": [
      "babel-register"
    ],
    "include": [
      "js/**/**/*.(js|vue*)"
    ],
    "sourceMap": false,
    "instrument": false
  },

.babelrc看起来像:

{
  "presets": ["env"],
  "env": {
    "test": {
      "plugins": ["istanbul"]}
  }

}

我将单个文件组件与vue.js一起使用,而声纳qube没有显示这些文件的测试范围。

在pom.xml中配置了声纳qube

<sonar.javascript.lcov.reportPaths>target/lcov.info</sonar.javascript.lcov.reportPaths>

在webpack.config.js中,我将其用作开发工具“ inline-source-map”,这会在报告文件(lcov.info)中产生错误的源文件路径。

SF:C:\src\main\frontend\js\components\js\components\VueComponent.vue

尽管原始路径是:

SF:C:\src\main\frontend\js\components\VueComponent.vue

我知道这个问题是众所周知的,我应该将其用作开发工具“ #eval”,但这会产生源文件路径:

SF:C:/src/main/frontend/js/components/VueComponent.vue?vue&type=script&lang=js&

SonarQube以两种方式产生0%的测试覆盖率。

有什么办法可以解决我的问题吗?

0 个答案:

没有答案