diff --git a/test/parallel/test-console-write-without-ignore-errors.js b/test/parallel/test-console-write-without-ignore-errors.js new file mode 100644 index 00000000000000..66d79dc5619026 --- /dev/null +++ b/test/parallel/test-console-write-without-ignore-errors.js @@ -0,0 +1,29 @@ +'use strict'; +const common = require('../common'); +const { Console } = require('console'); +const { Writable } = require('stream'); +const assert = require('assert'); +const ignoreErrors = false; +const expected = 'foobarbaz'; + +{ + const out = new Writable({ + write: common.mustCall((chunk, enc, callback) => { + const actual = chunk.toString(); + assert.strictEqual(expected + '\n', actual); + }) + }); + + const c = new Console(out, out, ignoreErrors); + c.log(expected); +} + +assert.throws(() => { + const err = new Writable({ + write: common.mustCall((chunk, enc, callback) => { + throw new Error('foobar'); + }) + }); + const c = new Console(err, err, ignoreErrors); + c.log(expected); +}, /^Error: foobar$/); \ No newline at end of file