Test Explorer for uvu
See and run your uvu tests in the VS Code Testing view. Every
suite('Name') becomes a group, every test('name', ...) and Name('name', ...) gets a play button in the
editor gutter, and every failing assertion is shown at the line where it failed, with an expected/actual diff.
uvu is fast and small, and its report is small too: a dot or a cross per test, and the full story only for the
tests that failed. That is fine in a terminal, but in the editor you want to know which test is which, run just the
one you are working on, and jump to the failing assert.equal. This extension reads your test files, runs them with
the Node.js and uvu already in your project, and puts the results where you are working.
Features
- Suites and tests appear without running anything. Files matching the include patterns (by default
test/**,
tests/**, __tests__/** and *.test.* / *.spec.*) that import or require uvu are read as you type.
const S = suite('Name'), S('test', ...), S.only(...), S.skip(...) and tests of uvu's default suite
(test('name', ...)) become items in the tree. Local names are followed: import { suite as describe },
import { test as it }, import * as uvu from 'uvu' with uvu.suite(...), and suite<Context>('Name') in TypeScript.
Helper files that use uvu but declare no tests are left out.
- Run a file, a suite or a single test from the Testing view or the gutter. A single suite or test really runs
on its own: the other suites and tests in that file are not started (and their hooks do not run).
- Per-test results. Passed, failed and skipped are shown for every test, with its duration. Tests written with
.skip are shown as skipped, and when a suite uses .only, its other tests are shown as skipped too.
- Failures where they happened.
assert.is, assert.equal, assert.type, assert.snapshot, assert.fixture
(and Node's assert.strictEqual / deepStrictEqual) open the diff view with expected and actual values. Other
errors show their message, uvu's own diff text and the stack, at the line in your test file.
- Hook errors are not lost. uvu silently drops an error thrown by a suite's
before hook (the suite just shows
0 passed). Here the suite's tests are marked as errored with that error. An error in an after hook (which stops
the run) is shown on the suite, and an error in before.each / after.each on the test it belongs to.
- Crashes are explained. If a test throws asynchronously and takes the process down, or never finishes, that test
is marked as errored with the error output, and the tests that finished before it keep their results.
- Tests named at runtime (for example
S(`square of ${n}`, ...) in a loop) appear after the first run and can
then be run on their own.
- CommonJS, ES modules and TypeScript (through the loader you already use, see
nodeArgs).
- Debug: 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
Each test file is run on its own with Node.js (node <your nodeArgs> <file>), the same way uvu runs a file you start
directly; up to four files run at the same time. Node.js is given a small preload script (--require) that patches
uvu's internal suite runner as uvu loads (for require('uvu') directly, for import 'uvu' through Node's module
hooks). The patched runner does exactly what uvu's runner does and prints exactly the same report, which you see in
the Test Results panel, but it also notes in a temporary file which test started, passed or failed, with the error's
expected and actual values. The same script is what lets a single suite or test run on its own.
If the patch cannot be applied (for example a future uvu release changes its internals), the extension falls back to
reading uvu's printed report: failures are matched by suite and test name, and passing tests are taken from the
source when the counts on uvu's summary line agree. Single tests then run with the whole file. --enable-source-maps
is added so that TypeScript line numbers point at your source.
Nothing is sent anywhere: the extension only starts Node.js on your machine, and only in trusted workspaces.
Requirements
uvu installed in your project (tested with uvu 0.5.6, the current release).
- Node.js on your
PATH, or set uvuTestExplorer.nodePath. ES module test files need Node.js 18.19 / 20.6 or newer
for per-test results (older versions fall back to reading the report).
Settings
| Setting |
Default |
What it does |
uvuTestExplorer.include |
test/**, tests/**, __tests__/**, **/*.{test,spec}.* (JS and TS extensions) |
Where to look for test files, relative to each workspace folder. |
uvuTestExplorer.exclude |
["**/node_modules/**"] |
Files never to show. |
uvuTestExplorer.nodePath |
node |
Node.js used to run a test file. |
uvuTestExplorer.nodeArgs |
[] |
Extra Node.js arguments before the file, e.g. ["-r", "tsm"], ["--import", "tsx"] or ["--loader", "tsm"]. Use the loader you pass to uvu -r. |
uvuTestExplorer.env |
{} |
Extra environment variables. |
uvuTestExplorer.singleTest |
filter |
filter runs only the chosen suites and tests. wholeFile runs the whole file and reports only the chosen ones; use it when tests depend on earlier tests. |
Tests run in the folder whose node_modules holds uvu (else the nearest package.json). Command:
uvu: Refresh uvu tests reads everything again.
Known limitations
- Files are run one by one with
node, not through the uvu command, so options of that command (--bail,
--ignore, its own -r) are not used; put loaders in nodeArgs instead.
- uvu only counts
.skip tests; their names come from the extension's patch or from the source. A test that is
skipped by a name built at runtime is shown only when the patch is active.
- When a suite uses
.only, running one of its other tests shows it as skipped, as uvu would.
- Two suites with the same name in one file, or two tests with the same name in one suite, are shown as one item,
and their results are combined.
- A suite whose name is built at runtime, or whose tests are added from helper functions, shows its tests only after
the first run. Suites created by a helper in another file are not found before a run.
- A suite that is never
.run() has no results.
- With
filter, a test that depends on state left by an earlier test of the same suite may behave differently;
use wholeFile then.
- Debugging has been checked less than normal runs.
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 uvu authors and is not affiliated with the uvu project or Luke Edwards. It was built with
AI assistance by Honestrel and is checked by automated tests against a real uvu install, including a run inside
VS Code.
| |