mocha-jenkins-reporter icon indicating copy to clipboard operation
mocha-jenkins-reporter copied to clipboard

mocha-jenkins-reporter changes how console.log works

Open victorb opened this issue 7 years ago • 1 comments

We have a test which checks a linting command. To avoid output to be printed to the console during the test case, we use sinon.stub (https://github.com/ipfs/aegir/blob/d57dd3f59fc752a44aa462c767565977dc18f047/test/lint.spec.js#L8-L13).

However, this doesn't work very nicely with mocha-jenkins-reporter as it also overloads the console.log function, to save the logging output. But after the test finishes, and mocha-jenkins-reporter is supposed to write the results, it fails due to console.log not having added the log rows during this test run. Implementation of this is here: https://github.com/juhovh/mocha-jenkins-reporter/blob/d2da9ad26a0592083eb7969e06fc26831bab8d57/lib/jenkins.js#L323-L326

Instead, it would be better for mocha-jenkins-reporter to listen to process.stdout so nothing have to be overloaded but still be able to capture debugging output.

victorb avatar Dec 14 '17 14:12 victorb

this same thing causes a test fail if console.log is stubbed and console.log.restore() is called later on. To fix this I assigned spy to a variable then use restore() on it

srknzl avatar Apr 28 '21 11:04 srknzl