Cypress · Junior · Question 20 of 75
How do you check a list has exactly 3 items?
- 1
cy.get('li').count(3) - 2
cy.get('li').length.should.equal(3) - 3
cy.get('li').should('have.length', 3)
Show the answer
Correct answer: cy.get('li').should('have.length', 3)
Explanation
have.length retries until the count matches, so it works for lists that render gradually.