-
-
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
safe --json && --listTests #4212
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4212 +/- ##
=========================================
Coverage ? 60.19%
=========================================
Files ? 191
Lines ? 6768
Branches ? 6
=========================================
Hits ? 4074
Misses ? 2691
Partials ? 3
Continue to review full report at Codecov.
|
I don't feel like this is the right way to go and it is using a huge bandaid to solve a real problem. I'm willing to bet the reason why it was impossible to locate where the stdout data came from is because that was inside a test file or other user code writing to stdout directly. How about in the environment where we clone the process object, we swap out |
I have mixed feelings with this PR: on one side, I agree with @cpojer that this does not look the best way to do it, and that we should really investigate the root cause of why On the other side, it's also true that While Jest takes care of buffering On the other (unrelated) side, I didn't know that |
@mjesun note that Jest doesn't wrap process.stdout within a test, which is what I suggest we should do. The wrapping you linked to wraps output during a test run, but will print the data at the end. |
why do you think it's a bad approach?
So even though in this PR we modify the global object, i strongly feel that it is a much better way to solve this problem than playing a whack-a-mole with with |
I would like to understand first the reasons why the current approach is breaking down concretely. As said, I think the biggest problem is test code and we can patch process.stdout for sandboxes.
All I'm saying is that this is the nuclear option that imho goes too far in one direction when we don't fully understand the source of the current problem and there are simpler fixes that we could try out first and changes to our process (hah!) that can mitigate this problem in the future. |
@aaronabramov Based on @cpojer's comment I'd strongly agree into looking at what is corrupting |
closing for now. we fixed it locally and will come up with a better strategy to fix it in the future |
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. |
we've had way too many bugs caused by accidentally
console.log
ging something together with JSON output, which, of course, would make this outputted JSON invalid.This PR solves the problem by completely replacing
process.stdout
withprocess.stderr
if we're in one of the "no random stdout" modes (--json
,--listTests
,--useStderr
).I had to hijack
process.stdout
, before we require a single module, because otherwise any console.log in insidenode_modules
, third party or plugin/reporter code can mess things up.cc @mjesun