-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
Current behavior:
When I chaining an invoke() and its() call, the behavior is different from what I expect here. It seems to me that the method specified in the invoke's parameter is not called anymore, just once and only its() is doing the retry.
With pseudo-code:
result = item.<invoke_method>()
waitUntil(result.<its_attribute> meets the assumption)
{}
Desired behavior:
My expectation is that if I use invoke() and its() in the same chain, then the framework should retry the whole chain. Invoke the method again and again, and check it's attribute again and again.
With pseudo-code:
result = item.<invoke_method>()
waitUntil(result.<its_attribute> meets the assumption)
{ result = item.<invoke_method>() }
Test code to reproduce
I modified the example code from the invoke() method documentation page:
https://docs.cypress.io/api/commands/invoke.html#Retries
it('Invoke+its test', function() {
let message = 'hello';
const english = {
greeting () {
return {'message' : message};
}
};
setTimeout(() => {
message = 'bye';
}, 2000);
// With this wait() the test passes
// cy.wait(2100);
cy.wrap(english)
.invoke('greeting')
.its('message')
.should('be.equal', 'bye');
});This test code fails for me with 'expected 'hello' to equal 'bye'' message. However if I add a cy.wait() in the test code (see the commented out line), then the test passes, which means the assumption is met after some time. I think the test should pass without that wait() too.
Versions
Cypress 4.3.0
OpenSUSE 15.1