{"id":13252,"library":"grape","title":"Grape Test Runner","description":"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.","status":"abandoned","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/korynunn/grape","tags":["javascript"],"install":[{"cmd":"npm install grape","lang":"bash","label":"npm"},{"cmd":"yarn add grape","lang":"bash","label":"yarn"},{"cmd":"pnpm add grape","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Grape is a CommonJS module, reflecting its last update in 2017. This is the primary way to import it in Node.js environments.","symbol":"test","correct":"const test = require('grape')"},{"note":"For running a single test, similar to `tape`'s API. This is a common pattern for focused development.","symbol":"test.only","correct":"const test = require('grape'); test.only('focused test', function (t) { /* ... */ });"},{"note":"For temporarily disabling a test without removing its code. Follows the `tape` API.","symbol":"test.skip","correct":"const test = require('grape'); test.skip('skipped test', function (t) { /* ... */ });"}],"quickstart":{"code":"const test = require('grape');\n\ntest('synchronous assertion', function (t) {\n  t.plan(1);\n  const result = 1 + 2;\n  t.equal(result, 3, 'should add numbers correctly');\n});\n\ntest('asynchronous test with timeout', function (t) {\n  t.plan(1);\n  setTimeout(() => {\n    t.ok(true, 'should eventually pass');\n  }, 50);\n});\n\ntest('test with multiple assertions', function (t) {\n  t.plan(2);\n  const arr = [1, 2, 3];\n  t.ok(Array.isArray(arr), 'should be an array');\n  t.deepEqual(arr, [1, 2, 3], 'should have correct contents');\n});\n\n// To run this test: `node your-test-file.js`","lang":"javascript","description":"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`."},"warnings":[{"fix":"Consider migrating to `tape` (https://www.npmjs.com/package/tape) for active maintenance and broader community support. The API is highly compatible.","message":"The 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.","severity":"deprecated","affected_versions":">=1.0.0"},{"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.","message":"Grape 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"The 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.","severity":"breaking","affected_versions":">=1.0.0"},{"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.","message":"The 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.","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":"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.","cause":"Attempting to `require()` 'grape' from an ES Module context, or attempting to `import` 'grape' in a Node.js project configured for ESM.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported. Instead change the require of index.js in ... to a dynamic import() call."},{"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.","cause":"Attempting to use `t` (the test object) as an EventEmitter, for example, `t.on('end', callback)`.","error":"TypeError: t.on is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}