{"library":"node-test-parser","title":"Node.js Test Report Stream Parser","description":"node-test-parser is a utility library designed to parse the output streams generated by Node.js's built-in native test runner. It provides a programmatic interface to transform raw test report streams into structured JavaScript objects, facilitating the creation of custom test reporters, analysis tools, or integration with other systems. The current stable version is 3.1.0, with regular patch and minor releases addressing dependency updates and Node.js compatibility. Major versions, such as v3.0.0, introduce significant breaking changes, primarily around Node.js runtime support. Its key differentiator lies in its specific focus and optimized parsing for the native Node.js test output, offering a streamlined approach for developers looking to extend the core Node.js testing experience without relying on external test frameworks.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install node-test-parser"],"cli":null},"imports":["import parseReport from 'node-test-parser'","import parseReport from 'node-test-parser'","export default async function* jsonReporter(source) { /* ... */ }"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import parseReport from 'node-test-parser'\nimport { test } from 'node:test'\n\n// reporter.js\nexport default async function* customJsonReporter(source) {\n  const report = await parseReport(source)\n  yield JSON.stringify(report, null, 2)\n}\n\n// In your terminal, you would run your tests with this custom reporter:\n// node --test --test-reporter ./reporter.js\n\n// Example of a simple test file (tests.js) to generate output for the reporter:\n// test('synchronous passing test', (t) => {\n//   t.ok(true, 'this passes')\n// });\n//\n// test('asynchronous failing test', async (t) => {\n//   await new Promise(resolve => setTimeout(resolve, 100));\n//   t.ok(false, 'this fails after a delay');\n// });\n//\n// test('skipped test', { skip: true }, (t) => {\n//   t.ok(true, 'this should be skipped');\n// });\n","lang":"javascript","description":"This quickstart demonstrates how to create a custom Node.js test reporter using `node-test-parser`. It shows how to import and use `parseReport` to consume the raw test stream and output a formatted JSON report. The example includes instructions for running tests with the custom reporter.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}