Nifty JS Tests: Mocha, node:test & Bun in Test Explorer
Run and debug Mocha, node:test and Bun tests from the Test Explorer: real diffs, stack locations, watch mode, TypeScript loaders and monorepos. No Jest or Vitest.
Maintained. No sign-in. No telemetry. Works in VS Code, Cursor, Windsurf, VSCodium and other editors that use Open VSX.
Features


- Three runners, one Test Explorer. Mocha (BDD and TDD), Node's built-in
node:test and bun test, side by side. Each package in a monorepo (npm, Yarn, pnpm or Bun workspaces) gets its own node with the runner it uses.
- Tests appear as you type. Discovery reads your files without running them:
describe / it / test / suite / context nesting, .only, .skip, .todo, test.each tables and template-literal names. After a run, tests that only exist at run time (loops, .each rows) show up under the line that declares them.
- Real failures. Assertion errors from
node:assert, Chai and expect open VS Code's diff view of expected and actual values, at the line in your test that failed (the stack is mapped back to your source, TypeScript included).
- Run exactly what you click. A file, a suite or one test, with the right filter for each runner (Mocha
--grep, --test-name-pattern, bun test -t). Mocha runs only the file you picked even when .mocharc lists every spec file.
- Debug Mocha and node:test tests with VS Code's JavaScript debugger: breakpoints in tests and in your code, child processes attached. Bun tests debug through Bun's own extension.
- Watch mode. Click the eye in the Test Explorer (or run Toggle Watch Mode): a changed test file reruns its tests, any other change reruns everything you're watching.
- Your setup, not ours. Reads
.mocharc.*, the mocha section of package.json, your test script (node --import tsx --test …, bun test ./src) and bunfig.toml. TypeScript runs through the loader your project already uses: tsx, ts-node, @swc-node/register, Node's type stripping, or Bun itself.
- Rerun Failed Tests in one click, and Run Test at Cursor from the editor's context menu.
Which projects it picks up
| Runner |
Detected from |
Test files |
| Mocha |
mocha in the test script, a .mocharc.* file, a mocha section or dependency |
The spec setting from your Mocha config (default ./test/*.{js,cjs,mjs}) |
| node:test |
node --test in the test script, or files that import node:test |
The globs in your test script, else Node's defaults (**/*.test.js, **/test/**/*.js…) |
| Bun |
bun test in the test script, bunfig.toml, bun.lock, @types/bun, or files that import bun:test |
*.test.*, *_test.*, *.spec.*, *_spec.*, or the paths in your test script |
Set nifty.js-tests.runner for a folder if the guess is wrong.
Jest and Vitest aren't handled here, on purpose: they already have good, maintained extensions (the official Vitest extension, and Jest Runner / the Jest extension). Packages that use them are skipped, so the two never show the same tests twice.
Nifty JS Tests, Nifty Run and Nifty Code Runner
Nifty Run lists and runs your npm test and other scripts as a whole; Nifty Code Runner runs the current file. Nifty JS Tests goes inside the test suite: every test is an item you can run, debug and see the result of, with diffs and locations.
Commands
| Command |
What it does |
Nifty JS Tests: Refresh Tests |
Find tests again |
Nifty JS Tests: Run All Tests |
Run every test in the workspace |
Nifty JS Tests: Debug All Tests |
The same, under the debugger |
Nifty JS Tests: Run Tests in File |
Run the current test file |
Nifty JS Tests: Run Test at Cursor |
Run the test or suite the cursor is in |
Nifty JS Tests: Rerun Failed Tests |
Run only the tests that failed last time |
Nifty JS Tests: Toggle Watch Mode |
Rerun tests whenever a JavaScript or TypeScript file changes |
Nifty JS Tests: Show Log |
What was detected and the exact commands run |
Settings
| Setting |
Default |
What it does |
nifty.js-tests.runner |
auto |
auto, mocha, node or bun, per folder |
nifty.js-tests.nodePath |
"" |
Node for Mocha and node:test. Empty: node on your PATH, or the editor's own Node |
nifty.js-tests.bunPath |
"" |
Bun executable. Empty: bun on your PATH |
nifty.js-tests.nodeArgs |
[] |
Extra Node flags, e.g. ["--import", "tsx"] |
nifty.js-tests.extraArgs |
{} |
Extra arguments per runner, e.g. { "mocha": ["--timeout", "10000"] } |
nifty.js-tests.env |
{} |
Environment variables for test runs |
nifty.js-tests.watchDelay |
400 |
Milliseconds to wait after a change before a watch run |
nifty.js-tests.autoDiscover |
true |
Find tests when the workspace opens |
Good to know
- Tests run with your project's own Mocha (from
node_modules) and your Node or Bun, never a bundled copy.
- Test names built at run time from variables (
it(name, …)) show up after the first run.
- Debugging Bun tests needs Bun's official extension; running them doesn't.
Install
- VS Code: search for "Nifty JS Tests" in the Extensions view, or install from the Visual Studio Marketplace.
- Cursor, Windsurf, VSCodium, Kiro, Antigravity: install from Open VSX.
Privacy
This extension collects no telemetry and needs no account.
- Nifty pytest: pytest Test Explorer: A pytest test explorer with saved run configurations, marker filters, real assertion diffs, rerun-failed and slowest-test reports. (Open VSX)
- Nifty .NET Explorer: Solution & Test Explorer: A solution explorer and test explorer for .NET in VS Code, Cursor, Windsurf and VSCodium: projects, references and files from .sln/.slnx, and xUnit, NUnit and MSTest tests in the Testing view. (Open VSX)
- Nifty Code Runner: Run Code in 25+ Languages: Run the current file or selection in 25+ languages in the terminal, with input support, your own commands and no telemetry. (Open VSX)
- Nifty Import Cost: Bundle Size of Imports: See the bundle size of every import inline, fast and cached, without maxing out your CPU. (Open VSX)
- Nifty Problems: Project-Wide TypeScript Errors: See TypeScript and ESLint errors for your whole project in the Problems panel, not just open files. (Open VSX)
- Nifty Python Profiler: cProfile Hotspots Inline: Profile Python scripts and pytest runs with cProfile: hotspot table, call counts and timings inline next to each function. (Open VSX)
See all 100+ Nifty extensions and web tools at https://getnifty.dev
| |