Skip to content
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

Using cy.route2, unable to find alias when running in CI (Github actions) #8984

Closed
ChrisSargent opened this issue Oct 27, 2020 · 5 comments
Closed

Comments

@ChrisSargent
Copy link

ChrisSargent commented Oct 27, 2020

Current behavior

I have some tests that are passing using open and when using run on my local machine, but which are failing in a Github action. Error is CypressError: cy.wait() could not find a registered alias for: ....

Screenshot 2020-10-27 at 10 59 06

Desired behavior

The aliased routes in the beforeEach should be available (note they are correctly available in previous and later tests)

Test code to reproduce

Minimal setup is here: https://github.com/ChrisSargent/cypress-test-tiny.

Versions

Cypress 5.5.0

@ChrisSargent
Copy link
Author

ChrisSargent commented Oct 27, 2020

Actually, I now have this happening in my local machine so at least I can start troubleshooting a little bit easier. Moving the route2 call to a test specific beforeEach instead of a beforeEach in the commands.js file seemed to get passed this error, but then I started getting undefined for the request - I have a feeling this is something to do with network requests being cancelled from the previous test, because if I skip the previous tests or just stick in a cy.wait(1000) at the end, the following tests pass okay (and I mean previous test in a different describe block)

@ChrisSargent
Copy link
Author

Screenshot 2020-10-27 at 13 15 17

Okay, now running locally in Electron but with the --headed option, I can see I get a Cypress error as above:

> Cannot access 'continueSent' before initialization

Seems that it would be related to this: #8926, just strange that it works fine when using cypress open vs run

@ChrisSargent
Copy link
Author

Sorry for the running commentary, but... okay, I moved all my route2 setup out of the beforeEach in to a setupRoutes function that I call at the beginning of each test, before cy.visit. I still get the same error which results in the request being undefined in the subsequent wait. Seems rather flaky because sometimes it's working, sometimes it's not. Works less often when the tests are running headlessly.

@ChrisSargent
Copy link
Author

ChrisSargent commented Oct 27, 2020

Adding cy.wait(1000); to my previous test to get passed this for now and waiting for this fix before investigating further: #8978

@jennifer-shehane
Copy link
Member

I think you're running into this issue - which is a timing issue, so it makes sense that it may only happen during cypress run - since there could be some variability in the way it runs in Electron versus Chrome or on your GitHub action versus locally.

Duplicate of #8926

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants