-
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 wait is displaying nondeterministic behavior #2387
Comments
I am experiencing the same issue at maybe a 50/50 ratio and it's a real blocker to actually using cypress in our CI process. Because I have am contacting a graphql endpoint I've done the The first XHR in the screenshot is one that passes the test, but it's almost as though the XHR is returning before the waiting begins, or something. function waitForMutation() {
cy.wait("@graphql").then(({ request }) => {
// We might hit a polling graphql
if (!request.body.query.includes("mutation")) {
waitForMutation();
}
});
}
Cypress.Commands.add("waitForMutation", waitForMutation); Versions |
This is likely a duplicate of #2227, which contains a link to an repo with this behavior being demonstrated: |
Duplicate of #2227 |
Is this a Feature or Bug?
Bug
Current behavior:
I am calling
cy.wait('@alias')
and sometimes it fails to detect that the aliased API call has been triggered when it has actually been called. It will work about 80% of the time, but about 20% of the time my wait will timeout with a failure. I have seen this on several of my endpoints and have yet to determine if it is exclusive to second calls on aliased endpoints or not. Here is an example of a situation where a failure occurred.I have an alias called
@plans
. In the below screenshot, you can see a wait called on line 11 and it successfully finds the method. If you look at the bottom of the screenshot you will see another wait for plans. This one however ended up failing despite the XHR call to plans. My page is also updated properly from a successful plans call.Here is a trimmed down version of my test with the alias:
Here is a screenshot when things go as planned:
This may or may not be useful, but I tend to see this issue on back to back API calls. For example, in the case above an edit call is made before the plans call. When I've tried waiting for both calls to occur (which would be my preferred state) the error happens more frequently. I see the issue when the runner seems to make calls extra fast. Not scientific at all, but maybe something to go off of. My hunch here is that the wait does not start listening until after the API call has been successfully made.
Desired behavior:
I would expect
cy.wait('@alias')
to perform consistently and to not timeout when my API call has been made.Steps to reproduce:
Repo: https://github.com/allisondhall/cypress-test-tiny - I haven't been able to get an isolated reproduction but here is the repo I'm working on it in.
General:
cy.wait()
for each oneVersions
Cypress: 3.1.0; MacOS High Sierra 10.13.5; Electron 59
The text was updated successfully, but these errors were encountered: