summaryrefslogtreecommitdiff
path: root/test/parallel/test-common.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-common.js')
-rw-r--r--test/parallel/test-common.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/parallel/test-common.js b/test/parallel/test-common.js
index 7fee3e0b84..647c39d939 100644
--- a/test/parallel/test-common.js
+++ b/test/parallel/test-common.js
@@ -108,3 +108,26 @@ 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', 'error' ], [ 'out', 'log' ]].forEach(([ type, method ]) => {
+ common[`hijackStd${type}`](common.mustCall(function(data) {
+ assert.strictEqual(data, 'test\n');
+
+ // throw an error
+ throw new Error(`console ${type} error`);
+ }));
+
+ console[method]('test');
+ common[`restoreStd${type}`]();
+});
+
+let uncaughtTimes = 0;
+process.on('uncaughtException', common.mustCallAtLeast(function(e) {
+ assert.strictEqual(uncaughtTimes < 2, true);
+ assert.strictEqual(e instanceof Error, true);
+ assert.strictEqual(
+ e.message,
+ `console ${([ 'err', 'out' ])[uncaughtTimes++]} error`);
+}, 2));