Skip to content

test: add file attribute to JUnit reporter testcase elements - #59432

Closed
Han5991 wants to merge 2 commits into
nodejs:mainfrom
Han5991:add-junit-file-attribute
Closed

test: add file attribute to JUnit reporter testcase elements#59432
Han5991 wants to merge 2 commits into
nodejs:mainfrom
Han5991:add-junit-file-attribute

Conversation

@Han5991

Copy link
Copy Markdown
Contributor

Fixes: #59422

This PR adds support for the file attribute in JUnit XML reporter's testcase elements, addressing the missing source file information that is useful for CI/CD platforms
like GitLab.

Changes

  • Add file attribute normalization infrastructure in test output transform
  • Implement file attribute support in JUnit reporter for testcase elements
  • Include comprehensive tests to verify correct file path handling

Background

The JUnit XML specification supports a file attribute on testcase elements to indicate the source file containing the test. This attribute was missing from Node.js test
runner's JUnit output, limiting integration with tools that rely on this information for enhanced test reporting.

Before:

<testcasename="testName"time="0.000414"classname="test"failure="Failed">
After:
<testcasename="testName"time="0.000414"classname="test"file="src/junit.test.mts"failure="Failed">

Testing
image

  • All existing tests pass
  • New tests verify file attribute is correctly included
  • File path normalization works across platforms

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Aug 10, 2025
@codecov

codecovBot commented Aug 11, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.54%. Comparing base (b757a8f) to head (6509a5e).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@## main #59432 +/- ##
=======================================
Coverage 88.53% 88.54% =======================================
Files 703 703 Lines 207804 207807 +3 Branches 40005 40005 =======================================
+ Hits 183989 184005 +16 + Misses 15817 15811 -6 + Partials 7998 7991 -7 
Files with missing linesCoverage Δ
lib/internal/test_runner/reporter/junit.js94.47% <100.00%> (+0.10%)⬆️

... and 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Han5991
Han5991force-pushed the add-junit-file-attribute branch from 791f5f7 to 2473640CompareAugust 11, 2025 11:38
@Han5991

Copy link
Copy Markdown
ContributorAuthor

@MoLow

Force pushed to fix commit message lint error - shortened title to meet 72 character limit per Node.js contribution guidelines.

@Han5991
Han5991force-pushed the add-junit-file-attribute branch from 2473640 to 70e2c68CompareAugust 14, 2025 20:39
@Han5991

Copy link
Copy Markdown
ContributorAuthor

Force pushed to fix commit message lint error - shortened title to meet 72 character limit per Node.js contribution guidelines.

@atlowChemi

atlowChemi commented Aug 18, 2025

Copy link
Copy Markdown
Member

@Han5991 Thanks for the contribution!
The submodule of the second commit should be test_runner, not test (test is the repo's tests themself, while test_runner is node's node:test module 🙂)

@Han5991
Han5991force-pushed the add-junit-file-attribute branch from 70e2c68 to fa35503CompareAugust 18, 2025 06:08
@Han5991

Copy link
Copy Markdown
ContributorAuthor

@atlowChemi

Thank you! The submodule reference has been successfully changed from "test" to "test_runner" in the second commit message.

@atlowChemi

Copy link
Copy Markdown
Member

@atlowChemi

Thank you! The submodule reference has been successfully changed from "test" to "test_runner" in the second commit message.

They seem to be applied the wrong way?
The commit which handles the tests is currently test_runner, and the one changing the test runner is test

@Han5991
Han5991force-pushed the add-junit-file-attribute branch from fa35503 to 25aeae1CompareAugust 18, 2025 08:50
@Han5991

Copy link
Copy Markdown
ContributorAuthor

@atlowChemi
Thank you! The submodule reference has been successfully changed from "test" to "test_runner" in the second commit message.

They seem to be applied the wrong way? The commit which handles the tests is currently test_runner, and the one changing the test runner is test

@atlowChemi
Thank you for checking! I've reapplied the changes with the correct commit message prefixes - now the test_runner module changes use test_runner: and the test preparation changes use test:.

@atlowChemiatlowChemi added commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. request-ci Add this label to start a Jenkins CI on a PR. labels Aug 18, 2025
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 18, 2025
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@bjohansebasbjohansebas added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 17, 2025
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 17, 2025
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/69263/

@Han5991

Copy link
Copy Markdown
ContributorAuthor

@atlowChemi

One of the CI jobs seems to have failed due to a flaky test. Would you mind rerunning just the failed job when you have a chance?

Add file attribute normalization in JUnit test output transform to
support upcoming file attribute feature in JUnit XML reporter.
Add file attribute to JUnit testcase elements when file information
is available in test event data.
@Han5991
Han5991force-pushed the add-junit-file-attribute branch from 25aeae1 to 6509a5eCompareOctober 7, 2025 08:03
@MoLowMoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 8, 2025
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 8, 2025
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/69612/

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/69613/

@MoLowMoLow added the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 8, 2025
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 8, 2025
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 1527825...f0aa073

nodejs-github-bot pushed a commit that referenced this pull request Oct 8, 2025
Add file attribute normalization in JUnit test output transform to
support upcoming file attribute feature in JUnit XML reporter.
PR-URL: #59432Fixes: #59422
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
nodejs-github-bot pushed a commit that referenced this pull request Oct 8, 2025
Add file attribute to JUnit testcase elements when file information
is available in test event data.
PR-URL: #59432Fixes: #59422
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
@RafaelGSSRafaelGSS mentioned this pull request Oct 13, 2025
9 tasks
aduh95 pushed a commit that referenced this pull request Oct 31, 2025
Add file attribute normalization in JUnit test output transform to
support upcoming file attribute feature in JUnit XML reporter.
PR-URL: #59432Fixes: #59422
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
aduh95 pushed a commit that referenced this pull request Oct 31, 2025
Add file attribute to JUnit testcase elements when file information
is available in test event data.
PR-URL: #59432Fixes: #59422
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
aduh95 pushed a commit that referenced this pull request Nov 7, 2025
Add file attribute normalization in JUnit test output transform to
support upcoming file attribute feature in JUnit XML reporter.
PR-URL: #59432Fixes: #59422
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
aduh95 pushed a commit that referenced this pull request Nov 7, 2025
Add file attribute to JUnit testcase elements when file information
is available in test event data.
PR-URL: #59432Fixes: #59422
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
@Han5991
Han5991 deleted the add-junit-file-attribute branch February 8, 2026 05:42
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit-queue-rebaseAdd this label to allow the Commit Queue to land a PR in several commits.needs-ciPRs that need a full CI run.test_runnerIssues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JUnit XML testcase element has no file attribute

6 participants

@Han5991@nodejs-github-bot@atlowChemi@MoLow@pmarchini@bjohansebas