角度测试:无法加载记者"",未注册

时间:2017-01-05 07:23:10

标签: angular karma-jasmine angular-cli jasmine-reporters

我正在尝试https://cli.angular.io/reference.pdf

中的以下命令
ng test --reporters

显示以下错误。请告诉我如何注册记者。

05 01 2017 12:47:19.437:ERROR [reporter]: Can not load reporter "", it is not re
gistered!
  Perhaps you are missing some plugin?
05 01 2017 12:47:44.876:WARN [karma]: No captured browser, open http://localhost
:9876/
05 01 2017 12:47:44.894:INFO [karma]: Karma v1.2.0 server started at http://loca
lhost:9876/
05 01 2017 12:47:44.895:INFO [launcher]: Launching browser Chrome with unlimited
 concurrency
05 01 2017 12:47:44.897:ERROR [karma]: Found 1 load error

1 个答案:

答案 0 :(得分:12)

我能够弄清楚如何在angular-cli中使用记者

我更新了Karma配置文件(karma.conf.js),如下所示

require('karma-jasmine-html-reporter'),

reporters: config.angularCli && config.angularCli.codeCoverage
              ? ['progress', 'karma-remap-istanbul', 'kjhtml']
              : ['progress', 'kjhtml'],

然后运行以下命令安装插件

npm install karma-jasmine-html-reporter --save-dev

然后我跑

ng test --code-coverage

它正在给我一个类似this

的报告