When I am running my tests, about half the time Cypress does not see that the XHR requests I have told it to wait for have completed successfully. I can rerun the test many times and it works only about half the time.
Here is a screenshot of the test timing out because No response ever occurred, even though you can see in the Cypress logs that more than 4 graphl XHR calls successfully returned w/ a 200:
And I then re-ran the test, and got this.....same XHR calls, all successful, but this time the wait finished properly:
Desired behavior:
Consistent test behavior. It seems like maybe cy.wait(...) is not seeing that the XHR requests finish if they happen too fast?
Test code to reproduce
This can easily be reproduced if you don't mind creating a Udacity account.
Find your _jwt cookie, and paste that into the test where cypress sets a cookie
Run the tests repeatedly. Sometimes they pass, sometimes they don't.
Here is an overview of the code.
I have read through so many issues and as far as I can tell, from a code perspective I am doing things correctly. I am starting the server & setting up routes before using cypress.visit(). If I am setting this up incorrectly, please let me know.
describe('Our website', () => {
beforeEach(() => {
cy.setCookie('_jwt', '< add your JWT here >');
cy.server();
cy.route({
url: '**/graphql',
method: 'POST'
}).as('apiRoute');
});
it(`Has no accessibility violations`, () => {
cy.visit('https://classroom.udacity.com/me');
// Also try waiting for the requests one at a time - but neither seems to work
// cy.wait('@apiRoute');
// cy.wait('@apiRoute');
// cy.wait('@apiRoute');
// cy.wait('@apiRoute');
cy.wait(['@apiRoute', '@apiRoute', '@apiRoute', '@apiRoute']);
expect(true);
});
});
Versions
Cypress: 4.6.0
System: mac OS 10.14
Browser: Electron 80 (when headless) or Chrome 83 in the GUI
Current behavior:
When I am running my tests, about half the time Cypress does not see that the XHR requests I have told it to wait for have completed successfully. I can rerun the test many times and it works only about half the time.
Here is a screenshot of the test timing out because
No response ever occurred
, even though you can see in the Cypress logs that more than 4graphl
XHR calls successfully returned w/ a 200:And I then re-ran the test, and got this.....same XHR calls, all successful, but this time the
wait
finished properly:Desired behavior:
Consistent test behavior. It seems like maybe
cy.wait(...)
is not seeing that the XHR requests finish if they happen too fast?Test code to reproduce
This can easily be reproduced if you don't mind creating a Udacity account.
_jwt
cookie, and paste that into the test where cypress sets a cookieHere is an overview of the code.
I have read through so many issues and as far as I can tell, from a code perspective I am doing things correctly. I am starting the server & setting up routes before using
cypress.visit()
. If I am setting this up incorrectly, please let me know.Versions
Cypress: 4.6.0 System: mac OS 10.14 Browser: Electron 80 (when headless) or Chrome 83 in the GUI