tap-parser is a JavaScript library designed to parse the Test Anything Protocol (TAP) stream, specifically implementing version 14 of the TAP specification. It is currently at version 18.3.3 and appears to have a stable release cadence, with frequent updates to its main `tap` package dependency, suggesting active maintenance. The library provides a streaming parser, allowing users to pipe TAP output directly into it for real-time processing. Beyond streaming, it also offers utility functions (`parse` and `stringify`) for handling TAP data as strings or arrays of events, though `stringify` has limitations as TAP is not an object serialization format. Key differentiators include its focus on strict TAP v14 compliance, its streaming capabilities, and its dual-purpose API for both stream and string-based parsing, along with a command-line interface.
npm install tap-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates piping a simulated TAP stream into a Parser instance and logging the complete results object, showing basic stream-based parsing.
Migrate your import statements from `const { Symbol } = require('tap-parser');` to `import { Symbol } from 'tap-parser';`. Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json` or using `.mjs` file extensions).Ensure that the input to `Parser.stringify()` is an array of TAP events, typically obtained from a previous call to `Parser.parse()` or a `Parser` instance's `complete` event.
Use the `omitVersion: true` option in the `Parser` constructor or `Parser.parse()` options if you are processing TAP output that includes version declarations within subtest blocks and encountering parsing errors or unexpected behavior.
Only enable `strict` mode if you are certain that your input will be exclusively valid TAP, or if you explicitly want to fail on any non-TAP content. For robustness with potentially mixed output, leave `strict` as `false` (default).
Ensure your Node.js environment meets the specified engine requirements (`node@20` or `node@>=22`) to guarantee compatibility and access to necessary features.
Change `const { Parser } = require('tap-parser');` to `import { Parser } from 'tap-parser';`. If your file is `.js`, ensure `"type": "module"` is set in your `package.json` or rename the file to `.mjs`.Verify that you are using a named import: `import { Parser } from 'tap-parser';`. If in CJS, ensure compatibility shims are in place or that Node.js resolves correctly (which is unlikely post-v10).Ensure named imports are used for static methods: `import { parse } from 'tap-parser';` or `import { Parser } from 'tap-parser'; const result = Parser.parse(data);`Review the input stream to ensure it is valid TAP. If non-TAP diagnostic output is expected, disable `strict` mode by passing `strict: false` to the `Parser` constructor or `Parser.parse()` options.
No dependency data recorded yet.