Cypress · Middle · Question 4 of 77
What does .should(callback) add compared with .then(callback)?
cy.get(".total").should(($el) => {
expect(parseFloat($el.text())).to.be.greaterThan(0);
});- 1The callback runs once, but with a longer timeout
- 2The callback is retried until its expectations pass
- 3The callback runs in Node instead of the browser
Show the answer
Correct answer: The callback is retried until its expectations pass
Explanation
Use .should() for checks that may need time. .then() runs once and is for working with a value.