-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Expose shouldAdvanceTime
option from @sinonjs/fake-timers
#27744
Comments
Hi @Yihao-G can you describe your use case in a bit more detail? |
Hi @nagash77 I updated the issue. |
We would like to have the same option. We have a very large React application and we found that the application does not load at all as soon as we do cy.clock();
navigate(path);
// In order to load the app with a stopped clock, we need to tick and wait multiple times.
// There seems to be a strong correlation between ticking and waiting, so we use them together.
// Potentially, issue caused due to webpack serving chunks of JS in small bundles,
// or by React, due to how we trigger the loading of lazy components, over time.
cy.tick(1000);
cy.wait(1000);
cy.tick(1000);
cy.wait(1000);
cy.tick(1000);
cy.wait(1000); The above allows the app to load. In the Developer Tools -> Network tab, we can see how after every Additionally, in order to evaluate the UI of the application, we need to do the following: cy.clock().invoke('restore');
cy.get('element').should('be.visible'); If we don't restore the clock, it seems like React doesn't re-render and therefore we can not make proper assertions on the UI. Re-rendering also works fine if we We believe that if we could mock the Our requirement for the |
What would you like?
I would like to set
shouldAdvanceTime
to true when callingcy.clock()
so the time automatically flows rather than stopped/frozen.Why is this needed?
I have a page that will only do something after a set time, but before that, the page also has some other components that rely on the elapse of time (because of the use of
setTimeout
/setInterval
). I don't want to callcy.tick
for a random duration because I want to test a specific behaviour that happens after the time I specified.Other
Related StackOverflow question and answer (and also shows some other use cases): https://stackoverflow.com/questions/75419850/how-to-set-initial-time-in-cypress-and-allow-time-to-flow
The text was updated successfully, but these errors were encountered: