簡體   English   中英

Karma-coverage檢查JS文件中的測試覆蓋率,而不是Angular 2中的TS

[英]Karma-coverage checks test coverage in JS files instead of TS in Angular 2

我通過伊斯坦布爾檢查TypeScript文件中的測試覆蓋率。 我需要通過karma-coverage設置測試閾值。伊斯坦布爾的報告與karma-coverage報告(我使用Angular-cli)不匹配,因為karma-coverage檢查JavaScript文件中的測試覆蓋率而不是TypeScript。 我使用了其他插件,如karma-threshold-reporter,istanbul-threshold-checker但結果相同。 我該如何解決?

報告為typeScript文件生成

報告為JS文件生成

 module.exports = function (config) { config.set({ basePath: '', frameworks: ['jasmine', 'angular-cli'], plugins: [ require('karma-jasmine'), require('karma-chrome-launcher'), require('karma-remap-istanbul'), require('karma-coverage'), require('angular-cli/plugins/karma') ], files: [ { pattern: './src/test.ts', watched: false } ], preprocessors: { './src/test.ts': ['angular-cli'] }, remapIstanbulReporter: { reports: { html: 'coverage', lcovonly: './coverage/coverage.lcov' } }, coverageReporter: { dir: 'coverage/', reporters: [ {type: 'text-summary'}, {type: 'html'} ], check: { global: { statements: 70, branches: 70, functions: 70, lines: 50 } } }, angularCli: { config: './angular-cli.json', environment: 'dev' }, reporters: ['progress', 'karma-remap-istanbul', 'coverage'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, browsers: ['Chrome'], singleRun: false }); }; 

plugin: ['karma-remap-istanbul', 'karma-istanbul-threshold'],
  coverageReporter: {
        type: 'in-memory',
    },

    remapCoverageReporter: {
        'text-summary': null,
        json: './coverage/coverage-final.json',
        html: './coverage/html-ts'
    },

    istanbulThresholdReporter: {
        src: './coverage/coverage-final.json',
        reporters: ['text'], 

        thresholds: {
            global: {
                statements: 90,
                branches: 90,
                lines: 90,
                functions: 90,
            }
        },
    },

這個配置對我有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM