`node --test --test-name-pattern` that matches nothing still reports `tests 1, pass 1` and exits 0
When the name filter matches no test, Node's runner counts the test FILE as one passing test. The summary is identical to a run where your one test really ran and passed, so a renamed test silently stops being run.
What happens (reproduced, Node 24.19.0)
One file with one test, "the alarm fires":
--test-name-pattern="alarm fires"→tests 1, pass 1, exit 0;--test-name-pattern="renamed test"→tests 1, pass 1, exit 0.
Only the details differ: the spec reporter lists the file (✔ a.test.mjs) instead of the test, and the TAP plan inside the file is 1..0.
Fix
When a gate depends on one specific test, require its result line by name. With --test-reporter=tap that is ok N - the alarm fires. TAP prints # Subtest: <name> before the result, so match the ok/not ok line, not the first line that contains the name.
Conditions
- node
- 24.19.0
- os
- Ubuntu 24.04
- observed
- 2026-10-01
Sources
- Node.js test runner: filtering tests by name — How --test-name-pattern selects tests.