Reputation: 83
I have written protractor tests with a format similar to below where I map an assertion over an list of elements (In this case an ElementArrayFinder).
it("all dropdowns should be enabled", done => {
....
elemArrayFinder.map((elem, idx) => {
expect(elemArrayFinder.get(idx).isEnabled()).toBeTruthy();
done();
})
});
My question is around the calling of done() - It appears this is called on the first assertion, instead of after all the assertions have been completed. Does this mean Jasmine/Protractor will move to the next test even though assertions continue to be made on the list of elements? Is there a way to call done() only when all assertions on the list items complete?
Upvotes: 1
Views: 259
Reputation: 3731
Because map
is a loop, given your code, done()
should be called on the first loop. You should be able to just omit the done()
and it should work. That said, to answer your question, you'd do something like this (though please don't do this :) ):
it("all dropdowns should be enabled", done => {
....
elemArrayFinder.map((elem, idx) => {
expect(elemArrayFinder.get(idx).isEnabled()).toBeTruthy();
}).then(done);
});
Upvotes: 3