Showing posts from October, 2016

How to write custom failure messages for expect in Protractor/Jasmine reports

In Protractor ,We can override the error messaging in the Jasmine reporter by defining the custom matcher in the global scope and overrding the default message variable as follows:

beforeEach(function () { jasmine.addMatchers({ toReport: function () { return { compare: function (actual, expected, msg) { var result = {pass: actual == expected}; result.message = msg; return result; } } } }); });And it can be used in expect statements like below inside err function block:expect(false).toReport(true, "Unable to perform required operation because of " + err.message);