tape

raw JSON →
5.9.0 verified Sat Apr 25 auth: no javascript

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.

error TypeError: test is not a function
cause Incorrect import: using named import instead of default import in ES modules.
fix
Use import test from 'tape' (no curly braces).
error AssertionError: plan !== count
cause t.plan() count does not match number of assertions executed.
fix
Ensure t.plan(N) matches the total expected assertions, or replace with t.end() for dynamic counts.
breaking tape v5 dropped Node.js < 12 support and switched to ES modules internally
fix Upgrade to Node.js >= 12, ensure CJS require pattern still works but check for any import/export changes.
deprecated tape v4 deprecated the 'skip' option on test function in favor of test.skip()
fix Use test.skip(name, cb) instead of test(name, {skip: true}, cb)
gotcha tape's 't.plan()' must match number of assertions; mismatch causes failure at test end
fix Always call t.plan(count) where count equals all assertions (including nested callbacks). Use t.end() if plan is hard to predict.
npm install tape
yarn add tape
pnpm add tape

Shows synchronous and async tests with plan, assertions equal and ok.

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)