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

Failed cy.exec should log full error #5470

Open
mxstbr opened this issue Oct 25, 2019 · 7 comments
Open

Failed cy.exec should log full error #5470

mxstbr opened this issue Oct 25, 2019 · 7 comments
Labels
cli existing workaround prevent-stale mark an issue so it is ignored by stale[bot] stage: needs investigating Someone from Cypress needs to look at this topic: cli output type: user experience Improvements needed for UX

Comments

@mxstbr
Copy link

mxstbr commented Oct 25, 2019

Current behavior:

When calling a command that fails with cy.exec, the stderr output is truncated:

CypressError: cy.exec('script/setup') failed because the command exited with a non-zero code.
Stderr:
go: finding github.com/package1 v2.3.1
go: finding github.com/package2 v0.0.3
go: finding github.com/package3 v0.0.0
go: finding g...
      at Object.cypressErr (http://localhost:3001/__cypress/runner/cypress_runner.js:85348:11)
      at Object.throwErr (http://localhost:3001/__cypress/runner/cypress_runner.js:85303:18)
      at Object.throwErrByPath (http://localhost:3001/__cypress/runner/cypress_runner.js:85335:17)
      at http://localhost:3001/__cypress/runner/cypress_runner.js:72714:23
      at tryCatcher (http://localhost:3001/__cypress/runner/cypress_runner.js:118962:23)
      at Promise._settlePromiseFromHandler (http://localhost:3001/__cypress/runner/cypress_runner.js:116898:31)
      at Promise._settlePromise (http://localhost:3001/__cypress/runner/cypress_runner.js:116955:18)
      at Promise._settlePromise0 (http://localhost:3001/__cypress/runner/cypress_runner.js:117000:10)
      at Promise._settlePromises (http://localhost:3001/__cypress/runner/cypress_runner.js:117079:18)
      at Async../node_modules/bluebird/js/release/async.js.Async._drainQueue (http://localhost:3001/__cypress/runner/cypress_runner.js:113687:16)
      at Async../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:3001/__cypress/runner/cypress_runner.js:113697:10)
      at Async.drainQueues (http://localhost:3001/__cypress/runner/cypress_runner.js:113571:14)
      at <anonymous>

Desired behavior:

Cypress should log the full stderr output to allow debugging of the issue:

CypressError: cy.exec('script/setup') failed because the command exited with a non-zero code.
Stderr:
go: finding github.com/package1 v2.3.1
go: finding github.com/package2 v0.0.3
go: finding github.com/package3 v0.0.0
go: finding golang.org/x/net v0.0.0-20190613194153-d28f0bde5980
go: github.com/[email protected]: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /home/runner/go/pkg/mod/cache/vcs/075ee809aae0177b65597ee0f28e756d8e2e5e438325d9b042470844e74f817e: exit status 128:
	fatal: could not read Username for 'https://github.com': terminal prompts disabled

Steps to reproduce: (app code and test code)

Call cy.exec with a command that fails with a long error (e.g. stack trace).

Versions

Cypress 3.4.1

@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Oct 28, 2019
@jennifer-shehane jennifer-shehane added cli type: user experience Improvements needed for UX labels Oct 28, 2019
@Leksat
Copy link

Leksat commented Dec 30, 2019

Example code:

cy.exec('(yes "Very long output" | head -n 100) && false')

@Leksat
Copy link

Leksat commented Dec 30, 2019

Workaround:

const exec = command => {
  cy.exec(command, { failOnNonZeroExit: false }).then(result => {
    if (result.code) {
      throw new Error(`Execution of "${command}" failed
      Exit code: ${result.code}
      Stdout:\n${result.stdout}
      Stderr:\n${result.stderr}`);
    }
  })
}
exec('(yes "Very long output" | head -n 100) && false')

@B-Galati
Copy link

Thanks for this workaround that works like a charm.

@bodinsamuel
Copy link

+1 on this

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label May 17, 2023
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2023
@dokterbob
Copy link

Here's some activity. Still relevant!

@jennifer-shehane jennifer-shehane added prevent-stale mark an issue so it is ignored by stale[bot] and removed stale no activity on this issue for a long period labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli existing workaround prevent-stale mark an issue so it is ignored by stale[bot] stage: needs investigating Someone from Cypress needs to look at this topic: cli output type: user experience Improvements needed for UX
Projects
None yet
Development

No branches or pull requests

8 participants