Angular-cli test coverage all files

前端 未结 6 1217
灰色年华
灰色年华 2021-02-07 09:16

I am running the following command to unit test and generate code code coverage report.

ng test --code-coverage

It is writing code coverage re

6条回答
  •  野的像风
    2021-02-07 10:00

    karma.conf.js should be like this. No other configuration is required ng cli will take care of everything. stop the previous run ng test and run ng test --code-coverage.

    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' ],
          fixWebpackSourcePaths: true
        },
        angularCli: {
          environment: 'dev'
        },
        reporters: ['progress', 'kjhtml'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: ['Chrome'],
        singleRun: false
      });
    };
    

提交回复
热议问题