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 does not log stderr from plugins #5765

Closed
flotwig opened this issue Nov 21, 2019 · 10 comments
Closed

cypress run does not log stderr from plugins #5765

flotwig opened this issue Nov 21, 2019 · 10 comments
Assignees

Comments

@flotwig
Copy link
Contributor

flotwig commented Nov 21, 2019

Current behavior:

Run this existing spec that has a plugin which logs to process.stderr:

npm run cypress:run -- --project ./packages/server/test/support/fixtures/projects/system-node
npm run cypress:open -- --project ./packages/server/test/support/fixtures/projects/system-node

module.exports = (onFn, config) => {
process.stderr.write('Plugin Loaded\n')
process.stderr.write(`Plugin Node version: ${process.versions.node}\n`)
process.stderr.write(`Plugin Electron version: ${process.versions.electron}\n`)
}

It will log in cypress open, but not cypress run.

Desired behavior:

The pluginsfile should log either way.

@flotwig
Copy link
Contributor Author

flotwig commented Nov 25, 2019

The culprit is that this code path will cause the onStderrData callback to always return falsey:

if (linuxWithDisplayEnv) {
_.extend(overrides, {
electronLogging: true,
onStderrData (str) {
// if we receive a broken pipe anywhere
// then we know that's why cypress exited early
if (util.isBrokenGtkDisplay(str)) {
brokenGtkDisplay = true
}
// we should attempt to always slurp up
// the stderr logs unless we've explicitly
// enabled the electron debug logging
if (!debugElectron.enabled) {
return false
}
},
})
}

I believe this was a mistake, as line 252 returns false, but there is no "default case" that returns true after that.

If you add "return true", once again, output will contain Electron debug information (#4255). But we can just filter that out or not set ELECTRON_ENABLE_LOGGING at any point.

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Nov 27, 2019
@santoshyadavdev
Copy link
Contributor

HI @jennifer-shehane ,
I would like to take this issue.

@flotwig
Copy link
Contributor Author

flotwig commented Dec 4, 2019

@santoshyadav198613 Feel free to pick this issue up, ping me if you have any questions. I think changing that onStderrData callback to return true will be a good starting point.

@santoshyadavdev
Copy link
Contributor

Hi @flotwig ,
Are we looking for this to be logged?
image

santoshyadavdev added a commit to santoshyadavdev/cypress that referenced this issue Dec 5, 2019
@cypress-bot cypress-bot bot added stage: work in progress and removed stage: ready for work The issue is reproducible and in scope labels Dec 5, 2019
santoshyadavdev added a commit to santoshyadavdev/cypress that referenced this issue Dec 5, 2019
santoshyadavdev added a commit to santoshyadavdev/cypress that referenced this issue Dec 5, 2019
santoshyadavdev added a commit to santoshyadavdev/cypress that referenced this issue Dec 5, 2019
@cypress-bot cypress-bot bot added stage: ready for work The issue is reproducible and in scope and removed stage: work in progress labels Dec 5, 2019
@cypress-bot cypress-bot bot added stage: work in progress and removed stage: ready for work The issue is reproducible and in scope labels Dec 5, 2019
@santoshyadavdev
Copy link
Contributor

Hi @flotwig ,
PR is open now.

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: work in progress stage: needs review The PR code is done & tested, needs review labels Dec 5, 2019
@flotwig
Copy link
Contributor Author

flotwig commented Dec 5, 2019

Hi @flotwig ,
Are we looking for this to be logged?
image

Yep, that's great!

@santoshyadavdev
Copy link
Contributor

Hi @flotwig,
Cool just need some help on Testing , mentioned the error which I am getting in PR.

santoshyadavdev added a commit to santoshyadavdev/cypress that referenced this issue Dec 5, 2019
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: work in progress stage: needs review The PR code is done & tested, needs review labels Dec 5, 2019
@justin335
Copy link

Nice

santoshyadavdev added a commit to santoshyadavdev/cypress that referenced this issue Dec 17, 2019
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Jan 13, 2020
@cypress-bot cypress-bot bot added stage: work in progress and removed stage: needs review The PR code is done & tested, needs review labels Jan 29, 2020
santoshyadavdev added a commit to santoshyadavdev/cypress that referenced this issue Feb 19, 2020
santoshyadavdev added a commit to santoshyadavdev/cypress that referenced this issue Feb 19, 2020
santoshyadavdev added a commit to santoshyadavdev/cypress that referenced this issue Feb 19, 2020
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: work in progress stage: needs review The PR code is done & tested, needs review labels Feb 20, 2020
@cypress-bot cypress-bot bot added stage: ready for work The issue is reproducible and in scope and removed stage: work in progress labels Mar 17, 2020
@purejgleason
Copy link

Also seems to not log std err in tests

@jennifer-shehane
Copy link
Member

This now works. I'm not sure which version this was released in. Closing as resolved.

@purejgleason console.logs or stderr within a test file is exectued within the browser - so will not log to stdout. Use cy.task to log any info within a test to stdout as shown here: https://on.cypress.io/api/commands/task#Usage

@jennifer-shehane jennifer-shehane removed the stage: ready for work The issue is reproducible and in scope label Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
@flotwig @jennifer-shehane @santoshyadavdev @justin335 @purejgleason and others