Skip to content

Conversation

Han5991
Copy link
Contributor

@Han5991 Han5991 commented Aug 10, 2025

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:

<testcase name="testName" time="0.000414" classname="test" failure="Failed">

After:
<testcase name="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
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-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
Copy link

codecov bot commented Aug 11, 2025

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 lines Coverage Δ
lib/internal/test_runner/reporter/junit.js 94.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 Han5991 force-pushed the add-junit-file-attribute branch from 791f5f7 to 2473640 Compare August 11, 2025 11:38
@Han5991
Copy link
Contributor Author

Han5991 commented Aug 11, 2025

@MoLow

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

@Han5991 Han5991 force-pushed the add-junit-file-attribute branch from 2473640 to 70e2c68 Compare August 14, 2025 20:39
@Han5991
Copy link
Contributor Author

Han5991 commented Aug 18, 2025

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

@atlowChemi
Copy link
Member

atlowChemi commented Aug 18, 2025

@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 Han5991 force-pushed the add-junit-file-attribute branch from 70e2c68 to fa35503 Compare August 18, 2025 06:08
@Han5991
Copy link
Contributor Author

Han5991 commented Aug 18, 2025

@atlowChemi

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

@atlowChemi
Copy link
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 Han5991 force-pushed the add-junit-file-attribute branch from fa35503 to 25aeae1 Compare August 18, 2025 08:50
@Han5991
Copy link
Contributor Author

Han5991 commented Aug 18, 2025

@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:.

@atlowChemi atlowChemi 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-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 18, 2025
@nodejs-github-bot
Copy link
Collaborator

@bjohansebas bjohansebas added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 17, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 17, 2025
@nodejs-github-bot
Copy link
Collaborator

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

@Han5991
Copy link
Contributor Author

Han5991 commented Sep 17, 2025

@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 Han5991 force-pushed the add-junit-file-attribute branch from 25aeae1 to 6509a5e Compare October 7, 2025 08:03
@MoLow MoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 8, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 8, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

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

@nodejs-github-bot
Copy link
Collaborator

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

@MoLow MoLow added the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 8, 2025
@nodejs-github-bot nodejs-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
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: #59432
Fixes: #59422
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Pietro Marchini <[email protected]>
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: #59432
Fixes: #59422
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Pietro Marchini <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. needs-ci PRs that need a full CI run. test_runner Issues 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