Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot override cy.clock a second time #29298

Open
Lehren opened this issue Apr 10, 2024 · 0 comments
Open

Cannot override cy.clock a second time #29298

Lehren opened this issue Apr 10, 2024 · 0 comments
Labels
stage: needs investigating Someone from Cypress needs to look at this

Comments

@Lehren
Copy link

Lehren commented Apr 10, 2024

Current behavior

If I mock the current date with cy.clock(), and then I call it again later in my test, the current date will not be changed and new invocations of new Date() will return my old mocked date.

Additionally, the second cy.clock call is not even shown in the log

Desired behavior

Something like this should work:

cy.clock(Date.UTC(2021, 2, 31);
cy.visit(....);
....

cy.clock(Date.UTC(2021, 4, 20);
cy.reload();
...

Test code to reproduce

https://github.com/Lehren/cypress-test-tiny

Cypress Version

13.7.2

Node version

v16.20.2

Operating System

macOS 14.3.1

Debug Logs

No response

Other

Cypress test:
Screenshot 2024-04-10 at 16 05 23

Cypress testlog :
Note, no second clock call

Screenshot 2024-04-10 at 16 04 45

@jennifer-shehane jennifer-shehane added the stage: needs investigating Someone from Cypress needs to look at this label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs investigating Someone from Cypress needs to look at this
Projects
None yet
Development

No branches or pull requests

2 participants