| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7982d3d commit 1240197
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -422,12 +422,22 @@ node --test | |||
| 422 | 422 | ||
| 423 | 423 | By default, Node.js will run all files matching these patterns: | |
| 424 | 424 | ||
| 425 | - * `**/*.test.?(c|m)js` | ||
| 426 | - * `**/*-test.?(c|m)js` | ||
| 427 | - * `**/*_test.?(c|m)js` | ||
| 428 | - * `**/test-*.?(c|m)js` | ||
| 429 | - * `**/test.?(c|m)js` | ||
| 430 | - * `**/test/**/*.?(c|m)js` | ||
| 425 | + * `**/*.test.{cjs,mjs,js}` | ||
| 426 | + * `**/*-test.{cjs,mjs,js}` | ||
| 427 | + * `**/*_test.{cjs,mjs,js}` | ||
| 428 | + * `**/test-*.{cjs,mjs,js}` | ||
| 429 | + * `**/test.{cjs,mjs,js}` | ||
| 430 | + * `**/test/**/*.{cjs,mjs,js}` | ||
| 431 | + | ||
| 432 | + When [`--experimental-strip-types`][] is supplied, the following | ||
| 433 | + additional patterns are matched: | ||
| 434 | + | ||
| 435 | + * `**/*.test.{cts,mts,ts}` | ||
| 436 | + * `**/*-test.{cts,mts,ts}` | ||
| 437 | + * `**/*_test.{cts,mts,ts}` | ||
| 438 | + * `**/test-*.{cts,mts,ts}` | ||
| 439 | + * `**/test.{cts,mts,ts}` | ||
| 440 | + * `**/test/**/*.{cts,mts,ts}` | ||
| 431 | 441 | ||
| 432 | 442 | Alternatively, one or more glob patterns can be provided as the | |
| 433 | 443 | final argument(s) to the Node.js command, as shown below. | |
@@ -3558,6 +3568,7 @@ Can be used to abort test subtasks when the test has been aborted. | |||
| 3558 | 3568 | ||
| 3559 | 3569 | [TAP]: https://testanything.org/ | |
| 3560 | 3570 | [TTY]: tty.md | |
| 3571 | + [`--experimental-strip-types`]: cli.md#--experimental-strip-types | ||
| 3561 | 3572 | [`--experimental-test-coverage`]: cli.md#--experimental-test-coverage | |
| 3562 | 3573 | [`--experimental-test-module-mocks`]: cli.md#--experimental-test-module-mocks | |
| 3563 | 3574 | [`--experimental-test-snapshots`]: cli.md#--experimental-test-snapshots | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,8 +54,11 @@ const kMultipleCallbackInvocations = 'multipleCallbackInvocations'; | |||
| 54 | 54 | const kRegExpPattern = /^\/(.*)\/([a-z]*)$/; | |
| 55 | 55 | ||
| 56 | 56 | const kPatterns = ['test', 'test/**/*', 'test-*', '*[._-]test']; | |
| 57 | - const kDefaultPattern = `**/{${ArrayPrototypeJoin(kPatterns, ',')}}.?(c|m)js`; | ||
| 58 | - | ||
| 57 | + const kFileExtensions = ['js', 'mjs', 'cjs']; | ||
| 58 | + if (getOptionValue('--experimental-strip-types')) { | ||
| 59 | + ArrayPrototypePush(kFileExtensions, 'ts', 'mts', 'cts'); | ||
| 60 | + } | ||
| 61 | + const kDefaultPattern = `**/{${ArrayPrototypeJoin(kPatterns, ',')}}.{${ArrayPrototypeJoin(kFileExtensions, ',')}}`; | ||
| 59 | 62 | ||
| 60 | 63 | function createDeferredCallback() { | |
| 61 | 64 | let calledCount = 0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + const test = require('node:test'); | ||
| 2 | + | ||
| 3 | + // 'as string' ensures that type stripping actually occurs | ||
| 4 | + test('this should pass' as string); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + import { test } from 'node:test'; | ||
| 2 | + | ||
| 3 | + // 'as string' ensures that type stripping actually occurs | ||
| 4 | + test('this should pass' as string); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + const test = require('node:test'); | ||
| 2 | + | ||
| 3 | + // 'as string' ensures that type stripping actually occurs | ||
| 4 | + test('this should pass' as string); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,6 +57,27 @@ for (const isolation of ['none', 'process']) { | |||
| 57 | 57 | assert.match(stdout, /ok 1 - this should pass/); | |
| 58 | 58 | assert.match(stdout, /ok 2 - this should pass/); | |
| 59 | 59 | assert.match(stdout, /ok 3 - this should pass/); | |
| 60 | + // Doesn't match the TypeScript files | ||
| 61 | + assert.doesNotMatch(stdout, /ok 4 - this should pass/); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + for (const type of ['strip', 'transform']) { | ||
| 65 | + // Should match files with "-test.(c|m)(t|j)s" suffix when typescript support is enabled | ||
| 66 | + const args = ['--test', '--test-reporter=tap', '--no-warnings', | ||
| 67 | + `--experimental-${type}-types`, `--experimental-test-isolation=${isolation}`]; | ||
| 68 | + const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'matching-patterns') }); | ||
| 69 | + | ||
| 70 | + assert.strictEqual(child.status, 0); | ||
| 71 | + assert.strictEqual(child.signal, null); | ||
| 72 | + assert.strictEqual(child.stderr.toString(), ''); | ||
| 73 | + const stdout = child.stdout.toString(); | ||
| 74 | + | ||
| 75 | + assert.match(stdout, /ok 1 - this should pass/); | ||
| 76 | + assert.match(stdout, /ok 2 - this should pass/); | ||
| 77 | + assert.match(stdout, /ok 3 - this should pass/); | ||
| 78 | + assert.match(stdout, /ok 4 - this should pass/); | ||
| 79 | + assert.match(stdout, /ok 5 - this should pass/); | ||
| 80 | + assert.match(stdout, /ok 6 - this should pass/); | ||
| 60 | 81 | } | |
| 61 | 82 | ||
| 62 | 83 | { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments