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);
});
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.

Further reading

Problem with a question

Cypress · Middle · question 4

Test yourself

Take the Cypress · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz