API Reference

node-tap

A Test Anything Protocol library for Node.js with coverage, TypeScript support, and a flexible runner.

Official Documentation ↗
CompatibilityThis documentation covers version v18. Check the official docs for the latest API surface.

Installation

npmnpm install --save-dev tap

Methods

node-tap emits TAP output so results can be consumed by any TAP reporter while offering rich assertions.

Key Features

  • TAP output consumable by any reporter
  • Built-in coverage and TypeScript support
  • Subtest nesting for structured output

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

Errors

The following points are quoted verbatim from the official documentation. 来源:https://node-tap.org/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:52:51.906Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

  • Basic TAP generation and flow control, error handling, config loading, and process management are all included in the core. (https://node-tap.org/)
  • High Signal, Low Noise It is important to give a lot of information about test failures, throws, and so on, so that you can easily jump straight to the appropriate place in the code to fix the problem. (https://node-tap.org/)
  • Assertions don’t throw (but throws are handled nicely) I frequently write programs that have many hundreds of assertions based on some list of test cases. (https://node-tap.org/)

Security notes

Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://node-tap.org/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:52:51.906Z.

  • Software tests should be a security blanket and a quality ratchet, giving you the support to undertake massive refactoring and fix bugs without worrying. (https://node-tap.org/)

FAQ

What is TAP?
The Test Anything Protocol is a plain-text format any reporter can parse, which decouples your tests from a single toolchain.
How do I get coverage?
tap enables coverage by default through the built-in coverage map; run tap --coverage-report=html for a browsable report.
Why use t.plan?
It helps catch tests that finish before async assertions run, because TAP flags a mismatch between planned and actual assertion counts.