Registry / testing / tape-run

tape-run

JSON →
library11.0.0jsnpmunverified

tape-run is a utility designed to execute JavaScript tests written with the `tape` testing framework within a headless browser environment. It is primarily used for continuous integration workflows and as a standard `npm test` script. The current stable version is 11.0.0, with releases occurring semi-regularly to address dependencies, security updates, and minor feature enhancements. Its core functionality involves taking a bundled test file (typically created using build tools like Browserify, Rollup, or Webpack) via a standard Unix pipe, executing these tests in a chosen headless browser (defaulting to Electron), and then streaming the TAP (Test Anything Protocol) results to standard output while returning an appropriate exit code. Key differentiators include its simple pipe-based API, deep integration with `tape`, and flexible support for various browser environments without requiring complex browser automation setups.

npm install tape-run
INSTALL
IMPORT
SIG · TAPE-RUN
T
tape-run
testingjavascriptv11.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.

run
const run = require('tape-run');
import run from 'tape-run';
`tape-run` is a CommonJS package; direct ESM `import` is not supported for its main API. Use `require` or dynamic import for compatibility.
run([opts])
const tapeRun = require('tape-run'); // ... bundle().pipe(tapeRun({ browser: 'chrome', wait: 2000 }))
The main export is a function that accepts an options object to configure browser selection, timeout, static file serving, and other behaviors.

Demonstrates how to programmatically bundle a Tape test file with Browserify and execute it in a headless browser via tape-run, outputting both raw TAP and parsed results.

const browserify = require('browserify'); const run = require('tape-run'); const path = require('path'); const fs = require('fs'); // Create a simple Tape test file dynamically for this example const testContent = ` const test = require('tape'); test('a simple tape-run test', function (t) { t.plan(1); t.ok(true, 'This assertion should pass'); }); `; const tempTestFilePath = path.join(__dirname, 'temp-tape-test.js'); fs.writeFileSync(tempTestFilePath, testContent); browserify(tempTestFilePath) .bundle() .pipe(run({ browser: 'electron', // Explicitly use electron, the default headless browser wait: 2000 // Increase wait time for results if tests are slow or numerous })) .on('results', (parsedResults) => { console.log('Parsed TAP results:', JSON.stringify(parsedResults, null, 2)); // Clean up the temporary test file fs.unlinkSync(tempTestFilePath); }) .pipe(process.stdout) // Also pipe raw TAP output to console .on('end', () => { console.log('\nTest run completed.'); });
tape-run --version
Debug
Known issues
breakingVersion 11.0.0 introduced a minimum Node.js engine requirement of `>=14`. Older Node.js versions are no longer officially supported and may lead to installation or runtime issues.
fix
Upgrade your Node.js environment to version 14 or higher.
affects: >=11.0.0
breakingIn version 10.0.0, the underlying CLI argument parser was switched from `optimist` to `yargs`. While largely compatible, users relying on specific `optimist` behaviors or advanced CLI configurations might encounter subtle differences.
fix
Review CLI argument parsing if migrating from versions <10.0.0 and encountering unexpected behavior with command-line flags. Refer to `yargs` documentation for advanced usage.
affects: >=10.0.0
breakingVersion 8.0.0 included a crucial update to `browser-run` to address an Electron security vulnerability. Older versions of `tape-run` (prior to v8.0.0) running tests in Electron may be exposed to security risks, especially if `nodeIntegration` is enabled and untrusted content is loaded.
fix
Upgrade to `tape-run@8.0.0` or higher immediately to mitigate potential Electron security vulnerabilities. Always keep Electron and its dependencies updated.
affects: <8.0.0
gotchaTests occasionally finish prematurely or report incomplete results, often indicated by messages like 'TAP finished without all tests being reported'. This usually means `tape-run`'s internal timeout (`wait` option) was too short for the tests to complete.
fix
Increase the `wait` option in `tape-run` (e.g., `tapeRun({ wait: 5000 })` or `tape-run --wait 5000`) to allow more time for all test assertions to complete and be reported, especially for asynchronous or numerous tests.
affects: >=1.0.0
gotchaWhen running tests that depend on Node.js-specific globals (like `process`, `Buffer`, `__dirname`) in a browser environment without proper handling, `tape-run` will encounter `ReferenceError` or similar issues.
fix
Use a bundler like Browserify with appropriate shims (`browserify-shim` or similar) or Webpack to correctly polyfill or mock Node.js globals for browser execution. For Electron specifically, consider enabling the `node` option (`tapeRun({ node: true })`) if your tests truly require Node.js integration within the Electron renderer process, but be aware of security implications with untrusted content.
affects: >=1.0.0
Errors
Common errors & fixes
Error: spawn <browser_executable> ENOENT
The specified headless browser (e.g., `electron`, `chrome`, `firefox`) is not installed or not found in the system's PATH. This error indicates 'No Entry' for the executable.
fix
Ensure the desired browser (e.g., Electron, Chrome) is correctly installed and its executable is accessible via your system's PATH. For example, if using `chrome`, ensure `google-chrome` or `chromium-browser` is installed and symlinked.
TAP finished without all tests being reported
One or more tests did not complete or report their results within the default or configured `wait` timeout, causing `tape-run` to conclude prematurely.
fix
Increase the `wait` option value (e.g., `tape-run --wait 5000` or `run({ wait: 5000 })`) to give tests more time to execute and report their output. Also, ensure all `tape` tests call `t.end()` or `t.plan()` to explicitly signal completion.
ReferenceError: require is not defined
Attempting to use `require()` or other Node.js-specific features in tests running in a browser environment without them being bundled or polyfilled by a tool like Browserify.
fix
Ensure your test files are correctly bundled with a tool like Browserify before piping to `tape-run`. Bundlers transform `require()` calls into browser-compatible code. If testing Node.js-specific code, you may need shims or to use the `node: true` option with Electron.
Upgrade
Version history
11.0.0latest on npm
Audit
Dependencies
taperequiredThe primary testing framework `tape-run` is designed to execute tests for. Essential for test authoring.
browserifyoptionalCommonly used bundler to prepare browser-compatible test bundles for `tape-run` CLI or API. Not a direct dependency but almost always used together.
rollupoptionalAlternative bundler to prepare browser-compatible test bundles for `tape-run` CLI. Not a direct dependency but often used together.
webpackoptionalAlternative bundler, often used with `webpack-tape-run` plugin, to prepare browser-compatible test bundles for `tape-run`. Not a direct dependency but often used together.
Agent activity
5 hits · last 30 days
node
4
Resources
tape-run — npm install tape-run · libregistry