Skip to content

getAllBy* commands chained by should don't retry correctly #23

Closed
@Bobgy

Description

@Bobgy
  • cypress-testing-library version: 2.3.3
  • node version: 8.12
  • npm (or yarn) 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).

  1. the tested app first render nothing
  2. then it loads a few "hello" texts, but doesn't have as many as 6
  3. then it loads more than 6 "hello" texts

What happened:
the test fails

example

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions