Skip to content
Latchkey

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 output
$ node --test
ℹ tests 0
ℹ pass 0
ℹ fail 0
# no test files matched the default patterns

Common 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.

Terminal
# explicit paths
node --test test/

# or a glob (Node 21+ supports --test with patterns)
node --test "src/**/*.test.js"

Make TS tests runnable

  1. Register a loader for TypeScript (node --import tsx --test ...).
  2. Name test files with a .test segment so default discovery finds them.
  3. 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →