How to modify protractor html screenshot reporter to show report for each “expect” (assertion ) instead of each “it” block in spec file

坚强是说给别人听的谎言 提交于 2019-12-22 01:29:40

问题


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!



来源:https://stackoverflow.com/questions/27383277/how-to-modify-protractor-html-screenshot-reporter-to-show-report-for-each-expec

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