Registry / testing / grape
library0.2.5jsnpmunverified

Grape is a JavaScript test library, inspired by and largely API-compatible with Substack's `tape`. It was created to address a specific behavior in `tape` where `t.plan()` combined with fewer assertions than planned, followed by `t.end()`, would still pass. The original README indicates this behavior was eventually fixed in `tape` itself, rendering `grape`'s primary differentiator largely obsolete. The package, currently at version 1.0.3, has not seen updates since 2017, suggesting it is no longer actively maintained. It aims to be 'swap-out-able' with `tape`, though it notes a deeper difference in that a `grape` test instance does not inherit from `EventEmitter`. Due to its age and lack of maintenance, it is primarily a CommonJS module, and its stability was described as 'whipped up in a few hours' even at its inception.

npm install grape
INSTALL
IMPORT
SIG · GRAPE
G
grape
testingjavascriptv0.2.5
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('grape')
Grape is a CommonJS module, reflecting its last update in 2017. This is the primary way to import it in Node.js environments.
test.only
const test = require('grape'); test.only('focused test', function (t) { /* ... */ });
For running a single test, similar to `tape`'s API. This is a common pattern for focused development.
test.skip
const test = require('grape'); test.skip('skipped test', function (t) { /* ... */ });
For temporarily disabling a test without removing its code. Follows the `tape` API.

This quickstart demonstrates basic synchronous and asynchronous testing patterns using Grape's `tape`-like API, including `t.plan`, `t.equal`, `t.ok`, and `t.deepEqual`.

const test = require('grape'); test('synchronous assertion', function (t) { t.plan(1); const result = 1 + 2; t.equal(result, 3, 'should add numbers correctly'); }); test('asynchronous test with timeout', function (t) { t.plan(1); setTimeout(() => { t.ok(true, 'should eventually pass'); }, 50); }); test('test with multiple assertions', function (t) { t.plan(2); const arr = [1, 2, 3]; t.ok(Array.isArray(arr), 'should be an array'); t.deepEqual(arr, [1, 2, 3], 'should have correct contents'); }); // To run this test: `node your-test-file.js`
Debug
Known issues
deprecatedThe primary bug that 'grape' was created to fix in 'tape' (incorrect `t.plan()` behavior) has been resolved in `tape` itself. This makes `grape` largely redundant, and `tape` is the actively maintained alternative.
fix
Consider migrating to `tape` (https://www.npmjs.com/package/tape) for active maintenance and broader community support. The API is highly compatible.
affects: >=1.0.0
gotchaGrape test instances do not inherit from `EventEmitter`, which is a fundamental difference from `tape`. This might lead to unexpected behavior or incompatibility if relying on event-driven patterns with test objects.
fix
Avoid treating `t` (the test object) as an `EventEmitter`. If `EventEmitter` functionality is required, `tape` is the appropriate choice, or a different testing framework.
affects: >=1.0.0
breakingThe package is abandoned, with the last commit in 2017 and no updates since. It does not support modern JavaScript features like ESM modules natively and is unlikely to receive security patches or bug fixes.
fix
Do not use in new projects. For existing projects, plan for migration to a currently maintained testing framework to avoid potential vulnerabilities, compatibility issues, and to leverage modern JavaScript features.
affects: >=1.0.0
gotchaThe project was 'whipped up in a few hours' and explicitly notes that it 'isn't quite the same at a deeper level' than `tape`. This suggests potential underlying instabilities or edge-case inconsistencies that may not be immediately apparent.
fix
Thoroughly review and test any existing codebases using `grape`. Migrate to a more stable and maintained testing framework if any unexpected behavior is encountered.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported. Instead change the require of index.js in ... to a dynamic import() call.
Attempting to `require()` 'grape' from an ES Module context, or attempting to `import` 'grape' in a Node.js project configured for ESM.
fix
Grape is a CommonJS module. Ensure your test files or runner are configured for CommonJS (`.js` files without `"type": "module"` in `package.json`, or explicitly using `require`). If ESM is strictly required, migration to `tape` (which has better ESM compatibility, often via `--experimental-modules` or transpilation) is recommended.
TypeError: t.on is not a function
Attempting to use `t` (the test object) as an EventEmitter, for example, `t.on('end', callback)`.
fix
Grape's test instances do not inherit from `EventEmitter`. Avoid using `EventEmitter` methods directly on the `t` object. If this functionality is crucial, migrate to `tape` which does provide `EventEmitter` capabilities on its test objects.
Upgrade
Version history
0.2.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources