I am using Protractor with CucumberJS and chai-as-promised (given that CucumberJS does not have a built-in assertions library) to build an automated test suite.
Everything works fine for single assertions (using the expect feature of chai-as-promised). I run into trouble, however, when attempting to handle multiple promises within the same test (step). In the following example, verifyUserFirstName returns a promise mapped to a certain row's td.getText().
this.Then(/^I should see my user entry with proper values in the list$/, function (callback) {
expect(usersPage.verifyUserFirstName('tony@gmail.com')).to.eventually.equal('Tony');
expect(usersPage.verifyUserLastName('tony@gmail.com')).to.eventually.equal('Bui');
expect(usersPage.verifyUserPhone('tony@gmail.com')).to.eventually.equal('8764309111');
callback();
Currently, when any of the expect() lines fail, Protractor will exit and leave the browser window hanging without running the rest of the tests.
When a step featuring just a single expect() fails (see example below), everything works perfectly. It is logged as a failed step, and Protractor continues to run the rest of the tests to completion. Has anyone experienced this?
this.Then(/^I should be directed to the user list page$/, function (callback) {
expect(browser.getCurrentUrl()).to.eventually.equal('http://localhost:9001/#/nav/').and.notify(callback);
});
I had same challenge, this is how I solved:
I hope that helps!