nodejs / nodejs/node

test_runner: files without any tests matching `--test-name-pattern` shouldn't be counted or reported

Open
#64,099 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature request test_runner
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

Version

v26.3.0

Subsystem

test_runner

What steps will reproduce the bug?
echo "const test = require('node:test'); test('good test', (t) => { t.assert.equal(1, 1) })" > one.test.js

echo "const test = require('node:test'); test('bad test', (t) => { t.assert.equal(1, 2) })" > two.test.js

node --test --test-name-pattern=good *.test.js 
How often does it reproduce? Is there a required condition?

always

What is the expected behavior? Why is that the expected behavior?
✔ good test (0.963084ms)
ℹ tests 1
ℹ suites 0
ℹ pass 1
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 0.963084ms

The file two.test.js does not contain a single test that matches the --test-name-pattern, so should be skipped entirely, i.e. treated as if it doesn't exist.

What do you see instead?
✔ good test (0.963084ms)
✔ two.test.js (61.52275ms)  <-- file with no matching tests reported (by file name) as passing 
ℹ tests 2                   <-- should be 1 test
ℹ suites 0
ℹ pass 2                    <-- should be 1 pass
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 68.503541     <-- should be 0.963084ms

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reported command with one.test.js and two.test.js, then inspect the test_runner implementation and its existing tests for --test-name-pattern handling. Done means a file with no matching tests is omitted and the totals, pass count, and duration include only the matching good test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
67/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.