Skip to content

test_runner: update output TAP format to follow TAP 14 specs #44040

Closed as not planned
@manekinekko

Description

@manekinekko

What steps will reproduce the bug?

  • create an index.js file with a few test cases:
const test = require('node:test');
const assert = require('node:assert');

test('top-level test 1', async (t) => {
  await t.test('level 1.1', () => {});
});

test('top-level test 2', () => {});
  • run the test: node index.js (note: node --test index.js gives an incorrect result)

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

Even though the current output is syntactically valid TAP output. The expected output would be a TAP format that follows specs 14.

TAP version 14

# Subtest: top-level test 1
    ok 1 - sub test level 1.1
    1..1
ok 1 - top-level test 1

ok 2 - top-level test 2

1..2

Note the version header TAP version 14 (required by TAP14).

What do you see instead?

We currently output the following format (removed diagnostics for readability):

TAP version 13

# Subtest: top-level test 1
    # Subtest: sub-test level 1.1
    ok 1 - sub-test level 1.1
    1..1
ok 1 - top-level test 1

1..1

Top-level tests are incorrectly output as subtests: # Subtest: top-level test 1 and # Subtest: top-level test 2

Additional information

As a reference, using node-tap (v16.3.0) gives the following output:

TAP version 13
# Subtest: top-level test 1
    ok 1 - sub test level 1.1
    1..1
ok 1 - top-level test 1

ok 2 - top-level test 2
1..2

Here is the diff:

TAP version 13

# Subtest: top-level test 1
-    # Subtest: sub test level 1.1
    ok 1 - sub test level 1.1
    1..1
ok 1 - top-level test 1

+ ok 2 - top-level test 2

-1..1
+1..2

Related: #43417 #43525

Metadata

Metadata

Assignees

Labels

good first issueIssues that are suitable for first-time contributors.test_runnerIssues and PRs related to the test runner subsystem.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions