Files
klz-cables.com/.pnpm-store/v10/files/b8/e2b9a2b29ead82c0dcdfbc7927884f2705215de898bf7ddca7a2d7c98cc54001720142abaa9c73d4f949b573e45584a2583c9ebc149864ba4bee8017350371
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

107 lines
2.7 KiB
Plaintext

'use strict'
const os = require('node:os')
const { test } = require('tap')
const pino = require('../')
const { pid } = process
const hostname = os.hostname()
test('metadata works', async ({ ok, same, equal }) => {
const now = Date.now()
const instance = pino({}, {
[Symbol.for('pino.metadata')]: true,
write (chunk) {
equal(instance, this.lastLogger)
equal(30, this.lastLevel)
equal('a msg', this.lastMsg)
ok(Number(this.lastTime) >= now)
same(this.lastObj, { hello: 'world' })
const result = JSON.parse(chunk)
ok(new Date(result.time) <= new Date(), 'time is greater than Date.now()')
delete result.time
same(result, {
pid,
hostname,
level: 30,
hello: 'world',
msg: 'a msg'
})
}
})
instance.info({ hello: 'world' }, 'a msg')
})
test('child loggers works', async ({ ok, same, equal }) => {
const instance = pino({}, {
[Symbol.for('pino.metadata')]: true,
write (chunk) {
equal(child, this.lastLogger)
equal(30, this.lastLevel)
equal('a msg', this.lastMsg)
same(this.lastObj, { from: 'child' })
const result = JSON.parse(chunk)
ok(new Date(result.time) <= new Date(), 'time is greater than Date.now()')
delete result.time
same(result, {
pid,
hostname,
level: 30,
hello: 'world',
from: 'child',
msg: 'a msg'
})
}
})
const child = instance.child({ hello: 'world' })
child.info({ from: 'child' }, 'a msg')
})
test('without object', async ({ ok, same, equal }) => {
const instance = pino({}, {
[Symbol.for('pino.metadata')]: true,
write (chunk) {
equal(instance, this.lastLogger)
equal(30, this.lastLevel)
equal('a msg', this.lastMsg)
same({ }, this.lastObj)
const result = JSON.parse(chunk)
ok(new Date(result.time) <= new Date(), 'time is greater than Date.now()')
delete result.time
same(result, {
pid,
hostname,
level: 30,
msg: 'a msg'
})
}
})
instance.info('a msg')
})
test('without msg', async ({ ok, same, equal }) => {
const instance = pino({}, {
[Symbol.for('pino.metadata')]: true,
write (chunk) {
equal(instance, this.lastLogger)
equal(30, this.lastLevel)
equal(undefined, this.lastMsg)
same({ hello: 'world' }, this.lastObj)
const result = JSON.parse(chunk)
ok(new Date(result.time) <= new Date(), 'time is greater than Date.now()')
delete result.time
same(result, {
pid,
hostname,
level: 30,
hello: 'world'
})
}
})
instance.info({ hello: 'world' })
})