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

"cypress run" fails but "cypress open" works #6697

Closed
darthmeme opened this issue Mar 11, 2020 · 2 comments
Closed

"cypress run" fails but "cypress open" works #6697

darthmeme opened this issue Mar 11, 2020 · 2 comments

Comments

@darthmeme
Copy link

darthmeme commented Mar 11, 2020

Current behavior:

The issue here is with trying to get a label that contains some specific text.
cy.get('label').contains('Select 2')

When running cypress open locally and running my e2e tests, everything passes.

On the other hand, when running the same specs in CircleCI, it fails. I can reproduce this locally when running cypress run

Desired behavior:

cypress run should be passing

Test code to reproduce

https://github.com/darthmeme/cypress-test

In this example, I'm using Chrome.
After installing dependencies:

  • Start the app locally with yarn serve
  • In another terminal, run yarn cy:open (uses cypress open) and choose Chrome. Run all specs and they should all pass

Issue occurs here:

  • Run yarn cy:run (uses cypress run and automatically uses Chrome), and the specs will fail

Any insights or help will be greatly appreciated!

Versions

Cypress: 3.8.3 (also reproduced on 4.1.0
OS: macOS Catalina
Browser: Chrome

@jennifer-shehane
Copy link
Member

Thank you for providing a reproducible example! I can recreate this. I went back to Cypress 3.4.1 to see if this still reproduces - it's still the same error there.

Seems to not be finding the labels during cypress run.

cypress open in Chrome

Screen Shot 2020-03-11 at 3 33 54 PM

cypress run in Chrome

Screen Shot 2020-03-11 at 3 34 24 PM

I was able to get this to work by using cy.contains('label', 'Select 2') instead of cy.get('label').contains('Select 2').

I think this may be a duplicate of this issue: #2640 and there just happens to be some variability in the runtime between cypress open and cypress run - where perhaps the label is rerendering, so is gone by the time the .contains() runs.

@cypress-bot cypress-bot bot added the stage: awaiting response Potential fix was proposed; awaiting response label Mar 11, 2020
@darthmeme
Copy link
Author

Hey @jennifer-shehane - your solution works for me too. Thanks a ton!

I'll close this issue for now and follow #2640 - thanks for your help 😄

@jennifer-shehane jennifer-shehane removed the stage: awaiting response Potential fix was proposed; awaiting response label Mar 16, 2020
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