node --test Glob Pattern Matches Nothing - Fix Shell-Expanded Globs in CI
When you pass a glob to node --test, the shell may expand it before Node sees it - or expand it to nothing and pass the literal pattern. Node’s built-in glob support also depends on the version. The result is the runner getting paths that match no files.
What this error means
node --test "src/**/*.test.js" runs no tests, or errors that the literal pattern is not a file. Either the shell consumed the glob, or an older Node did not interpret the pattern itself, so nothing matched.
$ node --test src/**/*.test.js
Could not find 'src/**/*.test.js'
# the shell did not expand it and Node got the literal stringCommon causes
The shell expanded or mangled the glob
An unquoted glob is expanded by the shell. With nullglob off, a non-matching pattern is passed literally; with globstar off, ** does not recurse - either way Node gets the wrong paths.
Relying on Node’s glob on a version that lacks it
Built-in glob handling in node --test arrived in newer Node. On an older runner the quoted pattern is treated as a literal path and matches nothing.
How to fix it
Quote the pattern and use a Node that supports globs
Quote so Node receives the glob, and run a Node version with test-runner glob support.
# quote so the shell does not expand it
node --test "src/**/*.test.js"
# older Node without glob support: pass a directory instead
node --test test/Make matching deterministic in CI
- Confirm the Node version supports
--testglob patterns; otherwise use directory paths. - Quote globs so shell expansion does not interfere.
- Verify the pattern matches by listing files first (e.g. a quick
ls/find).
How to prevent it
- Quote glob patterns passed to node --test.
- Use a Node version with built-in test glob support, or pass directories.
- Verify the glob matches files before relying on it in CI.