JasmineNodeOpts - 打印量角器测试结果

时间:2016-09-30 13:27:10

标签: jasmine protractor

背景:我使用Jasmine作为Protractor的测试框架,我一直在使用jasmine spec reporter进行报告。昨天我稍微改变了我的量角器conf.js中的jasmineNodeOpts参数,以包含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-reporterprotractor reference conf中提到了它,但没有关于它如何工作的真实文档,只提供了非常弱的例子。

有谁知道我可以在哪里了解有关此print()功能的更多信息和/或如何更改我的最终测试输出?

1 个答案:

答案 0 :(得分:1)

我对这个案子有一个解决方案。这是一种hack,jasmine-spec-reporter - displaySummary逻辑

中的一个小变化

使用以下逻辑

替换summary(metrics)处的node_modules/jasmine-spec-reporter/src/spec-display.js方法
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
相关问题