如何在控制台中获得更好的测试报告? [英] How to get better test reports in the console?

查看:41
本文介绍了如何在控制台中获得更好的测试报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当简单的karma.config.js文件

I have a fairly simple karma.config.js file

basePath = '../';


files = [
  JASMINE,
  JASMINE_ADAPTER,
  'js/lib/angular*.js',
  'test/lib/angular/angular-mocks.js',
  'js/**/*.js',
  'test/unit/**/*.js'
];

autoWatch = true;
browsers = ['PhantomJS'];


当我运行karma start config/karma.conf.js --single-run时,我得到以下输出


When I run karma start config/karma.conf.js --single-run I'm getting the following output

$ karma start config/karma.conf.js --single-run
[2013-06-24 23:47:08.750] [DEBUG] config - autoWatch set to false, because of singleRun
INFO [karma]: Karma server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9 (Mac)]: Connected on socket id LwMoWxzIbSUuBsvIqB_m
PhantomJS 1.9 (Mac): Executed 6 of 6 SUCCESS (0.073 secs / 0.02 secs)

我一直在寻找可以告诉我如何获取记录的测试输出的信息(例如SUCCESS Unit: services myService should behave)

I've been searching for something to tell me how to get the output of the tests that get logged (e.g. SUCCESS Unit: services myService should behave)

我可以看到测试输出的唯一方法是打开Chrome并单击调试",然后显示开发人员工具控制台.我希望将消息注销到终端,但是我不知道如何使它正常工作.

The only way I can see the output of the tests is to open Chrome and click 'Debug', then show the developer tools console. I want the messages to be logged out to the terminal, but I cannot figure out how to get this working.

推荐答案

通过安装 karma-规格报告者

npm install karma-spec-reporter --save-dev

并将其添加到我的karma.config.js

and adding this my karma.config.js

reporters: ['spec'],

根据业力文档

默认情况下,Karma会将所有与其同级的NPM模块装入其名称,它们的名称与karma- *相匹配.

By default, Karma loads all NPM modules that are siblings to it and their name matches karma-*.

但是一些用户不得不将以下内容添加到他们的配置中

but some users have had to add the following to their config

plugins: ['karma-spec-reporter']

这篇关于如何在控制台中获得更好的测试报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆