如何解决业力中不存在记者“规格”?

guy*_*abi 5 karma-runner karma-jasmine

我有一个使用generator-angular版本的项目,0.3.0我正在尝试spec在其业力测试中添加一个记者,但我不断收到Reporter "spec" does not exists in karma

阅读了一些资源后,我做了以下步骤

  • 运行命令 npm install karma-spec-reporter --save-dev
  • 我修改了 karma 配置文件(添加了“规范”)

    reporters = ['progress','dots','junit','spec'];

  • 我跑了grunt(反过来跑karma)并得到了错误

我怎样才能让规范报告者在我的环境中工作?

Edu*_*kan 5

刚刚遇到了同样的问题。

通过加载插件来修复,但 NPM 和 github 上一些 Karma 插件的用户指南没有在任何地方提到它。

       plugins: ['karma-chrome-launcher', 'karma-jasmine', 'karma-coverage', 'karma-browserify', 'karma-spec-reporter'],

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['coverage', 'progress', 'spec'],
Run Code Online (Sandbox Code Playgroud)

更新:该插件有一个新版本,它会告诉您加载它。

https://www.npmjs.com/package/karma-spec-reporter-2


guy*_*abi 0

如果有人遇到此问题,解决此问题的一种方法是升级 karma。我不知道我正在使用的版本是否有解决方案(我不知道那是哪个版本,抱歉),但是一旦我升级了版本,它就工作得很好。

确保 karma 升级的标志之一是配置文件需要采用以下格式

module.exports = function(config){
    config.set({
         //... the usual configuration converted from a=b to a:b
         reporters : ['spec'],// -- now this works well.. finally :) 
         //... some more configuration

    });
}
Run Code Online (Sandbox Code Playgroud)

升级过程非常顺利。没有什么大惊喜。我建议升级。