tape
raw JSON →TAP-producing test harness for Node.js and browsers. Current stable version is 5.9.0, released in July 2024. Tape is a minimal, dependency-light testing library that outputs standard TAP (Test Anything Protocol) format, making it compatible with many reporters and CI systems. It supports both CommonJS and ES modules in Node.js, works in browsers via bundlers, and includes built-in async/Promise support. Unlike heavier frameworks like Jest or Mocha, tape has no global state, no configuration, and a single assert API inspired by the Node.js assert module. It is unopinionated about test organization and does not require describe/it nesting; tests are simply functions. Tape is ideal for projects that want a simple, composable, and predictable test harness with minimal setup.
Common errors
error TypeError: test is not a function ↓
import test from 'tape' (no curly braces). error AssertionError: plan !== count ↓
Warnings
breaking tape v5 dropped Node.js < 12 support and switched to ES modules internally ↓
deprecated tape v4 deprecated the 'skip' option on test function in favor of test.skip() ↓
gotcha tape's 't.plan()' must match number of assertions; mismatch causes failure at test end ↓
Install
npm install tape yarn add tape pnpm add tape Imports
- test wrong
import { test } from 'tape'correctimport test from 'tape' - test wrong
const { test } = require('tape')correctconst test = require('tape') - Test
import { Test } from 'tape'
Quickstart
import test from 'tape';
test('basic arithmetic', function(t) {
t.plan(2);
t.equal(1 + 1, 2);
t.ok(true, 'this is true');
});
test('async test', async function(t) {
t.plan(1);
const result = await Promise.resolve(42);
t.equal(result, 42, 'promise resolved correctly');
});
// Run: node test.js (or: tape test.js)