Reputation: 1000
I came across this answer in a SO question:
'AFAIK expect waits internally for the related promises.'
Does anyone know if this is correct? I've searched the protractor documentation for an answer with no luck. Can anyone point out the correct place in the documentation where it say this?
If it is correct, it would save me a lot of work! We have over two hundred tests, and to prevent timeouts I am converting all these types of calls:
expect(parentDialog.getAttribute('class')).toContain('k-window-maximized');
to this:
parentDialog.getAttribute('class').then(function(cls) {
expect(cls).toContain('k-window-maximized');
});
Upvotes: 2
Views: 40
Reputation: 474281
This is definitely true. expect()
is "patched" by jasminewd
/jasminewd2
(used by protractor
internally) to implicitly resolve promises. Quote from the README:
Enhances
expect
so that it automatically unwraps promises before performing the assertion.
Here is an another documentation reference:
In other words, unless you need a real resolved value for further actions or calculations, you can safely pass a promise into expect()
:
expect(parentDialog.getAttribute('class')).toContain('k-window-maximized');
Upvotes: 3