Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,27 @@ You can also execute the tests in a test suite directory
tools/test.py test/message
```

You can execute tests that match a specific naming pattern using the wildcard
`*`. For example, to run all tests under `test/parallel` with a name that starts
with `test-stream-`:

```bash
tools/test.py test/parallel/test-stream-*
tools/test.py parallel/test-stream-* # The test/ prefix can be omitted
# In some shell environments, you may need to quote the pattern
Copy link
Contributor

@aduh95 aduh95 Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW that might be a bit misleading. If you don't quote it (and you use a POSIX-complient shell), the shell is going to expand it (i.e. looking for all files that match and pass each as a separate arg); so arguably quotes are always necessary, otherwise you waste a lot of time for on the shell expansion:

$ time tools/test.py test/parallel/test-debug*
[00:05|% 100|+  35|-   0]: Done                                               

All tests passed.
tools/test.py test/parallel/test-debug*  15.09s user 1.94s system 92% cpu 18.477 total
$ time tools/test.py 'test/parallel/test-debug*'
[00:05|% 100|+  35|-   0]: Done                                               

All tests passed.
tools/test.py 'test/parallel/test-debug*'  8.38s user 1.04s system 146% cpu 6.424 total

tools/test.py "test/parallel/test-stream-*"
```

The whildcard `*` can be used in any part of the path. For example, to run all tests
with a name that starts with `test-inspector-`, regardless of the directory they are in:

```bash
# Matches test/sequential/test-inspector-*, test/parallel/test-inspector-*,
# test/known_issues/test-inspector-*, etc.
tools/test.py "test/*/test-inspector-*"
tools/test.py "*/test-inspector-*" # The test/ prefix can be omitted
```

If you want to check the other options, please refer to the help by using
the `--help` option:

Expand Down
5 changes: 5 additions & 0 deletions doc/contributing/writing-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,11 @@ To generate a test coverage report, see the
Nightly coverage reports for the Node.js `main` branch are available at
<https://coverage.nodejs.org/>.

## Running tests

See the [Building guide](../../BUILDING.md#running-tests) for details on how to
run tests.

[ASCII]: https://man7.org/linux/man-pages/man7/ascii.7.html
[Google Test]: https://github.com/google/googletest
[Test Coverage section of the Building guide]: https://github.com/nodejs/node/blob/HEAD/BUILDING.md#running-coverage
Expand Down
Loading