DEV Community

Discussion on: How to wait for a request to finish before moving on with Cypress

Collapse
 
shanim profile image
Mandy •

Whenever I use cy. wait with cy.intercept I receive the following error. Do you know any workarounds?
ERROR:
Timed out retrying after 5000ms: cy.wait() timed out waiting 5000ms for the 1st request to the route: file. No request ever occurred.

Code:
cy.intercept('POST','**/file',cvUploadResponse).as('file');

cy.wait('@file');

Collapse
 
walmyrlimaesilv profile image
Walmyr •

It seems that requests are taking more than Cypress's defaults for such a thing. A way to work around it would be to overwrite the requestTimeout.
I recommend reading the official docs for timeouts docs.cypress.io/guides/references/....

Collapse
 
nadaaskora profile image
Nada Ahmed •

I tried to make it 20 seconds but still not working

Thread Thread
 
walmyrlimaesilv profile image
Walmyr •

Where is it now working?
And what do you mean with trying to wait for 20 seconds?
Are you doing cy.wait(20000)?
If that's the case, I don't recommend doing it.
For more info, read docs.cypress.io/guides/references/....

Thread Thread
 
walmyrlimaesilv profile image
Walmyr •

Could you share the code, please?

Thread Thread
 
nadaaskora profile image
Nada Ahmed •

here is the code I'm using cypress 10, gql
I am trying to filter items and check for the url if contains the filtered query
Image description

I added the requestTimeout to check if this will work but it didn't
Image description

Thread Thread
 
walmyrlimaesilv profile image
Walmyr •

I see, but without having a chance to play with it, it would be difficult to help you out.
I hope you can find a solution for it, and when you do so, share it here.
Good luck!

Collapse
 
normanmunge profile image
normanmunge •

Have you tried to set the intercept before visiting the page?