Skip to content

Commit

Permalink
Replaced zuul with airtap
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed May 27, 2018
1 parent 3b1645e commit 2a54d53
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 157 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lib"
],
"scripts": {
"browser-test": "zuul tape test/browser*test.js --local",
"browser-test": "airtap --local 8080 test/browser*test.js",
"test": "standard | snazzy && NODE_OPTIONS='--no-warnings' tap --no-cov test/*test.js",
"ci": "standard | snazzy && NODE_OPTIONS='--no-warnings' tap --cov test/*test.js",
"bench-all": "node benchmarks/runbench all",
Expand Down Expand Up @@ -55,6 +55,7 @@
},
"homepage": "http://getpino.io",
"devDependencies": {
"airtap": "0.0.7",
"benchmark": "^2.1.4",
"bole": "^3.0.2",
"bunyan": "^1.8.12",
Expand All @@ -69,14 +70,13 @@
"snazzy": "^7.1.1",
"standard": "^11.0.1",
"steed": "^1.1.3",
"tap": "^11.1.3",
"tap": "^11.1.5",
"tape": "^4.9.0",
"through2": "^2.0.3",
"winston": "^3.0.0-rc3",
"zuul": "^3.11.1"
"winston": "^3.0.0-rc5"
},
"dependencies": {
"chalk": "^2.3.2",
"chalk": "^2.4.1",
"fast-json-parse": "^1.0.3",
"fast-safe-stringify": "^1.2.3",
"flatstr": "^1.0.5",
Expand Down
278 changes: 140 additions & 138 deletions test/browser.serializers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,173 +38,175 @@ test('without the serialize option, serializers do not override values', functio
parent.fatal({test: 'test'})
})

test('if serialize option is true, standard error serializer is auto enabled', function (t) {
t.plan(1)
var err = Error('test')
err.code = 'test'
err.type = 'Error' // get that cov
var expect = pino.stdSerializers.err(err)

var consoleError = console.error
console.error = function (err) {
t.deepEqual(err, expect)
}

var logger = fresh('../browser', require)({
browser: { serialize: true }
if (process.title !== 'browser') {
test('if serialize option is true, standard error serializer is auto enabled', function (t) {
t.plan(1)
var err = Error('test')
err.code = 'test'
err.type = 'Error' // get that cov
var expect = pino.stdSerializers.err(err)

var consoleError = console.error
console.error = function (err) {
t.deepEqual(err, expect)
}

var logger = fresh('../browser', require)({
browser: { serialize: true }
})

console.error = consoleError

logger.fatal(err)
})

console.error = consoleError
test('if serialize option is array, standard error serializer is auto enabled', function (t) {
t.plan(1)
var err = Error('test')
err.code = 'test'
var expect = pino.stdSerializers.err(err)

logger.fatal(err)
})
var consoleError = console.error
console.error = function (err) {
t.deepEqual(err, expect)
}

test('if serialize option is array, standard error serializer is auto enabled', function (t) {
t.plan(1)
var err = Error('test')
err.code = 'test'
var expect = pino.stdSerializers.err(err)
var logger = fresh('../browser', require)({
browser: { serialize: [] }
})

var consoleError = console.error
console.error = function (err) {
t.deepEqual(err, expect)
}
console.error = consoleError

var logger = fresh('../browser', require)({
browser: { serialize: [] }
logger.fatal(err)
})

console.error = consoleError
test('if serialize option is array containing !stdSerializers.err, standard error serializer is disabled', function (t) {
t.plan(1)
var err = Error('test')
err.code = 'test'
var expect = err

logger.fatal(err)
})
var consoleError = console.error
console.error = function (err) {
t.is(err, expect)
}

test('if serialize option is array containing !stdSerializers.err, standard error serializer is disabled', function (t) {
t.plan(1)
var err = Error('test')
err.code = 'test'
var expect = err
var logger = fresh('../browser', require)({
browser: { serialize: ['!stdSerializers.err'] }
})

var consoleError = console.error
console.error = function (err) {
t.is(err, expect)
}
console.error = consoleError

var logger = fresh('../browser', require)({
browser: { serialize: ['!stdSerializers.err'] }
logger.fatal(err)
})

console.error = consoleError

logger.fatal(err)
})

test('in browser, serializers apply to all objects', function (t) {
t.plan(3)
var consoleError = console.error
console.error = function (test, test2, test3, test4, test5) {
t.is(test.key, 'serialized')
t.is(test2.key2, 'serialized2')
t.is(test5.key3, 'serialized3')
}

var logger = fresh('../browser', require)({
serializers: {
key: function () { return 'serialized' },
key2: function () { return 'serialized2' },
key3: function () { return 'serialized3' }
},
browser: { serialize: true }
test('in browser, serializers apply to all objects', function (t) {
t.plan(3)
var consoleError = console.error
console.error = function (test, test2, test3, test4, test5) {
t.is(test.key, 'serialized')
t.is(test2.key2, 'serialized2')
t.is(test5.key3, 'serialized3')
}

var logger = fresh('../browser', require)({
serializers: {
key: function () { return 'serialized' },
key2: function () { return 'serialized2' },
key3: function () { return 'serialized3' }
},
browser: { serialize: true }
})

console.error = consoleError

logger.fatal({key: 'test'}, {key2: 'test'}, 'str should skip', [{foo: 'array should skip'}], {key3: 'test'})
})

console.error = consoleError

logger.fatal({key: 'test'}, {key2: 'test'}, 'str should skip', [{foo: 'array should skip'}], {key3: 'test'})
})

test('serialize can be an array of selected serializers', function (t) {
t.plan(3)
var consoleError = console.error
console.error = function (test, test2, test3, test4, test5) {
t.is(test.key, 'test')
t.is(test2.key2, 'serialized2')
t.is(test5.key3, 'test')
}

var logger = fresh('../browser', require)({
serializers: {
key: function () { return 'serialized' },
key2: function () { return 'serialized2' },
key3: function () { return 'serialized3' }
},
browser: { serialize: ['key2'] }
test('serialize can be an array of selected serializers', function (t) {
t.plan(3)
var consoleError = console.error
console.error = function (test, test2, test3, test4, test5) {
t.is(test.key, 'test')
t.is(test2.key2, 'serialized2')
t.is(test5.key3, 'test')
}

var logger = fresh('../browser', require)({
serializers: {
key: function () { return 'serialized' },
key2: function () { return 'serialized2' },
key3: function () { return 'serialized3' }
},
browser: { serialize: ['key2'] }
})

console.error = consoleError

logger.fatal({key: 'test'}, {key2: 'test'}, 'str should skip', [{foo: 'array should skip'}], {key3: 'test'})
})

console.error = consoleError

logger.fatal({key: 'test'}, {key2: 'test'}, 'str should skip', [{foo: 'array should skip'}], {key3: 'test'})
})

test('serialize filter applies to child loggers', function (t) {
t.plan(3)
var consoleError = console.error
console.error = function (binding, test, test2, test3, test4, test5) {
t.is(test.key, 'test')
t.is(test2.key2, 'serialized2')
t.is(test5.key3, 'test')
}

var logger = fresh('../browser', require)({
browser: { serialize: ['key2'] }
test('serialize filter applies to child loggers', function (t) {
t.plan(3)
var consoleError = console.error
console.error = function (binding, test, test2, test3, test4, test5) {
t.is(test.key, 'test')
t.is(test2.key2, 'serialized2')
t.is(test5.key3, 'test')
}

var logger = fresh('../browser', require)({
browser: { serialize: ['key2'] }
})

console.error = consoleError

logger.child({aBinding: 'test',
serializers: {
key: function () { return 'serialized' },
key2: function () { return 'serialized2' },
key3: function () { return 'serialized3' }
}}).fatal({key: 'test'}, {key2: 'test'}, 'str should skip', [{foo: 'array should skip'}], {key3: 'test'})
})

console.error = consoleError
test('parent serializers apply to child bindings', function (t) {
t.plan(1)
var consoleError = console.error
console.error = function (binding) {
t.is(binding.key, 'serialized')
}

logger.child({aBinding: 'test',
serializers: {
key: function () { return 'serialized' },
key2: function () { return 'serialized2' },
key3: function () { return 'serialized3' }
}}).fatal({key: 'test'}, {key2: 'test'}, 'str should skip', [{foo: 'array should skip'}], {key3: 'test'})
})
var logger = fresh('../browser', require)({
serializers: {
key: function () { return 'serialized' }
},
browser: { serialize: true }
})

test('parent serializers apply to child bindings', function (t) {
t.plan(1)
var consoleError = console.error
console.error = function (binding) {
t.is(binding.key, 'serialized')
}
console.error = consoleError

var logger = fresh('../browser', require)({
serializers: {
key: function () { return 'serialized' }
},
browser: { serialize: true }
logger.child({key: 'test'}).fatal({test: 'test'})
})

console.error = consoleError
test('child serializers apply to child bindings', function (t) {
t.plan(1)
var consoleError = console.error
console.error = function (binding) {
t.is(binding.key, 'serialized')
}

logger.child({key: 'test'}).fatal({test: 'test'})
})
var logger = fresh('../browser', require)({
browser: { serialize: true }
})

test('child serializers apply to child bindings', function (t) {
t.plan(1)
var consoleError = console.error
console.error = function (binding) {
t.is(binding.key, 'serialized')
}
console.error = consoleError

var logger = fresh('../browser', require)({
browser: { serialize: true }
logger.child({key: 'test',
serializers: {
key: function () { return 'serialized' }
}}).fatal({test: 'test'})
})

console.error = consoleError

logger.child({key: 'test',
serializers: {
key: function () { return 'serialized' }
}}).fatal({test: 'test'})
})
}

test('child does not overwrite parent serializers', function (t) {
t.plan(2)
Expand Down
31 changes: 17 additions & 14 deletions test/browser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,23 @@ absentConsoleMethodTest('info', 'log')
absentConsoleMethodTest('debug', 'log')
absentConsoleMethodTest('trace', 'log')

test('in absence of console, log methods become noops', function (t) {
var console = global.console
delete global.console
var instance = fresh('../browser', require)()
global.console = console
t.is(fnName(instance.log), 'noop')
t.is(fnName(instance.fatal), 'noop')
t.is(fnName(instance.error), 'noop')
t.is(fnName(instance.warn), 'noop')
t.is(fnName(instance.info), 'noop')
t.is(fnName(instance.debug), 'noop')
t.is(fnName(instance.trace), 'noop')
t.end()
})
// do not run this with airtap
if (process.title !== 'browser') {
test('in absence of console, log methods become noops', function (t) {
var console = global.console
delete global.console
var instance = fresh('../browser', require)()
global.console = console
t.is(fnName(instance.log), 'noop')
t.is(fnName(instance.fatal), 'noop')
t.is(fnName(instance.error), 'noop')
t.is(fnName(instance.warn), 'noop')
t.is(fnName(instance.info), 'noop')
t.is(fnName(instance.debug), 'noop')
t.is(fnName(instance.trace), 'noop')
t.end()
})
}

test('opts.browser.asObject logs pino-like object to console', function (t) {
t.plan(3)
Expand Down

0 comments on commit 2a54d53

Please sign in to comment.