Skip to content

test_runner: JUnit reporter omits the timestamp attribute on <testsuite> #64028

Description

@Han5991

Problem

The JUnit reporter (node --test --test-reporter=junit) emits <testsuite> elements without the timestamp attribute defined by the JUnit/Ant XML schema. timestamp records, in ISO 8601, when the suite started; Node never writes it.

Why it matters

<testsuite timestamp> is how JUnit-consuming tools (CI dashboards, test-report viewers) anchor each suite on a time axis — for example, to order suites coming back from parallel/sharded runs, and to build per-suite history and trends across runs. Without it, consumers fall back to file mtime or the overall job time, which is coarser and can be misleading.

Node is also an outlier among JUnit producers: pytest (--junitxml), jest-junit, mocha-junit-reporter, and Maven Surefire all emit timestamp on <testsuite>. Node's reporter already emits time and hostname on <testsuite> (and file on <testcase>), but not timestamp.

Current behavior

$ node --test --test-reporter=junit ...
<testsuite name="my suite" time="0.42" disabled="0" errors="0" tests="2" failures="0" skipped="0" hostname="...">

No timestamp attribute is present.

Proposed solution

In lib/internal/test_runner/reporter/junit.js, emit the suite start time as the timestamp attribute on each <testsuite>.

There is one open question — the value format:

  • Full ISO 8601 with timezone (e.g. 2026-06-20T12:34:56.789Z). This is what Date.prototype.toISOString() produces directly, it is unambiguous about the instant, and it is the direction newer tooling (pytest 8.x, Maven Surefire 3.5.5+) is moving.
  • Legacy no-timezone Ant form (e.g. 2026-06-20T12:34:56). This is the canonical de-facto format (Ant XMLJUnitResultFormatter; the strict windyroad JUnit XSD even pins it to \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2} with no zone) and what jest-junit / mocha-junit-reporter currently emit, but it is ambiguous about the actual instant.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions