test('returns level integer', ({ end, is }) => { const instance = pino({ level: 'error' }) is(instance.levelVal, 50) end() })
test('exposes level string mappings', ({ end, is }) => { is(pino.levels.values.error, 50) end() })
test('unix timestamp', ({ end, is }) => { const instance = pino({ timestamp: pino.stdTimeFunctions.unixTime, browser: { asObject: true, write: function (o) { is(o.time, Math.round(1599400603614 / 1000.0)) } } }) instance.info('hello world') end() })
function consoleMethodTest (level, method) { if (!method) method = level test('pino().' + level + ' uses console.' + method, ({ end, is }) => { sink(method, (args) => { is(args[0], 'test') end() }) const instance = require('../browser')({ level }) instance[level]('test') }) }
test('exposes level number mappings', ({ end, is }) => { is(pino.levels.labels[50], 'error') end() })
test('iso timestamp', ({ end, is }) => { const instance = pino({ timestamp: pino.stdTimeFunctions.isoTime, browser: { asObject: true, write: function (o) { is(o.time, '2020-09-06T13:56:43.614Z') } } }) instance.info('hello world') end() })
test('children serializers get called', ({ end, is }) => { const parent = pino({ test: 'this', browser: { serialize: true, write (o) { is(o.test, 'child') } } }) const child = parent.child({ a: 'property', serializers: childSerializers }) child.fatal({ test: 'test' }) end() })
test('epoch timestamp by default', ({ end, is }) => { const instance = pino({ browser: { asObject: true, write: function (o) { is(o.time, 1599400603614) } } }) instance.info('hello world') end() })
test('without the serialize option, serializers do not override values', ({ end, is }) => { const parent = pino({ serializers: parentSerializers, browser: { write (o) { is(o.test, 'test') end() } } }) parent.fatal({ test: 'test' }) })
test('not print timestamp if the option is false', ({ end, is }) => { const instance = pino({ timestamp: false, browser: { asObject: true, write: function (o) { is(o.time, undefined) } } }) instance.info('hello world') end() })
test('serializers override values', ({ end, is }) => { const parent = pino({ serializers: parentSerializers, browser: { serialize: true, write (o) { is(o.test, 'parent') end() } } }) parent.fatal({ test: 'test' }) })
test('opts.browser.write func string object joining when asObject is true', ({ end, ok, is }) => { const instance = pino({ browser: { asObject: true, write: function (o) { is(o.level, 30) is(o.msg, 'test {"test":"test2"} {"test":"test3"}') ok(o.time) } } }) instance.info('test %j %j', { test: 'test2' }, { test: 'test3' }) end() })