JasmineNodeOpts - Printing Protractor Test Results

半腔热情 提交于 2020-01-23 08:06:07

问题


Background: I'm using Jasmine as my test framework for Protractor, I've been using jasmine spec reporter for reporting. Yesterday I slightly changed my jasmineNodeOpts parameters in my protractor conf.js to include the print() function i.e.

jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 120000,
    includeStackTrace : true,
    isVerbose : true,
    print: function () {}
},

I added this print function because I learned it would remove the . before each report. For example, my test reports used to come back:

.    ✓ 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

And now those leading dots are removed. However, now my final report has also slight changed from:

14 specs, 2 failures Finished in 45.473 seconds // this is the old, desired output

To this:

Executed 14 of 14 specs (2 FAILED) in 45 secs. // this is my current, undesired output

I want the best of both worlds, having the . removed from my report but retaining the previous overall report.

Problem: I cannot find detailed documentation on jasmineNodeOpts and/or that print() function. It is mentioned in jasmine-spec-reporter and the protractor reference conf but there is no real documentation on how it works, only very weak examples are provided.

Does anyone know where I can learn more about this print() function and/or how to change my final test output?


回答1:


I have one solution for this case. This is kind of a hack, a small change in the jasmine-spec-reporter - displaySummary logic

Replace the method - summary(metrics) at node_modules/jasmine-spec-reporter/src/spec-display.js with the below logic

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 + '.');
    }
  },

I just checked and its generating the execution summary as you are expecting

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


来源:https://stackoverflow.com/questions/39792691/jasminenodeopts-printing-protractor-test-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!