最近将我的角度应用程序版本迁移到 13。删除了 karma-coverage-istanbul-reporter 并添加了 karma-coverage。 在执行测试时,生成的覆盖率报告是空的,如附图所示。
npm run ng test --no-watch --codecoverage
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-coverage'),
require('karma-jasmine-html-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageReporter: {
dir: require('path').join(__dirname, './test/coverage/'),
reporters: [
{ type: 'html', subdir: 'html-report' },
{ type: 'lcovonly', subdir: 'lcov-report' }
],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'coverage'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};
我不确定我在这里错过了什么。