If you ever want to click the v-date-picker
, but you don’t want the time to change between tests,
here’s a fix for you.
Prerequisites
- A project with Cypress installed
Approach
According to the Cypress documentation
clock
overrides time, however, the documentation is rather hard to understand. So what if you want to freeze
time, for example, if you want to click the v-date-time-picker
?
Well it’s quite simple in the end actually. It looks exactly like this:
beforeEach('Render page', () => {
cy.clock(new Date(2023-2-14).getTime(), ['Date'])
})
Now, each time that the test runs, it will set the browser datetime to that date.