TAP Parser

18.3.3 · active · verified Tue Apr 21

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.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates piping a simulated TAP stream into a Parser instance and logging the complete results object, showing basic stream-based parsing.

import { Parser } from 'tap-parser';
import { pipeline } from 'stream/promises';

async function parseTapStream() {
  const results = [];
  const p = new Parser(r => results.push(r));

  // Simulate a TAP stream input
  const tapInput = `TAP version 14\n# beep\nok 1 should be equal\nok 2 should be equivalent\n# boop\nok 3 should be equal\nok 4 (unnamed assert)\n1..4\n# tests 4\n# pass 4\n# ok`;

  const readableStream = new (await import('stream')).Readable({
    read() {
      this.push(tapInput);
      this.push(null);
    }
  });

  await pipeline(readableStream, p);

  console.dir(results[0]); // The 'complete' event result
}

parseTapStream().catch(console.error);

view raw JSON →