I am using protractor to run my cucumber tests. Inside my test I have the following assertion:
label.getText().then(
function(labelText){
labelText = labelText.trim();
console.log('label text: ' + labelText);
chai.expect(labelText).to.equal(arg1);
callback();
},
function() {
callback.fail('Could not get page label text');
});
When the Assertion is correct there is no problem. However when my labelText is different from arg1 I would like to still keep running it but I don't know how to add the exception or a fail callback in that. At the moment my application just exits. I know that is because I am not using a fail callback (I would like to know where I should have it).
I am also not sure if I should put the callback(); where it is now.
I am looking for solutions online and all I can find are examples using Mocha. I am not using Mocha or Jasmine. I am just using Cucumber framework with protractor. Since Cucumberjs does not have an assertion library, I added chai-as-promised for that. Thanks!