{"_id":"pino-test","_rev":"6-492edbab430d83f1eee9fd06b32de6fb","name":"pino-test","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"pino-test","version":"1.0.0","keywords":["pino","logger","test","stream"],"author":"","license":"MIT","_id":"pino-test@1.0.0","maintainers":[{"name":"matteo.collina","email":"hello@matteocollina.com"}],"homepage":"https://github.com/pinojs/pino-test#readme","bugs":{"url":"https://github.com/pinojs/pino-test/issues"},"tsd":{"directory":"test/types"},"dist":{"shasum":"78515a7a990264237877394467a04d881a0ce4aa","tarball":"https://registry.npmjs.org/pino-test/-/pino-test-1.0.0.tgz","fileCount":17,"integrity":"sha512-uoyAzF8Wpa9MzI+MNbyUHr7kZDRR07Ro47fryutqJUD6UtCojF3NybdaPfOOSmbS0F0x8OpCOHl4NF+r34JccA==","signatures":[{"sig":"MEQCIGMarzjMxFn8VPV24JlUXJ37Jy70wRdq1iHFVJMeZZrqAiBPOrx8BvdNIIVgwchox48+BqhxPY6+jfPWesGCdIdghg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":27688},"main":"pino-test.js","type":"commonjs","types":"pino-test.d.ts","gitHead":"afbb0ff1bd88ec88af690509405646dad1ea1949","scripts":{"lint":"eslint .","test":"npm run lint && node --experimental-test-coverage --test-reporter=spec --test **/*.test.js && npm run test-types","test-ci":"npm run lint && node --experimental-test-coverage --test-reporter=lcov --test **/*.test.js && npm run test-types","test-types":"tsc && tsd && ts-node test/types/pino-test.ts","test-ci-pnpm":"pnpm run lint && node --experimental-test-coverage --test-reporter=lcov --test **/*.test.js && pnpm run test-types","test-ci-yarn-pnp":"yarn run lint && node --experimental-test-coverage --test-reporter=lcov --test **/*.test.js"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"precommit":"test","repository":{"url":"git+https://github.com/pinojs/pino-test.git","type":"git"},"_npmVersion":"10.2.4","description":"A set of API to easily test the Pino logger","directories":{},"_nodeVersion":"20.11.1","dependencies":{"split2":"^4.2.0"},"_hasShrinkwrap":false,"devDependencies":{"tsd":"^0.30.7","pino":"^8.19.0","eslint":"^8.57.0","ts-node":"^10.9.2","typescript":"^5.4.2","@types/node":"^20.11.25","eslint-plugin-n":"^16.6.2","eslint-plugin-node":"^11.1.0","@fastify/pre-commit":"^2.1.0","eslint-plugin-import":"^2.29.1","eslint-plugin-promise":"^6.1.1","eslint-config-standard":"^17.1.0"},"_npmOperationalInternal":{"tmp":"tmp/pino-test_1.0.0_1710322993907_0.12720980034519025","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"pino-test","version":"1.0.1","keywords":["pino","logger","test","stream"],"author":"","license":"MIT","_id":"pino-test@1.0.1","maintainers":[{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"watson","email":"w@tson.dk"}],"homepage":"https://github.com/pinojs/pino-test#readme","bugs":{"url":"https://github.com/pinojs/pino-test/issues"},"tsd":{"directory":"test/types"},"dist":{"shasum":"00bd583b8904358ca86e7ffed9ff0b7b1e6f9c9d","tarball":"https://registry.npmjs.org/pino-test/-/pino-test-1.0.1.tgz","fileCount":16,"integrity":"sha512-ISdyVW8D6xJez8tEC2D0JBXeaKVU40GjMjxd/YgKP/6Am1c+yHb7F4ysY6ZyKVblQSREetW0f1irKXeku6tJGw==","signatures":[{"sig":"MEUCIFlpSV4cTi35BoXeGV+7w3Wt3VnqQwQieQv8w0LR471rAiEAhTBmgBEKmmxsO8N4sP+GajUFRtiybi5kQEaB+ddr+ls=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25496},"main":"pino-test.js","type":"commonjs","types":"pino-test.d.ts","gitHead":"c22d2aba5a44f7d1cd51aed8f81ff70c1a046f7c","scripts":{"lint":"eslint .","test":"npm run lint && node --experimental-test-coverage --test-reporter=spec --test **/*.test.js && npm run test-types","test-ci":"npm run lint && node --experimental-test-coverage --test-reporter=lcov --test **/*.test.js && npm run test-types","test-types":"tsc && tsd && ts-node test/types/pino-test.ts","test-ci-pnpm":"pnpm run lint && node --experimental-test-coverage --test-reporter=lcov --test **/*.test.js && pnpm run test-types","test-ci-yarn-pnp":"yarn run lint && node --experimental-test-coverage --test-reporter=lcov --test **/*.test.js"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"precommit":"test","repository":{"url":"git+https://github.com/pinojs/pino-test.git","type":"git"},"_npmVersion":"10.2.4","description":"A set of API to easily test the Pino logger","directories":{},"_nodeVersion":"20.11.1","dependencies":{"split2":"^4.2.0"},"_hasShrinkwrap":false,"devDependencies":{"tsd":"^0.30.7","pino":"^8.19.0","eslint":"^8.57.0","ts-node":"^10.9.2","typescript":"^5.4.2","@types/node":"^20.11.25","eslint-plugin-n":"^16.6.2","eslint-plugin-node":"^11.1.0","@fastify/pre-commit":"^2.1.0","eslint-plugin-import":"^2.29.1","eslint-plugin-promise":"^6.1.1","eslint-config-standard":"^17.1.0"},"_npmOperationalInternal":{"tmp":"tmp/pino-test_1.0.1_1710325197519_0.7789631210983246","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"pino-test","version":"1.1.0","keywords":["pino","logger","test","stream"],"author":"","license":"MIT","_id":"pino-test@1.1.0","maintainers":[{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"watson","email":"w@tson.dk"}],"homepage":"https://github.com/pinojs/pino-test#readme","bugs":{"url":"https://github.com/pinojs/pino-test/issues"},"tsd":{"directory":"test/types"},"dist":{"shasum":"3e50be6249a1dd034f8fa7d3c810eda11172f126","tarball":"https://registry.npmjs.org/pino-test/-/pino-test-1.1.0.tgz","fileCount":16,"integrity":"sha512-eAD3qqt23jiJrwAWHSEdKyBRUjflodcTW14u9i/k4sdDsIT0r3v1cv+JyLJERFYfWgVkqAjgfOCkHVFiPNvpmg==","signatures":[{"sig":"MEYCIQCh5nK8SFJfP/qTPh7/eMR9hNsAP2vqntgFN4bAZz3fTgIhAOqqUDsbdhmVpxt/PpdOjaVxVsYvlc2jczyoxjHnveI1","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31956},"main":"pino-test.js","type":"commonjs","types":"pino-test.d.ts","gitHead":"464e7ae07a50dbee290ea7d4fc96a3fdef010fac","scripts":{"lint":"eslint .","test":"npm run lint && node --test **/*.test.js && npm run test-types","test-ci":"npm run lint && node --test **/*.test.js && npm run test-types","test-types":"tsc && tsd && ts-node test/types/pino-test.ts","test-ci-pnpm":"pnpm run lint && node --test **/*.test.js && pnpm run test-types","test-coverage":"npm run lint && node --experimental-test-coverage --test-reporter=spec --test **/*.test.js && npm run test-types","test-ci-yarn-pnp":"yarn run lint && node --test **/*.test.js"},"_npmUser":{"name":"jsumners","email":"james.sumners@gmail.com"},"precommit":"test","repository":{"url":"git+https://github.com/pinojs/pino-test.git","type":"git"},"_npmVersion":"10.8.2","description":"A set of API to easily test the Pino logger","directories":{},"_nodeVersion":"22.5.1","dependencies":{"split2":"^4.2.0"},"_hasShrinkwrap":false,"devDependencies":{"tsd":"^0.30.7","pino":"^8.19.0","eslint":"^8.57.0","ts-node":"^10.9.2","typescript":"^5.4.2","@types/node":"^20.11.25","eslint-plugin-n":"^16.6.2","eslint-plugin-node":"^11.1.0","@fastify/pre-commit":"^2.1.0","eslint-plugin-import":"^2.29.1","eslint-plugin-promise":"^6.1.1","eslint-config-standard":"^17.1.0"},"_npmOperationalInternal":{"tmp":"tmp/pino-test_1.1.0_1729338208976_0.6377222318579117","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"pino-test","version":"2.0.0","keywords":["pino","logger","test","stream"],"author":"","license":"MIT","_id":"pino-test@2.0.0","maintainers":[{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"watson","email":"w@tson.dk"}],"homepage":"https://github.com/pinojs/pino-test#readme","bugs":{"url":"https://github.com/pinojs/pino-test/issues"},"tsd":{"directory":"test/types"},"dist":{"shasum":"5ee7d3bc4efe6354b3daef1437e27ef878f9ac10","tarball":"https://registry.npmjs.org/pino-test/-/pino-test-2.0.0.tgz","fileCount":18,"integrity":"sha512-quHvIgAFMzm1Jx05xaHYRk2fdE/UQifabYzwGkbp8nbr34zxKcFPZqP5foGvk0EoqtepctrRTiDELvESOiwgIg==","signatures":[{"sig":"MEUCIQDhhf2vhX6uoEqoMQZNOSwMJDkXADaWP2HcUHiudOs67gIgf1o+dAx5URSr0zxVafCaizH+ZAJZVopx9f64qxPrEfY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32327},"main":"pino-test.js","type":"commonjs","types":"pino-test.d.ts","gitHead":"06864fa52d49296b383fa9d601f5c9a644a4b8cd","scripts":{"lint":"eslint .","test":"npm run lint && node --test **/*.test.js && npm run test-types","test-ci":"npm run lint && node --test **/*.test.js && npm run test-types","test-types":"tsc && tsd && ts-node test/types/pino-test.ts","test-ci-pnpm":"pnpm run lint && node --test **/*.test.js && pnpm run test-types","test-coverage":"npm run lint && node --experimental-test-coverage --test-reporter=spec --test **/*.test.js && npm run test-types","test-ci-yarn-pnp":"yarn run lint && node --test **/*.test.js"},"_npmUser":{"name":"jsumners","email":"james.sumners@gmail.com"},"repository":{"url":"git+https://github.com/pinojs/pino-test.git","type":"git"},"_npmVersion":"11.9.0","description":"A set of API to easily test the Pino logger","directories":{},"_nodeVersion":"24.14.0","dependencies":{"split2":"^4.2.0"},"_hasShrinkwrap":false,"devDependencies":{"tsd":"^0.33.0","pino":"^10.3.1","eslint":"^9.21.0","ts-node":"^10.9.2","typescript":"^5.7.3","@types/node":"^22.13.5","neostandard":"^0.13.0"},"_npmOperationalInternal":{"tmp":"tmp/pino-test_2.0.0_1773312568894_0.3222253046788921","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2024-03-13T09:43:13.906Z","modified":"2026-07-29T19:41:28.572Z","1.0.0":"2024-03-13T09:43:14.070Z","1.0.1":"2024-03-13T10:19:57.661Z","1.1.0":"2024-10-19T11:43:29.164Z","2.0.0":"2026-03-12T10:49:29.031Z"},"bugs":{"url":"https://github.com/pinojs/pino-test/issues"},"license":"MIT","homepage":"https://github.com/pinojs/pino-test#readme","keywords":["pino","logger","test","stream"],"repository":{"url":"git+https://github.com/pinojs/pino-test.git","type":"git"},"description":"A set of API to easily test the Pino logger","maintainers":[{"email":"hello@matteocollina.com","name":"matteo.collina"},{"email":"james.sumners@gmail.com","name":"jsumners"}],"readme":"# pino-test\n\nProvides a set of utilities for verifying logs generated by the Pino logger.\n\n## Getting started\n```sh\nnpm install pino-test --save-dev\n```\n\n```js\nconst test = require('node:test')\nconst pino = require('pino')\nconst pinoTest = require('pino-test')\n\ntest('pino should log a info message', async () => {\n  const stream = pinoTest.sink()\n  const logger = pino(stream)\n\n  logger.info('hello world')\n\n  const expected = { msg: 'hello world', level: 30 }\n  await pinoTest.once(stream, expected)\n})\n\n// with a own assert function\nfunction is (received, expected, msg) {\n  if (received.msg !== expected.msg) {\n    throw new Error(`expected msg ${expected.msg} doesn't match the received one ${received.msg}`)\n  }\n}\n\ntest('pino should log a info message using a own assert function', async () => {\n  const stream = pinoTest.sink()\n  const logger = pino(stream)\n\n  logger.info('hello world')\n\n  const expected = { msg: 'hello world', level: 30 }\n  await pinoTest.once(stream, expected, is)\n})\n```\n\n## API\n\n* [sink()](#sink)\n* [once()](#once)\n* [consecutive()](#consecutive)\n\n<a id=\"sink\"></a>\n### `pinoTest.sink({ destroyOnError = false, emitErrorEvent = false }) => Transform`\nCreate a Pino destination stream to easily inspect the logs processed by Pino.\n\n```js\nconst pino = require('pino')\nconst pinoTest = require('pino-test')\n\nconst stream = pinoTest.sink()\nconst logger = pino(stream)\n\nlogger.info('hello world')\n\nstream.once('data', (chunk) => {\n  console.log(chunk.msg) // 'hello world'\n  console.log(chunk.level) // 30\n})\n```\nDestroy the stream on error\n```js\nconst pino = require('pino')\nconst pinoTest = require('pino-test')\n\nconst stream = pinoTest.sink({ destroyOnError: true })\nstream.write('helloworld')\nstream.end()\n\nstream.once('close', () => {\n  console.log('close event') // \"close event\"\n})\n```\nDestroy and send error event on error\n```js\nconst pino = require('pino')\nconst pinoTest = require('pino-test')\n\nconst stream = pinoTest.sink({ destroyOnError: false, emitErrorEvent: false })\nstream.write('helloworld')\nstream.end()\n\nstream.on('error', (err) => {\n  console.log(err) // Unexpected token h in JSON at position 0\n})\n\nstream.on('close', () => {\n  console.log('close event') // \"close event\"\n})\n```\nSend error event on error\n```js\nconst pino = require('pino')\nconst pinoTest = require('pino-test')\n\nconst stream = pinoTest.sink({ emitErrorEvent: false })\nstream.write('helloworld')\nstream.end()\n\nstream.on('error', (err) => {\n  console.log(err) // Unexpected token h in JSON at position 0\n})\n```\n<a id=\"once\"></a>\n### `once(stream, expectedOrCallback, is) => Promise<void>`\nAssert that a single log is expected.\nThe function internally\n- assert log message `time` is less than or equal to the current time\n- assert log message `pid` matches the current process id\n- assert log message `hostname` matches the current hostname\n- uses the default `deepStrictEqual` assert function of the `node:assert` module.\n\n```js\nconst pino = require('pino')\nconst pinoTest = require('pino-test')\n\nconst stream = pinoTest.sink()\nconst logger = pino(stream)\n\nlogger.info('hello world')\n\nconst expected = { msg: 'hello world', level: 30 }\nawait pinoTest.once(stream, expected) // doesn't throw a diff error\nawait pinoTest.once(stream, { msg: 'bye world', level: 30 }) // throw a diff error\n\n// OR logging an object\nlogger.info({ hello: 'world', hi: 'world' })\nawait pinoTest.once(stream, { hello: 'world', hi: 'world', level: 30 }) // doesn't throw a diff error\nawait pinoTest.once(stream, { hello: 'world', level: 30 }) // throw a diff error\n\n// OR using a custom assert function\nfunction is (received, expected, msg) {\n  if (received.msg !== expected.msg) {\n    throw new Error(`expected msg ${expected.msg} doesn't match the received one ${received.msg}`)\n  }\n}\n\nawait pinoTest.once(stream, expected, is) // doesn't throw an error\nawait pinoTest.once(stream, { msg: 'bye world', level: 30 }, is) // throw an error\n\n// OR using a custom callback\nawait pinoTest.once(stream, (received) => {\n  assert.strictEqual(received.msg, 'hello world')\n})\n```\n<a id=\"consecutive\"></a>\n### `consecutive(stream, expectedOrCallbacks, is) => Promise<void>`\nAssert that consecutive logs are expected.\nThe function internally\n- assert log message `time` is less than or equal to the current time\n- assert log message `pid` matches the current process id\n- assert log message `hostname` matches the current hostname\n- uses the default `deepStrictEqual` assert function of the `node:assert` module.\n\n```js\nconst pino = require('pino')\nconst pinoTest = require('pino-test')\n\nconst stream = pinoTest.sink()\nconst logger = pino(stream)\n\nlogger.info('hello world')\nlogger.info('hi world')\n\nconst expected = [\n  { msg: 'hello world', level: 30 },\n  { msg: 'hi world', level: 30 }\n]\n\nawait pinoTest.consecutive(stream, expected) // doesn't throw a diff error\nawait pinoTest.consecutive(stream, [{ msg: 'bye world', level: 30 }]) // throw a diff error\n\n// OR logging an object\nlogger.info({ hello: 'world' })\nlogger.info({ hi: 'world' })\nawait pinoTest.consecutive(stream, [\n  { hello: 'world', level: 30 },\n  { hi: 'world', level: 30 }\n])\n\n// OR using a custom assert function\nfunction is (received, expected, msg) {\n  if (received.msg !== expected.msg) {\n    throw new Error(`expected msg ${expected.msg} doesn't match the received one ${received.msg}`)\n  }\n}\n\nawait pinoTest.consecutive(stream, expected, is) // doesn't throw an error\nawait pinoTest.consecutive(stream, [{ msg: 'bye world', level: 30 }], is) // throw an error\n\n// OR using a custom callback\nawait pinoTest.consecutive(stream, [\n  { msg: 'hello world', level: 30 },\n  (received) => {\n    assert.strictEqual(received.msg, 'hi world')\n  }\n])\n```\n","readmeFilename":"README.md"}