Karma转轮控制台 - 仅输出失败的测试

Pri*_*osK 23 javascript unit-testing karma-runner

这是默认输出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)
Run Code Online (Sandbox Code Playgroud)

我不喜欢这样一个事实,即必须一直滚动到未能看到异常的测试.这可能会让人讨厌,所以我的问题是,是否有可能以某种方式更改输出,以便只在控制台中报告失败的测试?

所以在一个测试失败的情况下,我更喜欢类似于此的输出:

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)
Run Code Online (Sandbox Code Playgroud)

而不是上面的输出.

Ste*_*sen 40

查看http://karma-runner.github.io/0.10/config/configuration-file.html

您是否尝试过将配置设置为使用空reporters数组?Karma v0.10默认为记者配置['progress'],这可能会导致您的详细输出.

你可能喜欢'点'记者.您可以使用CLI在CLI上尝试

karma start yourconfig.js  --reporters dots
Run Code Online (Sandbox Code Playgroud)


Hea*_*rts 8

我发现使用点记者和设置:

client: {
    captureConsole: false
}
Run Code Online (Sandbox Code Playgroud)

在业力配置文件中解决了我的问题。停止client.captureConsole任何console.log()出现。


jaa*_*apz 5

我自己使用了一些非常详细的业力报告器,我也必须滚动终端才能找到我的错误。这让我很恼火,所以我写了一个记者,只报告失败的测试。它与“karma-spec-reporter”结合使用效果很好。

https://github.com/jaapz/karma-failed-reporter