Testing · Senior · Question 55 of 75
Why does this custom check not retry, and how do you fix it?
cy.get(".total").then(($el) => {
expect(parseFloat($el.text())).to.be.greaterThan(100);
});- ✓Correct answer:
.thenruns once; use.should(($el) => { ... })- a callback assertion is retried together with the query - 2
expectdoesn't work in Cypress - 3
parseFloatbreaks retry-ability
Explanation
The .should callback must be free of side effects, since it may run many times.