Background:我使用Jasmine作为我的Protractor测试框架,我一直使用Jasmine spec reporter进行报告。昨天我稍微改变了我的jasmineNodeOpts
参数在我的量规conf.js包括print()
功能,即
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 120000,
includeStackTrace : true,
isVerbose : true,
print: function () {}
},
我添加了这个打印功能,因为我知道它会在每个报告之前删除.
。例如,我的测试报告通常返回:
. ✓ should display a profile question about IT loads
. ✓ checks the width of the progress bar
. ✓ selects an option from the radio buttons and updates the progress bar
现在这些导点被移除了。然而,现在我的最终报告也有细微的变化:
14 specs, 2 failures Finished in 45.473 seconds // this is the old, desired output
:
Executed 14 of 14 specs (2 FAILED) in 45 secs. // this is my current, undesired output
我想两全其美,从我的报告中删除.
,但保留以前的总体报告。
问题:我找不到关于jasmineNodeOpts
和/或print()
函数的详细文档。在jasmine-spec-reporter和量角器参考文件中提到了它,但是没有关于它如何工作的真正文档,只提供了非常弱的示例。
有没有人知道我在哪里可以了解更多关于这个print()
函数和/或如何改变我的最终测试输出?
对于这种情况我有一个解决方案。这是一种hack,对jasmine-spec-reporter - displaySummary逻辑做了一个小改动
用以下逻辑替换node_modules/jasmine-spec-reporter/src/spec-display.js
的summary(metrics)
方法
summary: function (metrics) {
this.log(metrics.executedSpecs + ' specs, ' + metrics.failedSpecs+ ' failures Finished in ' + metrics.duration);
if (metrics.random) {
this.log('Randomized with seed ' + metrics.seed + '.');
}
},
我刚刚检查过,它正在生成您期望的执行摘要
Spec started
- sample test
√ Dummy Test
√ Dummy Test2
√ Dummy Test3
3 specs, 0 failures
Finished in 27.544 seconds
3 specs,0 failures Finished in 28 secs