{"id":12899,"library":"blue-tape","title":"blue-tape","description":"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.","status":"abandoned","version":"1.0.0","language":"javascript","source_language":"en","source_url":"git://github.com/spion/blue-tape","tags":["javascript","tape","bluebird","promises"],"install":[{"cmd":"npm install blue-tape","lang":"bash","label":"npm"},{"cmd":"yarn add blue-tape","lang":"bash","label":"yarn"},{"cmd":"pnpm add blue-tape","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core test runner that blue-tape extends.","package":"tape","optional":false}],"imports":[{"note":"blue-tape is a CommonJS module and does not natively support ES module imports.","wrong":"import test from 'blue-tape';","symbol":"test","correct":"const test = require('blue-tape');"},{"note":"The primary `test` function is the default (and only common) export, not a named export.","wrong":"import { test } from 'blue-tape';","symbol":"Tape-style assertions","correct":"test('description', t => { t.ok(true); });"},{"note":"`t.shouldFail` (or `t.shouldReject`) is available directly on the test context `t`.","symbol":"t.shouldFail","correct":"test('should fail', async t => { await t.shouldFail(promiseThatRejects()); });"}],"quickstart":{"code":"const test = require('blue-tape');\n\n// Simulate an async operation that resolves\nfunction delay(ms) {\n  return new Promise(resolve => setTimeout(resolve, ms, 'success'));\n}\n\n// Simulate an async operation that rejects\nfunction failDelay(ms = 1) {\n  return new Promise((resolve, reject) => {\n    setTimeout(() => reject(new Error('Failed on purpose!')), ms);\n  });\n}\n\n// Custom error type for specific rejection testing\nclass DerpError extends Error {\n  constructor(message) {\n    super(message);\n    this.name = 'DerpError';\n  }\n}\n\nfunction failWithDerpError(ms = 1) {\n    return new Promise((resolve, reject) => {\n        setTimeout(() => reject(new DerpError('Oh snap!')), ms);\n    });\n}\n\ntest(\"simple delay - promise resolves, test ends\", async function(t) {\n    const result = await delay(1);\n    t.equal(result, 'success', 'delay should resolve with success');\n    // No t.plan() or t.end() needed when returning a promise\n});\n\ntest(\"should fail - promise chain throws error, test fails\", async function(t) {\n    try {\n        await delay(1).then(function() {\n            throw new Error(\"This promise chain should cause a test failure!\");\n        });\n        t.fail('Should have thrown an error');\n    } catch (e) {\n        t.ok(e instanceof Error, 'Error should be caught');\n        t.equal(e.message, 'This promise chain should cause a test failure!', 'Correct error message');\n    }\n});\n\ntest(\"promise fails but test succeeds using t.shouldFail\", async function(t) {\n    // t.shouldFail returns a promise that resolves if the input promise rejects\n    await t.shouldFail(failDelay(), /Failed on purpose!/);\n    t.pass('Promise rejected as expected');\n});\n\ntest(\"promise fails with specific error type using t.shouldFail\", async function(t) {\n    await t.shouldFail(failWithDerpError(), DerpError);\n    t.pass('Promise rejected with DerpError as expected');\n});\n","lang":"javascript","description":"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."},"warnings":[{"fix":"Migrate your test suite to an alternative testing framework or a maintained `tape` wrapper with promise support.","message":"The 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.","severity":"breaking","affected_versions":">=1.0.0"},{"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.","message":"When 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"`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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"`blue-tape` is a CommonJS module being imported with ES module `import` syntax or in an ESM-only environment.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/blue-tape/index.js from /path/to/your/test.js not supported."},{"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)`.","cause":"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.","error":"UnhandledPromiseRejectionWarning: Unhandled promise rejection."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}