Registry / testing / blue-tape

blue-tape

JSON →
library1.0.0jsnpmunverified

blue-tape is a thin wrapper around the `tape` test runner, designed to integrate promise-based asynchronous testing seamlessly. Released as version 1.0.0 approximately ten years ago, this library automatically handles returned promises from test functions, eliminating the need for explicit `t.plan()` or `t.end()` calls. It also introduces a `t.shouldFail()` assertion (aliased as `t.shouldReject`) for robustly testing promise rejections, optionally asserting on the error type or message. While it provided valuable functionality for promise-driven tests, the project is officially no longer maintained, making it an abandoned solution for modern development workflows. Developers are advised to seek actively maintained alternatives for promise support in `tape` or other testing frameworks. It primarily targets Node.js environments and uses CommonJS module syntax.

npm install blue-tape
INSTALL
IMPORT
SIG · BLUE-TAPE
B
blue-tape
testingjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

test
const test = require('blue-tape');
import test from 'blue-tape';
blue-tape is a CommonJS module and does not natively support ES module imports.
Tape-style assertions
test('description', t => { t.ok(true); });
import { test } from 'blue-tape';
The primary `test` function is the default (and only common) export, not a named export.
t.shouldFail
test('should fail', async t => { await t.shouldFail(promiseThatRejects()); });
`t.shouldFail` (or `t.shouldReject`) is available directly on the test context `t`.

This quickstart demonstrates basic promise-based testing, handling successful promise resolution, deliberate promise rejections causing test failures, and using `t.shouldFail` to assert on expected rejections, including custom error types.

const test = require('blue-tape'); // Simulate an async operation that resolves function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms, 'success')); } // Simulate an async operation that rejects function failDelay(ms = 1) { return new Promise((resolve, reject) => { setTimeout(() => reject(new Error('Failed on purpose!')), ms); }); } // Custom error type for specific rejection testing class DerpError extends Error { constructor(message) { super(message); this.name = 'DerpError'; } } function failWithDerpError(ms = 1) { return new Promise((resolve, reject) => { setTimeout(() => reject(new DerpError('Oh snap!')), ms); }); } test("simple delay - promise resolves, test ends", async function(t) { const result = await delay(1); t.equal(result, 'success', 'delay should resolve with success'); // No t.plan() or t.end() needed when returning a promise }); test("should fail - promise chain throws error, test fails", async function(t) { try { await delay(1).then(function() { throw new Error("This promise chain should cause a test failure!"); }); t.fail('Should have thrown an error'); } catch (e) { t.ok(e instanceof Error, 'Error should be caught'); t.equal(e.message, 'This promise chain should cause a test failure!', 'Correct error message'); } }); test("promise fails but test succeeds using t.shouldFail", async function(t) { // t.shouldFail returns a promise that resolves if the input promise rejects await t.shouldFail(failDelay(), /Failed on purpose!/); t.pass('Promise rejected as expected'); }); test("promise fails with specific error type using t.shouldFail", async function(t) { await t.shouldFail(failWithDerpError(), DerpError); t.pass('Promise rejected with DerpError as expected'); });
Debug
Known issues
breakingThe blue-tape project is officially no longer maintained. This means no further updates, bug fixes, or security patches will be released. Consider migrating to actively maintained alternatives like `tape-promise` or `node-tap` for promise support.
fix
Migrate your test suite to an alternative testing framework or a maintained `tape` wrapper with promise support.
affects: >=1.0.0
gotchaWhen a test function returns a Promise, `blue-tape` automatically waits for its resolution or rejection. This means you should NOT use `t.plan()` or `t.end()` in these tests, as it can lead to unexpected behavior or hangs.
fix
Remove `t.plan()` and `t.end()` calls from any test functions that return a Promise. `blue-tape` manages the test's completion based on the promise's lifecycle.
affects: >=1.0.0
gotcha`blue-tape` is a CommonJS module and does not provide native ES module (ESM) support. Attempting to `import` it in an ESM context will likely result in an error.
fix
Ensure your project is configured for CommonJS, or use dynamic `import()` for ESM projects (`const test = await import('blue-tape');`). The recommended fix, however, is to migrate to a modern, maintained testing library.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/blue-tape/index.js from /path/to/your/test.js not supported.
`blue-tape` is a CommonJS module being imported with ES module `import` syntax or in an ESM-only environment.
fix
Change your import statement to `const test = require('blue-tape');` or configure your project to use CommonJS for test files. For mixed environments, consider dynamic `import()` or migrating to a different test runner.
UnhandledPromiseRejectionWarning: Unhandled promise rejection.
A promise within a test rejected, but the rejection was not caught or returned by the test function, or `t.shouldFail` was not used for expected rejections.
fix
Ensure that test functions either return the promise (allowing `blue-tape` to handle its rejection as a test failure) or explicitly catch rejections. If a rejection is expected, use `t.shouldFail(promise, expectedErrorType, message)`.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
taperequiredCore test runner that blue-tape extends.
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources
blue-tape — npm install blue-tape · libregistry