[英]Angular Unit testing : can't change the reporter of karma
我正在尝试将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
我没有引用istanbul:
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
。
因此,我在Angular CLI项目上写了一个问题,他们告诉我,无论您进行了什么设置,使用code coverage
选项都会自动添加istanbul软件包。 我现在使用的命令
ng test --reporters=junit --watch=false || ECHO
要摆脱上述错误,正确安装的软件包是:
卡玛 - 覆盖 - 伊斯坦布尔 - 记者
npm install karma-coverage-istanbul-reporter --save-dev
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.