Appearance
test.mjs
Collects every *.test.mjs file under test/ and runs it through Node's own test runner, in an exclusive phase and a parallel phase.
Contributor tooling › test.mjs
What it does
Collects every *.test.mjs file under test/, or under TEST_GLOB_DIR when that environment variable is set, skipping test/ui unless TEST_GLOB_DIR is set. Splits the collection into an exclusive phase (test/perf, test/build) run one file at a time, and a parallel phase for everything else, running the exclusive phase first. Exits non-zero when either phase fails, or when no test file is collected at all.
Usage
The npm alias:
bash
npm testDirect invocation:
bash
node tools/test.mjsOptions
| Flag | Value | What it does | Default |
|---|---|---|---|
--ui | none | Runs test/ui alone instead of the rest of the tree, under the tsx loader and --test-force-exit at concurrency 4; takes precedence over TEST_GLOB_DIR. | off, test/ui is skipped and every other directory runs |
Inputs and outputs
Reads the test/ tree (or TEST_GLOB_DIR) for *.test.mjs files, and the TEST_GLOB_DIR environment variable itself. Writes nothing directly; every assertion and effect belongs to the collected tests, which this tool only hands to node --test.
Exits 1 immediately when zero test files are collected, before running anything. Otherwise it runs the exclusive phase, then the parallel phase, and exits with whichever of the two carries a failure; it exits 0 only when both phases pass.
Examples
Run the full suite locally, the same step the gate runs:
bash
npm testRun one directory's tests while iterating on it, bypassing the rest of the tree:
bash
TEST_GLOB_DIR=test/tools npm testNotes
The exclusive phase covers only test/perf and test/build, one file at a time, and finishes before the parallel phase starts. Every other directory, including a handful of guard files under test/browser, runs in the parallel phase at Node's default concurrency.
test/ui is skipped by default: its .jsx panel imports need the tsx loader npm run test:ui provides, which plain node --test cannot load. Setting TEST_GLOB_DIR turns that skip off entirely, so pointing it at a tree that reaches into test/ui fails under this runner.
test/browser's and test/devloop's own suites (*.spec.mjs, run by npm run test:browser and npm run test:devloop) sit beside this tool rather than inside it: it only ever collects *.test.mjs.
Source
tools/test.mjs — part of Contributor tooling