Files
klz-cables.com/.pnpm-store/v10/files/c1/66fcc73d7d4cab662df0fa6d5f598bb6048b8f864eeead04289361c191fb257dee68dbb870dfb403091db1f0ba6fbe41065798691eb833469a9a77aa845052
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

136 lines
3.7 KiB
Plaintext

'use strict'
const os = require('node:os')
const { join } = require('node:path')
const { readFile } = require('node:fs').promises
const { watchFileCreated, file } = require('../helper')
const { test } = require('tap')
const pino = require('../../')
const { DEFAULT_LEVELS } = require('../../lib/constants')
const { pid } = process
const hostname = os.hostname()
test('pino.transport with a pipeline', async ({ same, teardown }) => {
const destination = file()
const transport = pino.transport({
pipeline: [{
target: join(__dirname, '..', 'fixtures', 'transport-transform.js')
}, {
target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
options: { destination }
}]
})
teardown(transport.end.bind(transport))
const instance = pino(transport)
instance.info('hello')
await watchFileCreated(destination)
const result = JSON.parse(await readFile(destination))
delete result.time
same(result, {
pid,
hostname,
level: DEFAULT_LEVELS.info,
msg: 'hello',
service: 'pino' // this property was added by the transform
})
})
test('pino.transport with targets containing pipelines', async ({ same, teardown }) => {
const destinationA = file()
const destinationB = file()
const transport = pino.transport({
targets: [
{
target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
options: { destination: destinationA }
},
{
pipeline: [
{
target: join(__dirname, '..', 'fixtures', 'transport-transform.js')
},
{
target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
options: { destination: destinationB }
}
]
}
]
})
teardown(transport.end.bind(transport))
const instance = pino(transport)
instance.info('hello')
await watchFileCreated(destinationA)
await watchFileCreated(destinationB)
const resultA = JSON.parse(await readFile(destinationA))
const resultB = JSON.parse(await readFile(destinationB))
delete resultA.time
delete resultB.time
same(resultA, {
pid,
hostname,
level: DEFAULT_LEVELS.info,
msg: 'hello'
})
same(resultB, {
pid,
hostname,
level: DEFAULT_LEVELS.info,
msg: 'hello',
service: 'pino' // this property was added by the transform
})
})
test('pino.transport with targets containing pipelines with levels defined and dedupe', async ({ same, teardown }) => {
const destinationA = file()
const destinationB = file()
const transport = pino.transport({
targets: [
{
target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
options: { destination: destinationA },
level: DEFAULT_LEVELS.info
},
{
pipeline: [
{
target: join(__dirname, '..', 'fixtures', 'transport-transform.js')
},
{
target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
options: { destination: destinationB }
}
],
level: DEFAULT_LEVELS.error
}
],
dedupe: true
})
teardown(transport.end.bind(transport))
const instance = pino(transport)
instance.info('hello info')
instance.error('hello error')
await watchFileCreated(destinationA)
await watchFileCreated(destinationB)
const resultA = JSON.parse(await readFile(destinationA))
const resultB = JSON.parse(await readFile(destinationB))
delete resultA.time
delete resultB.time
same(resultA, {
pid,
hostname,
level: DEFAULT_LEVELS.info,
msg: 'hello info'
})
same(resultB, {
pid,
hostname,
level: DEFAULT_LEVELS.error,
msg: 'hello error',
service: 'pino' // this property was added by the transform
})
})