Cypress · Junior · Question 54 of 75
How do you test a feature that depends on time, like a countdown?
- 1Wait for the real countdown to finish
- 2Change the CI machine's system clock
- 3Use
cy.clock()andcy.tick()
Show the answer
Correct answer: Use cy.clock() and cy.tick()
Explanation
cy.clock() replaces timers and Date, and cy.tick(ms) moves time forward instantly.