diff --git a/doc/api/test.md b/doc/api/test.md index 85156b7599ee40..e1639cab9ce585 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -472,9 +472,12 @@ By default, Node.js will run all files matching these patterns: Unless [`--no-experimental-strip-types`][] is supplied, the following additional patterns are also matched: -* `**/test/**/*-test.{cts,mts,ts}` -* `**/test/**/*.test.{cts,mts,ts}` -* `**/test/**/*_test.{cts,mts,ts}` +* `**/*.test.{cts,mts,ts}` +* `**/*-test.{cts,mts,ts}` +* `**/*_test.{cts,mts,ts}` +* `**/test-*.{cts,mts,ts}` +* `**/test.{cts,mts,ts}` +* `**/test/**/*.{cts,mts,ts}` Alternatively, one or more glob patterns can be provided as the final argument(s) to the Node.js command, as shown below. diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js index 0f40fa1016b504..4c2949f4158ab1 100644 --- a/lib/internal/test_runner/runner.js +++ b/lib/internal/test_runner/runner.js @@ -110,7 +110,7 @@ let kResistStopPropagation; function createTestFileList(patterns, cwd) { const hasUserSuppliedPattern = patterns != null; if (!patterns || patterns.length === 0) { - patterns = kDefaultPattern; + patterns = [kDefaultPattern]; } const glob = new Glob(patterns, { __proto__: null, diff --git a/lib/internal/test_runner/utils.js b/lib/internal/test_runner/utils.js index 4e1a21df976b17..44789451d18335 100644 --- a/lib/internal/test_runner/utils.js +++ b/lib/internal/test_runner/utils.js @@ -60,10 +60,10 @@ const kRegExpPattern = /^\/(.*)\/([a-z]*)$/; const kPatterns = ['test', 'test/**/*', 'test-*', '*[._-]test']; const kFileExtensions = ['js', 'mjs', 'cjs']; -const kDefaultPattern = [`**/{${ArrayPrototypeJoin(kPatterns, ',')}}.{${ArrayPrototypeJoin(kFileExtensions, ',')}}`]; if (getOptionValue('--experimental-strip-types')) { - ArrayPrototypePush(kDefaultPattern, '**/test/**/*{-,.,_}test.{cts,mts,ts}'); + ArrayPrototypePush(kFileExtensions, 'ts', 'mts', 'cts'); } +const kDefaultPattern = `**/{${ArrayPrototypeJoin(kPatterns, ',')}}.{${ArrayPrototypeJoin(kFileExtensions, ',')}}`; function createDeferredCallback() { let calledCount = 0; @@ -295,7 +295,7 @@ function parseCommandLine() { if (!coverageExcludeGlobs || coverageExcludeGlobs.length === 0) { // TODO(pmarchini): this default should follow something similar to c8 defaults // Default exclusions should be also exported to be used by other tools / users - coverageExcludeGlobs = kDefaultPattern; + coverageExcludeGlobs = [kDefaultPattern]; } coverageIncludeGlobs = getOptionValue('--test-coverage-include'); diff --git a/test/fixtures/test-runner/matching-patterns/test/typescript-test.cts b/test/fixtures/test-runner/matching-patterns/typescript-test.cts similarity index 100% rename from test/fixtures/test-runner/matching-patterns/test/typescript-test.cts rename to test/fixtures/test-runner/matching-patterns/typescript-test.cts diff --git a/test/fixtures/test-runner/matching-patterns/test/typescript-test.mts b/test/fixtures/test-runner/matching-patterns/typescript-test.mts similarity index 100% rename from test/fixtures/test-runner/matching-patterns/test/typescript-test.mts rename to test/fixtures/test-runner/matching-patterns/typescript-test.mts diff --git a/test/fixtures/test-runner/matching-patterns/test/typescript-test.ts b/test/fixtures/test-runner/matching-patterns/typescript-test.ts similarity index 100% rename from test/fixtures/test-runner/matching-patterns/test/typescript-test.ts rename to test/fixtures/test-runner/matching-patterns/typescript-test.ts