Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_runner: always make spec the default reporter #54548

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions doc/api/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -1000,12 +1000,13 @@ flags for the test runner to use a specific reporter.

The following built-reporters are supported:

* `spec`
The `spec` reporter outputs the test results in a human-readable format. This
is the default reporter.

* `tap`
The `tap` reporter outputs the test results in the [TAP][] format.

* `spec`
The `spec` reporter outputs the test results in a human-readable format.

* `dot`
The `dot` reporter outputs the test results in a compact format,
where each passing test is represented by a `.`,
Expand All @@ -1018,9 +1019,6 @@ The following built-reporters are supported:
The `lcov` reporter outputs test coverage when used with the
[`--experimental-test-coverage`][] flag.

When `stdout` is a [TTY][], the `spec` reporter is used by default.
Otherwise, the `tap` reporter is used by default.

The exact output of these reporters is subject to change between versions of
Node.js, and should not be relied on programmatically. If programmatic access
to the test runner's output is required, use the events emitted by the
Expand Down Expand Up @@ -3505,7 +3503,6 @@ added:
Can be used to abort test subtasks when the test has been aborted.

[TAP]: https://testanything.org/
[TTY]: tty.md
[`--experimental-test-coverage`]: cli.md#--experimental-test-coverage
[`--experimental-test-snapshots`]: cli.md#--experimental-test-snapshots
[`--import`]: cli.md#--importmodule
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/test_runner/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const kBuiltinReporters = new SafeMap([
['lcov', 'internal/test_runner/reporter/lcov'],
]);

const kDefaultReporter = process.stdout.isTTY ? 'spec' : 'tap';
const kDefaultReporter = 'spec';
const kDefaultDestination = 'stdout';

function tryBuiltinReporter(name) {
Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-runner-reporters.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ describe('node:test reporters', { concurrency: true }, () => {
it('should default to outputing TAP to stdout', async () => {
const child = spawnSync(process.execPath, ['--test', testFile]);
assert.strictEqual(child.stderr.toString(), '');
assert.match(child.stdout.toString(), /TAP version 13/);
assert.match(child.stdout.toString(), /ok 1 - ok/);
assert.match(child.stdout.toString(), /not ok 2 - failing/);
assert.match(child.stdout.toString(), /ok 2 - top level/);
assert.match(child.stdout.toString(), /✖ failing tests:/);
assert.match(child.stdout.toString(), / ok/);
assert.match(child.stdout.toString(), / failing/);
assert.match(child.stdout.toString(), / top level/);
});

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