How to set current time to future time by using Cypress?

I am using cypress to automate countdown content block, I need to test recurrence scenarios by using Cypress. In Example,

At the Start – Days – 00 | Hrs – 00 | Mins – 00

I need to validate, after one hour, count down will be started (Days – 23 | Hrs – 59 | Mins – 59)

I cannot use hard coded waittimes, so I try the following cypress script by I wont work.

const now = new Date().getTime()
cy.clock(now)
cy.tick(3600000)

Anything worng in this? Or help me to find a good solution.

Source: Ask Javascript Questions

LEAVE A COMMENT