test('the wrong level throws', ({ end, throws }) => { const instance = pino() throws(() => { instance.level = 'kaboom' }) end() })
test('exposes err stdSerializer', ({ end, ok }) => { ok(pino.stdSerializers.err) ok(pino.stdSerializers.err(Error())) end() })
test('exposed levels', ({ end, same }) => { same(Object.keys(pino.levels.values), [ 'fatal', 'error', 'warn', 'info', 'debug', 'trace' ]) end() })
test('opts.browser.write func log single object', ({ end, ok, is }) => { const instance = pino({ browser: { write: function (o) { is(o.level, 30) is(o.test, 'test') ok(o.time) } } }) instance.info({ test: 'test' }) end() })
test('throws if transmit object does not have send function', ({ end, throws }) => { throws(() => { pino({ browser: { transmit: {} } }) }) throws(() => { pino({ browser: { transmit: { send: 'not a func' } } }) }) 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() })
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('exposes level string mappings', ({ end, is }) => { is(pino.levels.values.error, 50) end() })
test('opts.browser.asObject defensively mitigates naughty numbers', ({ end, pass }) => { const instance = pino({ browser: { asObject: true, write: () => {} } }) const child = instance.child({ test: 'test' }) child._childLevel = -10 child.info('test') pass() // if we reached here, there was no infinite loop, so, .. pass. end() })
test('throw if creating child without bindings', ({ end, throws }) => { const instance = pino() throws(() => instance.child()) 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('exposed labels', ({ end, same }) => { same(Object.keys(pino.levels.labels), [ '10', '20', '30', '40', '50', '60' ]) end() })
test('returns level integer', ({ end, is }) => { const instance = pino({ level: 'error' }) is(instance.levelVal, 50) end() })
test('the wrong level by number throws', ({ end, throws }) => { const instance = pino() throws(() => { instance.levelVal = 55 }) 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' }) })