我正在尝试使用声纳上的coverageIstanbulReporter
扫描代码的覆盖范围。这是我的karma.conf.js文件:
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
reports: ['html', {
'lcovonly': {
"directory": "coverage",
"filename": "lcov.info",
"subdirectory": "lcov"
}
}],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml', 'dots'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
我的build.gradle文件具有声纳的属性:
sonarqube {
properties {
// Sonar Specific properties
property 'sonar.host.url', '' // This is the Sonar Server
property "sonar.projectName", ""
property "sonar.projectKey", ""
property "sonar.sources", "./src"
property "sonar.exclusions", "**/*.spec.js,**/test.ts,"
property "sonar.language", "ts"
property "sonar.typescript.lcov.reportPaths", "coverage/lcov/lcov.info"
property "sonar.test.inclusions", "**/*.spec.ts"
}
}
现在,问题是,声纳的覆盖范围并不反映我测试过的覆盖范围。另外,在本地运行时,在我的计算机上看不到coverage / lcov / lcov.info文件。
我不确定我的代码出了什么问题。
答案 0 :(得分:0)
您是否使用此命令来运行单元测试
ng test --code-coverage
这应该产生lcov.info文件。