cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.07k stars 3.19k forks source link

Multiple queries are not retried #30453

Open NormalCrazy000 opened 3 weeks ago

NormalCrazy000 commented 3 weeks ago

Current behavior

For example if I try to do:

  cy.get('#tableId').contains('td','example').should('have.length', 1)

In case there is a slow loading of data in the table, the “get” is not retried and only “contains” is retried on the same old table object. It seems that when using multiple queries (e.g., 2), only the one next to the “should” is retried and not all the other previous ones as well

Desired behavior

I would like all queris before "should" be retested. I would like this in order to better manage DOM updates.

Test code to reproduce

From cypress official documentation:

https://docs.cypress.io/app/core-concepts/retry-ability#:~:text=The%20test%20still%20passes!%20cy.get(%27.todo%2Dlist%27)%20passes%20immediately%20%2D%20the%20todo%2Dlist%20exists%20%2D%20but%20.should(%27have.length%27%2C%201)%20shows%20the%20spinning%20indicator%2C%20meaning%20Cypress%20is%20still%20waiting%20for%20the%20assertion%20to%20pass.

From the example in the documentation, we see that retry is performed only for the “find,” but this would not work if the element acquired from the “get” was also re-rendered and thus changed

Cypress Version

13.13.3

Node version

20.17.0

Operating System

Window

Debug Logs

No response

Other

No response

jennifer-shehane commented 3 weeks ago

@NormalCrazy000 Could you provide a full example we can run and see the issue?