Reputation: 23597
I have the following assertion...
promise.then(function() {
assert.ok(browser.query(addForm), "It should have the add form");
callback();
})
But when I try to see it go red, instead I get...
Possibly unhandled AssertionError: It should have the add form
and the test suite just fails to go any farther
Upvotes: 1
Views: 131
Reputation: 2384
Cucumber.js seems to have issues if anything is thrown within functions. I'm not sure which assertion framework your using, but I ran into a similar issue using Chai expects inside of a callback that I passed to then()
. I worked around the issue by pulling the expect outside of the callback as shown here.
Edit, including code from link:
For instance, if you were using Chai and your code looked like this:
element(by.tagName('body')).getText().then(function (text) {
text = doSomethingSpecial(text);
expect(text).to.equal('something');
});
You could modify your code using a library that understood promises (such as chai-as-promised in this case) so that it would look like:
var text = element(by.tagName('body')).getText().then(function (text) {
return doSomethingSpecial(text);
});
expect(text).to.eventually.equal('something');
Upvotes: 1