Skip to content

Commit

Permalink
Added test for the new error serializer.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina authored and watson committed Jan 9, 2017
1 parent e8c9f23 commit 048bdaa
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,33 @@ test('type, message and stack should be first level properties', function (t) {
instance.level = name
instance[name](err)
})

test('err serializer', function (t) {
t.plan(2)
var err = new Error('myerror')
err.foo = 'bar'
var instance = pino({
serializers: {
err: pino.stdSerializers.err
}
}, sink(function (chunk, enc, cb) {
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time
t.deepEqual(chunk, {
pid: pid,
hostname: hostname,
level: level,
err: {
type: 'Error',
message: err.message,
stack: err.stack,
foo: err.foo
},
v: 1
})
cb()
}))

instance.level = name
instance[name]({ err: err })
})

0 comments on commit 048bdaa

Please sign in to comment.