Description
cypress-testing-library
version: 2.3.3node
version: 8.12npm
(oryarn
) version: 6.4.1
Relevant code or config
// I tried two ways to do this, both don't work
// cy.wait(100) // if I uncomment this, it will work
cy.getAllByText("hello").should('have.length.gte', 6)
cy.getAllByText("hello").should(($elements) => {
expect($elements.length).to.be.gte(6)
})
What you did:
Run the above commands in an e2e test for an app (scenario for loading).
- the tested app first render nothing
- then it loads a few "hello" texts, but doesn't have as many as 6
- then it loads more than 6 "hello" texts
What happened:
the test fails
Reproduction repository:
I don't yet have one, will try to create when I have time.
Problem description:
getAllByText
seems to first match 1 DOM, then it assumes getAllByText
has already succeeded. When further should
commands fail, cypress only retries those should commands, but not getAllByText
. Therefore, although I verified that my DOMs have loaded before timeout, getAllByText
is run only once and doesn't try to get them again.
Suggested solution:
I am not sure if this is a problem with cypress-testing-library or cypress itself. My only clue is that commands like get
in cypress work with retry, so I assume it's a problem with this library. However, I couldn't find any information on cypress doc about this retry
behavior, so I cannot really tell. I'd like some feedback.