-
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
Feature request: longer timeouts when network requests detected #6563
Comments
Hi @DamienCassou! The command timeout can also be set for an individual command by passing |
That is another workaround we have used indeed. But it requires having a random number in the middle of the code base and it isn't as powerful as |
Could you provide more detail about why you feel My thought with increasing the default timeout for |
My code above with Maybe your solution to increase the timeout of |
I would argue that using You will also receive a better error message. You will know:
Yes, if you intend to use this set of commands over and over, like a general 'waitForPageToLoad', we would recommend writing a custom command to hold all these commands within. Overall, you're likely looking for something along the lines of 'wait for network idle' feature outlined here: #1773 Duplicate of #1773 |
My server returns a mostly empty HTML page and then the client slowly populate the page by requesting more data through REST. I would like to write that kind of code:
The first line usually succeeds quite fast because the server doesn't have much to do. My problem is that the second line we often fail because
cy.contains()
only waits fordefaultCommandTimeout
even though there might be many requests aftercy.visit()
succeeds and before"some dynamic content"
appears on the page.I usually do something like this instead:
This works better because
cy.wait()
waits much longer thancy.contains()
before giving up. This gives plenty of time for"some dynamic content"
to appear. I don't like this solution though because the test becomes more complex (it has more lines to understand) and more fragile (it depends on the client making a request to/Data
).I could increase the value of
defaultCommandTimeout
but this doesn't feel like a good solution because not all calls tocy.contains()
should have a big timeout.Would it be possible to make Cypress wait longer when network requests are detected?
cy.wait()
is quite clever about how it waits: it timesout afterrequestTimeout
if no request were sent and afterresponseTimeout
if at least one was sent. Maybe there could be a way to configurecy.contains()
so it does something similar.The text was updated successfully, but these errors were encountered: