Showing posts from 2016

Protractor: Data driven testing

We can iterate jasmine "it" blocks with custom data easily by passing  some array or some other external objects as follows:

var testParams = testConfig.testArray; { it('write your test here', function() { //test code here }); });
Here we are using javascript map function without using any foreach loops as map function internally iterates over the passed array values the given "it"  block.

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);