JasmineNodeOpts - 打印量角器测试结果

Gun*_*son 5 jasmine protractor

背景:我使用 Jasmine 作为 Protractor 的测试框架,我一直在使用jasmine 规范报告器进行报告。昨天,我稍微更改了jasmineNodeOpts量角器 conf.js 中的参数以包括print()函数 ie

\n\n
jasmineNodeOpts: {\n    showColors: true,\n    defaultTimeoutInterval: 120000,\n    includeStackTrace : true,\n    isVerbose : true,\n    print: function () {}\n},\n
Run Code Online (Sandbox Code Playgroud)\n\n

我添加了这个打印功能,因为我了解到它会删除.每个报告之前的内容。例如,我的测试报告曾经返回:

\n\n
.    \xe2\x9c\x93 should display a profile question about IT loads\n.    \xe2\x9c\x93 checks the width of the progress bar\n.    \xe2\x9c\x93 selects an option from the radio buttons and updates the progress bar\n
Run Code Online (Sandbox Code Playgroud)\n\n

现在那些前导点被删除了。然而,现在我的最终报告也略有变化:

\n\n
14 specs, 2 failures Finished in 45.473 seconds // this is the old, desired output\n
Run Code Online (Sandbox Code Playgroud)\n\n

对此:

\n\n
Executed 14 of 14 specs (2 FAILED) in 45 secs. // this is my current, undesired output\n
Run Code Online (Sandbox Code Playgroud)\n\n

我想要两全其美,拥有.从我的报告中删除这些内容,但保留之前的总体报告。

\n\n

问题:我找不到有关和/或该功能的详细文档。它在jasmine-spec-reporter量角器参考conf中提到jasmineNodeOptsprint(),但没有关于它如何工作的真正文档,只提供了非常弱的示例。

\n\n

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

\n

Adi*_*ddy 2

对于这种情况,我有一个解决方案。这是一种 hack,是jasmine-spec-reporter - displaySummary逻辑的一个小变化

\n\n

将方法 -at 替换summary(metrics)node_modules/jasmine-spec-reporter/src/spec-display.js以下逻辑

\n\n
summary: function (metrics) {\n\n    this.log(metrics.executedSpecs + \' specs, \' +  metrics.failedSpecs+ \' failures Finished in \' + metrics.duration);\n    if (metrics.random) {\n      this.log(\'Randomized with seed \' + metrics.seed + \'.\');\n    }\n  },\n
Run Code Online (Sandbox Code Playgroud)\n\n

我刚刚检查过,它生成了您所期望的执行摘要

\n\n
Spec started\n\n   - sample test\n    \xe2\x88\x9a Dummy Test\n    \xe2\x88\x9a Dummy Test2\n    \xe2\x88\x9a Dummy Test3\n\n\n3 specs, 0 failures\nFinished in 27.544 seconds\n\n  3 specs,0 failures Finished in 28 secs\n
Run Code Online (Sandbox Code Playgroud)\n