Here is a failed test:
describe("Checking errors", function () { var scope = {}; beforeEach(function () { browser.get("/#endpoint"); browser.waitForAngular(); scope.page = new MyPage(); }); it("should not show any errors", function () { expect(scope.page.errors).toBeEmptyArray(); }); });
where MyPage is the page object:
var MyPage = function () { this.errors = element.all(by.css("div.error-block b.error")) .filter(function (elm) { return elm.isDisplayed().then(function (value) { return value; }); }) .map(function (elm) { return elm.getText(); }); }; module.exports = MyPage;
where errors should be an array of visible error texts found on the page.
Here is the error we get:
Failures: 1) Checking errors should not show any errors Message: Expected [ ] to be empty array. Stacktrace: Error: Failed expectation
FYI, toBeEmptyArray() counter comes from third-party jasmine-matchers .
I tried to print the value of scope.page.errors as follows:
scope.page.errors.then(function (errors) { console.log(errors); });
And printed as [] . Array.isArray(errors) returns true .
From what I see, scope.page.errors is an empty array, but the wait fails. What am I missing?
source share