| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -518,8 +518,7 @@ flags for the test runner to use a specific reporter. | |||
| 518 | 518 | The following built-reporters are supported: | |
| 519 | 519 | ||
| 520 | 520 | * `tap` | |
| 521 | - The `tap` reporter is the default reporter used by the test runner. It outputs | ||
| 522 | - the test results in the [TAP][] format. | ||
| 521 | + The `tap` reporter outputs the test results in the [TAP][] format. | ||
| 523 | 522 | ||
| 524 | 523 | * `spec` | |
| 525 | 524 | The `spec` reporter outputs the test results in a human-readable format. | |
@@ -529,6 +528,9 @@ The following built-reporters are supported: | |||
| 529 | 528 | where each passing test is represented by a `.`, | |
| 530 | 529 | and each failing test is represented by a `X`. | |
| 531 | 530 | ||
| 531 | + When `stdout` is a [TTY][], the `spec` reporter is used by default. | ||
| 532 | + Otherwise, the `tap` reporter is used by default. | ||
| 533 | + | ||
| 532 | 534 | ### Custom reporters | |
| 533 | 535 | ||
| 534 | 536 | [`--test-reporter`][] can be used to specify a path to custom reporter. | |
@@ -1732,6 +1734,7 @@ added: | |||
| 1732 | 1734 | aborted. | |
| 1733 | 1735 | ||
| 1734 | 1736 | [TAP]: https://testanything.org/ | |
| 1737 | + [TTY]: tty.md | ||
| 1735 | 1738 | [`--experimental-test-coverage`]: cli.md#--experimental-test-coverage | |
| 1736 | 1739 | [`--import`]: cli.md#--importmodule | |
| 1737 | 1740 | [`--test-name-pattern`]: cli.md#--test-name-pattern | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -98,7 +98,7 @@ const kBuiltinReporters = new SafeMap([ | |||
| 98 | 98 | ['tap', 'internal/test_runner/reporter/tap'], | |
| 99 | 99 | ]); | |
| 100 | 100 | ||
| 101 | - const kDefaultReporter = 'tap'; | ||
| 101 | + const kDefaultReporter = process.stdout.isTTY ? 'spec' : 'tap'; | ||
| 102 | 102 | const kDefaultDestination = 'stdout'; | |
| 103 | 103 | ||
| 104 | 104 | function tryBuiltinReporter(name) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,11 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + process.env.FORCE_COLOR = '1'; | ||
| 3 | + delete process.env.NODE_DISABLE_COLORS; | ||
| 4 | + delete process.env.NO_COLOR; | ||
| 5 | + | ||
| 6 | + require('../common'); | ||
| 7 | + const test = require('node:test'); | ||
| 8 | + | ||
| 9 | + test('should pass', () => {}); | ||
| 10 | + test('should fail', () => { throw new Error('fail'); }); | ||
| 11 | + test('should skip', { skip: true }, () => {}); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,19 @@ | |||
| 1 | + [32m* should pass [90m(*ms)[39m[39m | ||
| 2 | + [31m* should fail [90m(*ms)[39m | ||
| 3 | + Error: fail | ||
| 4 | + at * [90m(*)[39m | ||
| 5 | + [90m at *[39m | ||
| 6 | + [90m at *[39m | ||
| 7 | + [90m at *[39m | ||
| 8 | + [90m at *[39m | ||
| 9 | + [90m at *[39m | ||
| 10 | + [90m at *[39m | ||
| 11 | + ** | ||
| 12 | + [90m* should skip [90m(*ms)[39m # SKIP[39m | ||
| 13 | + [34m* tests 3[39m | ||
| 14 | + [34m* pass 1[39m | ||
| 15 | + [34m* fail 1[39m | ||
| 16 | + [34m* cancelled 0[39m | ||
| 17 | + [34m* skipped 1[39m | ||
| 18 | + [34m* todo 0[39m | ||
| 19 | + [34m* duration_ms *[39m | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments