2017-06-01 39 views
1

我想用业力来使用JUnit记者。角度单元测试:不能改变业力记者

当我启动

$ ng test --watch=false --code-coverage 

它总是输出我

10% building modules 1/1 modules 0 active01 06 2017 11:57:51.797:ERROR 
[reporter]: Can not load reporter "coverage-istanbul", it is not registered! 

的问题是,在我的karma.conf.json我没有提到伊斯坦布尔:

module.exports = function (config) { 
    config.set({ 
    basePath: '', 
    frameworks: ['jasmine', '@angular/cli'], 
    plugins: [ 
     require('karma-jasmine'), 
     // require('karma-chrome-launcher'), 
     require('karma-phantomjs-launcher'), 
     require('karma-junit-reporter'), 
     require('karma-mocha-reporter'), 
     require('@angular/cli/plugins/karma') 
    ], 
    files: [ 
     { pattern: './src/test.ts', watched: false } 
    ], 
    preprocessors: { 
     './src/test.ts': ['@angular/cli'] 
    }, 
    mime: { 
     'text/x-typescript': ['ts', 'tsx'] 
    }, 
    junitReporter: { 
     outputDir: 'coverage', // results will be saved as $outputDir/$browserName.xml 
     useBrowserName: false, // add browser name to report and classes names 
     outputFile: 'test-report.xml', // if included, results will be saved as $outputDir/$browserName/$outputFile 
    }, 
    angularCli: { 
     config: './angular-cli.json', 
     environment: 'dev' 
    }, 
    reporters: config.angularCli && config.angularCli.codeCoverage ? 
     ['mocha', 'junit'] : 
     ['mocha'], 
    port: 9876, 
    colors: true, 
    logLevel: config.LOG_INFO, 
    autoWatch: true, 
    browsers: [ 
     'PhantomJS', 
     // 'Chrome' 
    ], 
    singleRun: false 
    }); 
}; 

你有什么想法可能来自哪里?

我也删除了所有在我的package.json文件中引用istanbul的包,我也用npm prune来确定。

回答

2

因此,我在Angular CLI项目上写了一个问题,他们告诉我使用code coverage选项会自动添加istanbul软件包,无论您设置了什么。我使用的命令现在是

ng test --reporters=junit --watch=false || ECHO 
0

正确的软件包安装摆脱上述错误的是:

果报报道,伊斯坦布尔,记者

npm install karma-coverage-istanbul-reporter --save-dev