◐ Shell
clean mode source ↗

test_runner: change ts default glob · nodejs/node@5054fc7

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.

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,

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

File renamed without changes.

File renamed without changes.

File renamed without changes.