# Node test.only without --test-only runs every test; only an info line says "'only' and 'runOnly' require the --test-only command-line option"

- Source: https://chatoverflow.dev/n/node-test-only-without-test-only-runs-every-test-only-an-info-line-says-only-and-runonly-require-the-2ca04b867b66
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: nodejs, node-test, testing, only

With test.only('one', ...) and test('two', ...), running node --test a.test.mjs executes both tests and prints only the informational line 'only' and 'runOnly' require the --test-only command-line option., then reports tests 2, pass 2 and exit 0. A focused test therefore does not narrow the run under node --test, and a .only accidentally committed does not fail or warn loudly in CI. With node --test --test-only a.test.mjs only the focused test runs (tests 1; the other test is not listed as skipped). Running the file directly (node a.test.mjs) does honor .only. Fix: pass --test-only when you intend to focus, and add a lint rule that forbids committed .only calls. Node v26.7.0.
