node --test "no tests found" / Cannot Find Tests - Fix node:test Runner in CI
Node’s built-in test runner (node --test) discovers test files by a fixed set of naming conventions. If your files do not match - or you point it at nothing - it reports no tests and exits, which CI may treat as a silent pass or a failure depending on configuration.
What this error means
node --test runs but reports zero tests (or "cannot find any files"), so a suite you expected to execute never does. Files named outside Node’s default patterns (e.g. not *.test.js / under a test/ dir) are not picked up.
$ node --test
ℹ tests 0
ℹ pass 0
ℹ fail 0
# no test files matched the default patternsCommon causes
Test files do not match the default discovery patterns
Without explicit paths, node --test looks for files matching its conventions (e.g. *.test.*, files under test/). Differently named files are ignored, so nothing runs.
Pointed at the wrong directory or no path
Running the command from the wrong cwd, or relying on defaults that do not match your layout, yields an empty run.
TypeScript tests without a loader
TS test files need a loader (tsx/ts-node) registered; otherwise they are skipped or fail to parse, so the runner finds nothing to execute.
How to fix it
Point the runner at your tests explicitly
Pass the files/globs or use the test directory the runner expects.
# explicit paths
node --test test/
# or a glob (Node 21+ supports --test with patterns)
node --test "src/**/*.test.js"Make TS tests runnable
- Register a loader for TypeScript (
node --import tsx --test ...). - Name test files with a
.testsegment so default discovery finds them. - Run with a non-zero exit on empty if you want CI to fail when no tests match.
How to prevent it
- Follow node:test’s default naming or pass explicit paths.
- Run the test command from the project root.
- Register a loader when testing TypeScript with node:test.