-
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
cypress.clock doesn't work with async await #19620
Comments
I believe you need to set By making this change in your test case, the test passed. describe('fetching products', () => {
it('should fetch products and use fake timers', () => {
+ cy.clock();
cy.visit('/');
- cy.clock();
cy.findByText('Fetch products').click();
cy.findByText('fetched').should('exist');
cy.findByText(/You pressed/).should('exist');
cy.tick(6000);
cy.findByText(/You pressed/).should('not.exist');
})
}) |
Thanks @mjhenkes ! This raises another issue (docs related) - For me, it wasn't clear from the documentation (I read it a few times before I opened this issue) that this is a viable solution to my problem because my Are you saying that as a requirement if so, I would put it under "rules" and not "behavior" If not, why does it work in this specific case then? Thanks again! |
Closing because of the inactivity. |
Current behavior
I have an Angular app which fetches data via ajax.
After the data is being received there is an element showing in the template, and then after a timeout of 5000ms it disappears.
I tried to uses
cy.clock
to speed things up usingcy.tick(6000)
but it hangs because the code that should run after the ajax request returns doesn't run.When I remove the cy.clock everything works good (although delayed).
Desired behavior
I want to be able to use
cy.clock
andcy.tick
with ajax calls in my E2E tests and speed things up.I believe we might need to add
tickAsync
option to cypress.Test code to reproduce
I've uploaded a repository that simulates the issue (instructions are in the README) -
https://github.com/shairez/cypress-clock-timeout-issue
Cypress Version
9.2.0
Other
I think it has to do with the fact it's async await related code.
I noticed sinon (which cy.clock is based on) has a
tickAsync
method, maybe that could be a good investigation routeThe text was updated successfully, but these errors were encountered: