javascript Karma runner 控制台 - 仅输出失败的测试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18121197/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Karma runner console - output only failed tests
提问by PrimosK
This is default output of Karma test runner
(with one failed test):
这是Karma test runner
(有一个失败的测试)的默认输出:
.
..
...
e 28.0 (Windows): Executed 413 of 421 (1 FAILED)
e 28.0 (Windows): Executed 414 of 421 (1 FAILED)
e 28.0 (Windows): Executed 415 of 421 (1 FAILED)
e 28.0 (Windows): Executed 416 of 421 (1 FAILED)
e 28.0 (Windows): Executed 417 of 421 (1 FAILED)
e 28.0 (Windows): Executed 418 of 421 (1 FAILED)
e 28.0 (Windows): Executed 419 of 421 (1 FAILED)
e 28.0 (Windows): Executed 420 of 421 (1 FAILED)
e 28.0 (Windows): Executed 421 of 421 (1 FAILED)
e 28.0 (Windows): Executed 421 of 421 (1 FAILED) (1.74 secs / 1.091 secs)
I don't like the fact that one have to scroll all the way up to the test that failed to see an exception. This might get annoying over the time so my question is whether is it possible to somehow change the output so that only tests that failed would be reported in the console?
我不喜欢这样一个事实,即必须一直滚动到未能看到异常的测试。随着时间的推移,这可能会很烦人,所以我的问题是是否有可能以某种方式更改输出,以便只有失败的测试才会在控制台中报告?
So in the case of one failed test I would prefer output similar to this:
因此,在一次测试失败的情况下,我更喜欢与此类似的输出:
Chrome 28.0 (Windows) FailedTest only should be printed to console FAILED
ReferenceError: something is not defined
at null.<anonymous> (c:/SuperProject/src/test/FailedTest.js:10:10)
Chrome 28.0 (Windows): Executed 71 of 421 (1 FAILED)
instead of the output above.
而不是上面的输出。
回答by Steve Jansen
Looking at http://karma-runner.github.io/0.10/config/configuration-file.html
看着http://karma-runner.github.io/0.10/config/configuration-file.html
Have you tried setting the config to use an empty reporters
array? Karma v0.10 defaults to a reporters config of ['progress']
, which is likely causing your verbose output.
您是否尝试将配置设置为使用空reporters
数组?Karma v0.10 默认为 的记者配置['progress']
,这可能会导致您的输出冗长。
You might like the 'dots' reporter. You can try it on the CLI using
您可能喜欢“点”记者。您可以在 CLI 上使用
karma start yourconfig.js --reporters dots
回答by jaapz
I use a few very verbose karma reporters myself, and I had to scroll up the terminal to find my errors too. This annoyed me to no end, so I wrote a reporter that just reports the failed tests. It works nice in combination with 'karma-spec-reporter'.
我自己使用了一些非常冗长的 karma 报告器,我也不得不向上滚动终端才能找到我的错误。这让我很恼火,所以我写了一个记者,只报告失败的测试。它与“karma-spec-reporter”结合使用效果很好。
回答by Heather Roberts
I found using the dots reporter and setting:
我发现使用 dots 报告器和设置:
client: {
captureConsole: false
}
in the karma config file sorted my issues out. The client.captureConsole
stops any console.log()
showing up.
在 karma 配置文件中解决了我的问题。在client.captureConsole
任何停止console.log()
显示出来。