Skip to content

Cannot override cy.clock a second timeΒ #29298

Open
@Lehren

Description

@Lehren

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.15.0

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions