cypress: `cypress ci` does not issue proper exit code in Codeship CI

I am having an issue when running tests in Codeship. The tests should exit with the number of failures, but instead it times out.

Error Message

--------------------------------------------------------------------------------
This command didn't output anything for 10 minutes, thus we stopped it.
Please make sure your steps regularly print to standard out or standard error.
If the error is on our end please inform us so we can help you to fix this.
--------------------------------------------------------------------------------

Screenshot screen shot 2016-12-06 at 11 18 27 am

Codeship’s support team input

I took a look at some of your builds and I’m wondering more about the cypress ci command. It looks like it finishes, but maybe isn’t giving an exit code? Codeship relies on scripts/commands providing a meaningful exit code to know when the command is done and also to then know to move on to the next command or if the build should be failed.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 3
  • Comments: 37 (21 by maintainers)

Commits related to this issue

Most upvoted comments

Also just wanted to say you are awesome @joesiewert as I don’t think we would have ever been able to figure this out, haha.

I was bit by this yesterday, and came up with a workaround script. It’s not a long-term solution, but I’m posting here because it could be useful to someone: https://gist.github.com/bgschiller/397ad1ca123aa15f331f3f3ec9717e5f

The workaround is:

  • Wrap Cypress with a script that watches its output
  • wait for all tests to finish, collect the failed tests count
  • kill cypress subprocess
  • then exit with an appropriate code (based on the failed test count)

I’m still seeing this hang on Codeship Basic without this workaround in place.

sed -i '/eval $(ssh-agent)/d' ~/.bash_profile
sed -i '/ssh-add -k/d' ~/.bash_profile
nvm install 10
npm ci
npm run cy:verify
npm start -- --silent &
npm run cy:run

Finally managed to track this down. It looks like ~/.bash_profile is getting sourced when cy.exec is called.

Taking a look at ~/.bash_profile on Codeship, eval $(ssh-agent) is getting called and is responsible for causing Cypress to hang.

There are probably a number of ways to workaround this, but I think the simplest thing is to just drop these commands from ~/.bash_profile before running Cypress:

sed -i '/eval $(ssh-agent)/d' ~/.bash_profile
sed -i '/ssh-add -k/d' ~/.bash_profile

Suggested doc updates here: https://github.com/cypress-io/cypress-documentation/pull/759

yeah, seems even a single unit test that uses cy.exec on Codeship basic, even something simple like the echo below is hanging.

cy.exec('echo Jane Lane')
   .its('stdout').should('contain', 'Jane Lane')