Test Explorer for tape
See and run your tape tests in the VS Code Testing view. Each
test('name', ...) gets a play button in the editor gutter, nested t.test(...) calls show up as children,
and every failing assertion is shown at the line where it failed, with an expected/actual diff.
tape keeps things simple: a test file is just a Node.js script that prints TAP. That is great on the command line,
but in the editor you usually end up scrolling through terminal output to find which t.deepEqual broke.
This extension reads your test files, runs them with the tape already installed in your project, and puts the
results where you are working.
Features
- Tests appear without running anything. Files matching the include patterns (by default
test/**,
tests/** and *.test.js / .cjs / .mjs) that use tape are read as you type. Helper files without tests,
and test files of other runners in projects without tape, are left out. Calls such as test('…'), tape('…'),
test.only('…'), test.skip('…') and nested t.test('…') become items in the tree. The local name you give
tape (const check = require('tape'), import { test as it } from 'tape') is recognised too.
- Run a file or a single test from the Testing view or the gutter. A single top-level test really runs on its
own: the other top-level tests in that file are not started. A nested test runs together with the top-level test
that contains it.
- Failures where they happened. Every failing assertion becomes its own message at the failing line.
t.equal, t.deepEqual and friends open the diff view with expected and actual values, formatted the way tape
prints them. A parent test that only failed because of a child does not repeat the message.
- Crashes are explained. If a test throws and takes the process down, that test is marked as errored at the
line that threw, with the error output, and the tests that finished before it keep their results.
- Tests named at runtime (for example
test(`square of ${n}`, ...) in a loop) appear after the first run.
test.skip tests are shown as skipped. CommonJS and ESM (.mjs, "type": "module") test files both work.
- Debug (preview): the Debug profile starts the same run under VS Code's built-in JavaScript debugger, so you
can stop at breakpoints in your tests and code; results are shown when the debug session ends.
How it works
tape prints flat TAP: a # name line when a test starts, then its assertions, with nothing that says which test is
nested in which. To get this right, the extension starts your project's node_modules/tape/bin/tape with Node.js
and preloads a small script (--require) that notes, in a temporary file, which test each assertion belongs to.
The same script is what lets a single test run on its own. It does not change what tape prints; the full TAP output
is shown in the Test Results panel.
When you use a custom command, the script is passed through NODE_OPTIONS. If it cannot load (for example the command
does not start Node.js), the extension falls back to reading the TAP output and matching the # name lines to the
tests it found in your file. Single tests then run with the whole file, and only the chosen test is reported.
Nothing is sent anywhere: the extension only starts tape on your machine.
Requirements
tape installed in your project (tested with tape 5.10). Older versions may work but are not tested.
- Node.js on your
PATH, or set tapeTestExplorer.nodePath.
Settings
| Setting |
Default |
What it does |
tapeTestExplorer.include |
["test/**/*.{js,cjs,mjs,ts}", "tests/**/*.{js,cjs,mjs,ts}", "**/*.test.{js,cjs,mjs}"] |
Where to look for test files, relative to each workspace folder. |
tapeTestExplorer.exclude |
["**/node_modules/**"] |
Files never to show. |
tapeTestExplorer.command |
[] |
Command that starts tape, e.g. ["npx", "tape"]. Empty: the project's own node_modules/tape. |
tapeTestExplorer.nodePath |
node |
Node.js used when command is empty. |
tapeTestExplorer.args |
[] |
Extra tape arguments, e.g. ["-r", "ts-node/register"] for TypeScript tests. |
tapeTestExplorer.env |
{} |
Extra environment variables. |
tapeTestExplorer.singleTest |
filter |
filter runs only the chosen top-level test. wholeFile runs the whole file and reports only the chosen test; use it when your tests depend on a "setup" test that runs first. |
Command: tape: Refresh tape tests reads everything again.
Known limitations
- tape has no name filter of its own, so single-test runs depend on the preloaded script. With the default
filter
mode, top-level tests the chosen test depends on (such as a test('setup', ...)) are not run; switch to
wholeFile if your files work that way.
- Test files are run one at a time per file (up to four files in parallel), not in one tape process.
- Two tests with exactly the same name under the same parent are shown as one item, and their results are combined.
- A test whose name is built at runtime cannot be run on its own before the first run has shown it.
- TypeScript test files need a loader in
tapeTestExplorer.args (or a Node.js version that runs .ts files).
- Debugging is a preview and has not been checked on every platform yet.
Feedback
Problems and ideas are welcome on the Marketplace page (Q & A or rating). This is an independent extension: it is not
an official product of the tape authors and is not affiliated with the tape project. It was built with AI assistance
by Honestrel and is checked by automated tests against a real tape install, including a run inside VS Code.
| |