-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
- NodeJS Console initialization fix #4157
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4157 +/- ##
=======================================
Coverage 60.55% 60.55%
=======================================
Files 196 196
Lines 6777 6777
Branches 6 6
=======================================
Hits 4104 4104
Misses 2670 2670
Partials 3 3
Continue to review full report at Codecov.
|
Can you go into more detail of what this issue is aimed at fixing, and also providing a test that this change fixes? I don't see right now how this PR makes sense, I'll need more context. Thank you. |
@cpojer Sure. I've referenced the original issue 3 days ago - Jest 20.0.0.4 swallows the console output from an app that is being tested. Here is one more issue about the same problem, and here is another one That is really frustrating problem reported by many users, but all those issues were just closed without any fixes. So I've proposed a fix that definitely solves it. A test that covers this update should prove that console.log calls from a tested app (not from the Jest itself) are really make output to stdout. To be honest - I don't know how to makes this test without running Jest inside of another process that logs all stdout calls from it. |
I wrote an infinite loop and jest doesn't output to console, but this should solve my issue as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this change. Looks like stubbing stdout in constructor is unnecessary here. And console.log
s et al. still call BufferedConsole.write
Alright, not so fast. Passing |
Well, @cpojer then I don't understand how it isn't wrong. When you are extending Console - the first parameter of super should be a stream that takes the output. And in our case this buffered stream should bring the output to the console after all. But since there is a BufferedConsole.write call that has nothing to do with stdout - all console calls just getting pushed into this._buffer and nothing else happens after that. So, basically, you are creating a Console, that is detached from stdout at all. |
The buffer gets sent back to the Jest parent process, which will print it when it prints the test result. |
Thank you for the explanation, --verbose key had solved my case. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
This is a fix for the problem when NodeJS is "swallowing" console output.
BufferedConsole is initializing Console module with constructor parameters that don't match with the expected ones.