Skip to content

Commit 5054fc7

Browse files
marco-ippolitotargos
authored andcommitted
test_runner: change ts default glob
PR-URL: #57359 Fixes: #56546 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
1 parent 3dc3207 commit 5054fc7

File tree

6 files changed

+7
-10
lines changed

6 files changed

+7
-10
lines changed

β€Ždoc/api/test.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,9 @@ By default, Node.js will run all files matching these patterns:
423423
Unless [`--no-experimental-strip-types`][] is supplied, the following
424424
additional patterns are also matched:
425425

426-
* `**/*.test.{cts,mts,ts}`
427-
* `**/*-test.{cts,mts,ts}`
428-
* `**/*_test.{cts,mts,ts}`
429-
* `**/test-*.{cts,mts,ts}`
430-
* `**/test.{cts,mts,ts}`
431-
* `**/test/**/*.{cts,mts,ts}`
426+
* `**/test/**/*-test.{cts,mts,ts}`
427+
* `**/test/**/*.test.{cts,mts,ts}`
428+
* `**/test/**/*_test.{cts,mts,ts}`
432429

433430
Alternatively, one or more glob patterns can be provided as the
434431
final argument(s) to the Node.js command, as shown below.

β€Žlib/internal/test_runner/runner.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ let kResistStopPropagation;
108108
function createTestFileList(patterns, cwd) {
109109
const hasUserSuppliedPattern = patterns != null;
110110
if (!patterns || patterns.length === 0) {
111-
patterns = [kDefaultPattern];
111+
patterns = kDefaultPattern;
112112
}
113113
const glob = new Glob(patterns, {
114114
__proto__: null,

β€Žlib/internal/test_runner/utils.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ const kRegExpPattern = /^\/(.*)\/([a-z]*)$/;
5555

5656
const kPatterns = ['test', 'test/**/*', 'test-*', '*[._-]test'];
5757
const kFileExtensions = ['js', 'mjs', 'cjs'];
58+
const kDefaultPattern = [`**/{${ArrayPrototypeJoin(kPatterns, ',')}}.{${ArrayPrototypeJoin(kFileExtensions, ',')}}`];
5859
if (getOptionValue('--experimental-strip-types')) {
59-
ArrayPrototypePush(kFileExtensions, 'ts', 'mts', 'cts');
60+
ArrayPrototypePush(kDefaultPattern, '**/test/**/*{-,.,_}test.{cts,mts,ts}');
6061
}
61-
const kDefaultPattern = `**/{${ArrayPrototypeJoin(kPatterns, ',')}}.{${ArrayPrototypeJoin(kFileExtensions, ',')}}`;
6262

6363
function createDeferredCallback() {
6464
let calledCount = 0;
@@ -290,7 +290,7 @@ function parseCommandLine() {
290290
if (!coverageExcludeGlobs || coverageExcludeGlobs.length === 0) {
291291
// TODO(pmarchini): this default should follow something similar to c8 defaults
292292
// Default exclusions should be also exported to be used by other tools / users
293-
coverageExcludeGlobs = [kDefaultPattern];
293+
coverageExcludeGlobs = kDefaultPattern;
294294
}
295295
coverageIncludeGlobs = getOptionValue('--test-coverage-include');
296296

0 commit comments

Comments
Β (0)