How to modify protractor html screenshot reporter

2019-04-15 07:31发布

问题:

I have 3 'it' specs with 27 expects in the code. protractor-html-screenshot-reporter includes 'it' specs but not expect level results.

Please let me know, can i make any configuration changes to make it work.

Thanks, Arpit Jain

回答1:

protractor-html-screenshot-reporter works on the spec-level (it blocks).

According to the source code, it defines the reportSpecResults function which is called by jasmine when the reporting results for a spec run.



回答2:

The below code takes a screenshot on each Failed expect:

// takes screenshot on each failed expect
var originalAddMatcherResult = jasmine.Spec.prototype.addMatcherResult;
jasmine.Spec.prototype.addMatcherResult = function() {
++index;
if (!arguments[0].passed()) {
  screenshot(this.description, index);
}
return originalAddMatcherResult.apply(this, arguments);

};

Hope this helps!