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 job do not exit on fail (Gitlab CI) #5845

Closed
AlexLo33 opened this issue Dec 2, 2019 · 5 comments
Closed

Cypress job do not exit on fail (Gitlab CI) #5845

AlexLo33 opened this issue Dec 2, 2019 · 5 comments

Comments

@AlexLo33
Copy link

AlexLo33 commented Dec 2, 2019

Hi everyone ! I don't know if it's a Cypress bug or a Gitlab bug but i'm stuck with my pipeline...

Current behavior:

I run my tests in a job with Gitlab.

When all tests are OK (no fails), the job end correctly and the next job is launched

BUT

When one test fail, the job is still running altough the Cypress process is trying to exit with code 1

gitlab-ci.yml

tests_e2e:
  stage: tests_e2e 🖥️
  script:
    - yarn cy:test

package.json :

"cy:run": "DEBUG=cypress:* cypress run",
"cy:test": "wait-on -t 600000 http://localhost:9000 && yarn cy:run"

Desired behavior:

My job will "successfully" fail after a test fail

With Debug mode, when all tests passed :
success_tests_job_end

With debug mode when a test fail :
fail_tests_job_stuck

Steps to reproduce: (app code and test code)

  • Launch a Gitlab job with successfull tests
  • See the job pass
  • Retry with a failed test
  • See the job stuck

My test code :

Success :

it('Go to login page', () => {
    cy.visit('/signin');
    cy.get('input[name=login]').should('be.visible');
  });

Fail : (input with name login123 does not exist)

it('Go to login page', () => {
    cy.visit('/signin');
    cy.get('input[name=login123]').should('be.visible');
  });

Versions

Cypress 3.7.0

@AlexLo33
Copy link
Author

AlexLo33 commented Dec 2, 2019

FYI, Maybe i'm not the only one with this issue :
https://stackoverflow.com/questions/58880355/gitlab-ci-runner-hangs-after-cypress-tests

@jennifer-shehane
Copy link
Member

@AlexLo33 Can you try running the tests in CI passing --browser chrome? This will launch the tests within a Chrome browser detected on your machine. I'd like to narrow does if this is an issue isolated to the Electron browser.

Also, there is an issue with hanging in CI here that we're working to fix: #5475 It may be related, but I haven't seen this happen in the same way your describing - only when a test fails.

You may want to try downgrading to 3.4.1 regardless, see if this is an issue isolated to a recent release in the past 6 weeks.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Dec 3, 2019
@AlexLo33
Copy link
Author

AlexLo33 commented Dec 3, 2019

I already have tried to downgrade to v3.4.1, same issue...
I'll try with a Chrome :)

@AlexLo33
Copy link
Author

AlexLo33 commented Dec 3, 2019

I have found the issue, it was not with Cypress but with Gitlab...

For informations :

I started my server in background with /myapp/bin/start & (so with &) and at the end of my tests Gitlab didn't want to go to the next script because my application's process was still running...

So I had to, in the same script, launch my application, run my tests, save the exit code out by Cypress, kill my application and return the saved exit code.

And, it works!

This issue can be closed

@bahmutov
Copy link
Contributor

bahmutov commented Dec 3, 2019

@AlexLo33 we recommend using something like https://github.com/bahmutov/start-server-and-test to start and shutdown server after the tests complete, you can find a few examples in our https://on.cypress.io/ci guide as well

@bahmutov bahmutov closed this as completed Dec 3, 2019
@cypress-io cypress-io locked and limited conversation to collaborators Jan 2, 2020
@jennifer-shehane jennifer-shehane removed the stage: needs information Not enough info to reproduce the issue label Jul 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants