更新到 Angular 13 后,生成的覆盖率报告是空的

问题描述 投票:0回答:0

最近将我的角度应用程序版本迁移到 13。删除了 karma-coverage-istanbul-reporter 并添加了 karma-coverage。 在执行测试时,生成的覆盖率报告是空的,如附图所示。 image

测试执行命令

npm run ng test --no-watch --codecoverage

我的 karma.conf.js

// 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
  });
};

我不确定我在这里错过了什么。

预期结果类似于添加的图像 - 我在版本升级之前生成的旧报告。 image

typescript karma-jasmine code-coverage angular13 karma-coverage
© www.soinside.com 2019 - 2024. All rights reserved.