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

mocha-jenkins-reporter changes how console.log works #75

Open
victorb opened this issue Dec 14, 2017 · 1 comment
Open

mocha-jenkins-reporter changes how console.log works #75

victorb opened this issue Dec 14, 2017 · 1 comment

Comments

@victorb
Copy link

victorb commented Dec 14, 2017

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:

console.log = function () {
log.apply(this, arguments);
test.logEntries.push(Array.prototype.slice.call(arguments));
};

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.

@srknzl
Copy link

srknzl commented Apr 28, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants