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

CustomConsole: print console.error and console.assert to stderr #8261

Merged
merged 7 commits into from
Apr 3, 2019

Conversation

rubennorte
Copy link
Contributor

@rubennorte rubennorte commented Apr 3, 2019

Summary

When using the CLI in jest-runtime, console.error, console.warn and console.assert print to stdout, which is wrong. CustomConsole should print to the given stderr when calling those methods.

Test plan

Added unit tests in CustomConsole.

@rubennorte rubennorte force-pushed the custom-console-error branch 2 times, most recently from 631e8ea to 6203ed6 Compare April 3, 2019 02:19
Copy link
Contributor

@scotthovestadt scotthovestadt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests failing but code LGTM.

One thing I noticed here is that we're logging to stderr even when --useStderr is not set. We should probably fix that at some point.

@rubennorte
Copy link
Contributor Author

@scotthovestadt yeah, we need to fix how we use stdio. #8091 aims to fix part of that

@rubennorte
Copy link
Contributor Author

I made a change so this only applies to jest-runtime CLI.

expect(_stdout).toMatch('AssertionError');
expect(_stdout).toMatch('false == true');
expect(_stderr).toMatch('AssertionError');
expect(_stderr).toMatch('The expression evaluated to a falsy value:');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node 11 tries to be smart printing the line that threw the error but it doesn't work well.

@rubennorte rubennorte force-pushed the custom-console-error branch from 7a8ef47 to 5d0f9f2 Compare April 3, 2019 04:32
@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants