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-runVerified import paths — ran on the pinned version, not inferred.
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.
Upgrade your Node.js environment to version 14 or higher.
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.
Upgrade to `tape-run@8.0.0` or higher immediately to mitigate potential Electron security vulnerabilities. Always keep Electron and its dependencies updated.
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.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.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.
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.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.