-
-
Notifications
You must be signed in to change notification settings - Fork 34.8k
test: fix hijackStdout behavior in console #14647
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,3 +108,23 @@ const HIJACK_TEST_ARRAY = [ 'foo\n', 'bar\n', 'baz\n' ]; | |
| common[`restoreStd${txt}`](); | ||
| assert.strictEqual(originalWrite, stream.write); | ||
| }); | ||
|
|
||
| // hijackStderr and hijackStdout again | ||
| // for console | ||
| [ 'err', 'out' ].forEach((txt) => { | ||
|
||
| common[`hijackStd${txt}`](common.mustCall(function(data) { | ||
| assert.strictEqual(data, 'test\n'); | ||
|
|
||
| // throw an error | ||
| throw new Error(`console ${txt} error`); | ||
| })); | ||
|
|
||
| console[txt === 'err' ? 'error' : 'log']('test'); | ||
| common[`restoreStd${txt}`](); | ||
| }); | ||
|
|
||
| let uncaughtTimes = 0; | ||
| process.on('uncaughtException', common.mustCallAtLeast(function(e) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CR: How is the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The second parameter of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I wasn't clear. I meant it should be |
||
| assert.strictEqual(e instanceof Error, true); | ||
| assert.strictEqual(e.message, `console ${([ 'err', 'out' ])[uncaughtTimes++]} error`); | ||
| }, 2)); | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
Nit: I know you like
functions but this could be a single line.IMHO the indentation is weird