Skip to content

Commit eb7e18f

Browse files
authored
test_runner: always make spec the default reporter
This is a breaking change. Prior to this commit, the test_runner defaulted to the spec reporter if using a TTY, and the TAP reporter otherwise. This commit makes spec the default reporter unconditionally. TAP output is still available via the --test-reporter=tap CLI flag. Fixes: #54540 PR-URL: #54548 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Jake Yuesong Li <[email protected]>
1 parent ba07067 commit eb7e18f

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

doc/api/test.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -1000,12 +1000,13 @@ flags for the test runner to use a specific reporter.
10001000

10011001
The following built-reporters are supported:
10021002

1003+
* `spec`
1004+
The `spec` reporter outputs the test results in a human-readable format. This
1005+
is the default reporter.
1006+
10031007
* `tap`
10041008
The `tap` reporter outputs the test results in the [TAP][] format.
10051009

1006-
* `spec`
1007-
The `spec` reporter outputs the test results in a human-readable format.
1008-
10091010
* `dot`
10101011
The `dot` reporter outputs the test results in a compact format,
10111012
where each passing test is represented by a `.`,
@@ -1018,9 +1019,6 @@ The following built-reporters are supported:
10181019
The `lcov` reporter outputs test coverage when used with the
10191020
[`--experimental-test-coverage`][] flag.
10201021

1021-
When `stdout` is a [TTY][], the `spec` reporter is used by default.
1022-
Otherwise, the `tap` reporter is used by default.
1023-
10241022
The exact output of these reporters is subject to change between versions of
10251023
Node.js, and should not be relied on programmatically. If programmatic access
10261024
to the test runner's output is required, use the events emitted by the
@@ -3505,7 +3503,6 @@ added:
35053503
Can be used to abort test subtasks when the test has been aborted.
35063504

35073505
[TAP]: https://testanything.org/
3508-
[TTY]: tty.md
35093506
[`--experimental-test-coverage`]: cli.md#--experimental-test-coverage
35103507
[`--experimental-test-snapshots`]: cli.md#--experimental-test-snapshots
35113508
[`--import`]: cli.md#--importmodule

lib/internal/test_runner/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const kBuiltinReporters = new SafeMap([
119119
['lcov', 'internal/test_runner/reporter/lcov'],
120120
]);
121121

122-
const kDefaultReporter = process.stdout.isTTY ? 'spec' : 'tap';
122+
const kDefaultReporter = 'spec';
123123
const kDefaultDestination = 'stdout';
124124

125125
function tryBuiltinReporter(name) {

test/parallel/test-runner-reporters.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ describe('node:test reporters', { concurrency: true }, () => {
1616
it('should default to outputing TAP to stdout', async () => {
1717
const child = spawnSync(process.execPath, ['--test', testFile]);
1818
assert.strictEqual(child.stderr.toString(), '');
19-
assert.match(child.stdout.toString(), /TAP version 13/);
20-
assert.match(child.stdout.toString(), /ok 1 - ok/);
21-
assert.match(child.stdout.toString(), /not ok 2 - failing/);
22-
assert.match(child.stdout.toString(), /ok 2 - top level/);
19+
assert.match(child.stdout.toString(), / failing tests:/);
20+
assert.match(child.stdout.toString(), / ok/);
21+
assert.match(child.stdout.toString(), / failing/);
22+
assert.match(child.stdout.toString(), / top level/);
2323
});
2424

2525
it('should default destination to stdout when passing a single reporter', async () => {

0 commit comments

Comments
 (0)