Skip to content

Commit

Permalink
use pino/file instead of pino-pretty for caller transport tests (#1370)
Browse files Browse the repository at this point in the history
This is due to pinojs/pino-pretty#304 which
might trigger under severe load and short-lived scripts. The fix
on pino-pretty will happen on its own time but there is no need
to use pino-pretty in these tests.

Fixes #1368
  • Loading branch information
mcollina committed Mar 17, 2022
1 parent 0d6eda8 commit da6b1dc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 38 deletions.
2 changes: 1 addition & 1 deletion test/fixtures/eval/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const pino = require('../../../')
const logger = pino(
pino.transport({
target: 'pino-pretty'
target: 'pino/file'
})
)
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/eval/node_modules/file14.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 6 additions & 36 deletions test/transport/caller.test.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,23 @@
'use strict'

const writer = require('flush-write-stream')
const { join } = require('path')
const { test } = require('tap')
const execa = require('execa')

const { once } = require('../helper')

test('when using a custom transport outside node_modules, the first file outside node_modules should be used', async function (t) {
const evalApp = join(__dirname, '../', '/fixtures/eval/index.js')
const child = execa(process.argv[0], [evalApp])

let actual = ''
child.stdout.pipe(writer((s, enc, cb) => {
actual += s
cb()
}))

await once(child, 'close')

t.match(actual, /done!/)
const { stdout } = await execa(process.argv[0], [evalApp])
t.match(stdout, /done!/)
})

test('when using a custom transport where some files in stacktrace are in the node_modules, the first file outside node_modules should be used', async function (t) {
const evalApp = join(__dirname, '../', '/fixtures/eval/node_modules/2-files.js')
const child = execa(process.argv[0], [evalApp])

let actual = ''
child.stdout.pipe(writer((s, enc, cb) => {
actual += s
cb()
}))

await once(child, 'close')

t.match(actual, /done!/)
const { stdout } = await execa(process.argv[0], [evalApp])
t.match(stdout, /done!/)
})

test('when using a custom transport where all files in stacktrace are in the node_modules, the first file inside node_modules should be used', async function (t) {
const evalApp = join(__dirname, '../', '/fixtures/eval/node_modules/14-files.js')
const child = execa(process.argv[0], [evalApp])

let actual = ''
child.stdout.pipe(writer((s, enc, cb) => {
actual += s
cb()
}))

await once(child, 'close')

t.match(actual, /done!/)
const { stdout } = await execa(process.argv[0], [evalApp])
t.match(stdout, /done!/)
})

0 comments on commit da6b1dc

Please sign in to comment.