我正在運行以下命令來進行單元測試並生成代碼覆蓋率報告。Angular-cli測試覆蓋所有文件
ng test --code-coverage
它正在覆蓋文件夾中寫入代碼覆蓋率報告。
我需要看到整個項目的覆蓋面,而不僅僅是有測試的文件。
karma.conf.js
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', 'angular-cli'],
plugins: [
require('karma-jasmine'),
require('karma-jasmine-html-reporter'),
require('karma-chrome-launcher'),
require('karma-remap-istanbul'),
require('angular-cli/plugins/karma'),
require('karma-coverage'),
require('karma-sourcemap-loader')
],
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['angular-cli']
},
mime: {
'text/x-typescript': ['ts','tsx']
},
remapIstanbulReporter: {
reports: {
html: 'coverage',
lcovonly: './coverage/coverage.lcov'
}
},
angularCli: {
config: './angular-cli.json',
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'karma-remap-istanbul']
: ['progress', 'kjhtml'],
coverageReporter: {
includeAllSources: true
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
有同樣的問題。你解決了嗎? – Vnuuk
@Vnuuk https://github.com/angular/angular-cli/issues/1735 –