Hi there,
I have a problem with testing my app with Cypress/lolex clock.
For my e2e tests I want to set a specific date as today date with clock, so I can easily assume the output of my react-dates calendar.
However if I do that - the calendar doesn't render at all and there is no error in the console.
I've spent hours on debugging and looking for the problem, but haven't found any.
Could anybody give me a hint on what to do?
Everything works fine if I don't use the clock.
That sounds like a bug with clock then - moment is dependent on the only two date apis that provide the current time, Date.now and new Date, and any proper clock mocking should be working with it.
@davebream cypress allows you to pass a list of time related functions that clock should override - https://docs.cypress.io/api/commands/clock.html#Function-Names. React dates is attempting to animate into view but the animation is prevented by clock overriding timing functions.
cy.clock(2527372800000, [ 'Date' ]) fixed the issue for me
@stuart-williams Wow, you are right, everything works now! thanks!
@stuart-williams Thanks so much!
Most helpful comment
@davebream cypress allows you to pass a list of time related functions that clock should override - https://docs.cypress.io/api/commands/clock.html#Function-Names. React dates is attempting to animate into view but the animation is prevented by clock overriding timing functions.
cy.clock(2527372800000, [ 'Date' ])fixed the issue for me