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

test: improve console coverage to check ignoreErrors #11531

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions test/parallel/test-console-write-without-ignore-errors.js
Original file line number Diff line number Diff line change
@@ -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';
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you either scope this to the first test, or name it something else. This isn't actually "expected" output in the second test.


{
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) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused parameters.

throw new Error('foobar');
})
});
const c = new Console(err, err, ignoreErrors);
c.log(expected);
}, /^Error: foobar$/);
Copy link
Contributor

Choose a reason for hiding this comment

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

Our linter will fail as there is no newline at the end of the file.