Skip to content

Commit

Permalink
Fix a test failure in node >=12 due to util.format edge case change
Browse files Browse the repository at this point in the history
THis is a slight change in how `log.info(undefined, 'some message')`
is rendered by Bunyan, but that's been a fact since node v12.

nodejs/node#23162 was the relevant change.
  • Loading branch information
trentm committed Jun 27, 2020
1 parent b6f73f3 commit ab8e5c6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/log.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,20 @@ var names = ['trace', 'debug', 'info', 'warn', 'error', 'fatal'];
var fields = {one: 'un'};

test('log.info(undefined, <msg>)', function (t) {
// https://github.com/nodejs/node/pull/23162 (starting in node v12) changed
// util.format() handling such that this test case expected string differs.
var expect;
if (Number(process.versions.node.split('.')[0]) >= 12) {
expect = 'undefined some message';
} else {
expect = 'undefined \'some message\'';
}

names.forEach(function (lvl) {
log3[lvl].call(log3, undefined, 'some message');
var rec = catcher.records[catcher.records.length - 1];
t.equal(rec.msg, 'undefined \'some message\'',
format('log.%s msg is "some message"', lvl));
t.equal(rec.msg, expect,
format('log.%s(undefined, "some message")', lvl));
});
t.end();
});
Expand Down

0 comments on commit ab8e5c6

Please sign in to comment.