Skip to content

Conversation

@devholic22
Copy link

@devholic22 devholic22 commented Aug 30, 2025

Fixes: #59593

This PR aligns the Node.js test runner’s JUnit XML output with the official JUnit specification by removing the non-standard failure attribute from elements and replacing it with a proper nested tag.

Changes

• Remove non-compliant failure attribute from elements
• Update snapshot tests accordingly

Background

The JUnit XML specification mandates that failure details must be represented via a nested (child) <failure> element inside a <testcase>, rather than as an attribute.

스크린샷 2025-08-30 오후 4 39 27

However, the Node.js test runner previously:
• Incorrectly embedded the failure message as a failure="..." attribute on , which is not spec-compliant
• This caused compatibility issues with tools like GitLab, Jenkins, or any CI/CD pipeline that parses JUnit reports strictly

Before:

<testcase name="testName" time="0.002234" classname="test" failure="The value must be 01 !== 0">
  <failure type="testCodeFailure" message="The value must be 01 !== 0">

After:

<testcase name="testName" time="0.002234" classname="test">
    <failure type="testCodeFailure" message="The value must be 01 !== 0">

Testing

스크린샷 2025-08-30 오후 4 06 57
  • All existing tests pass

@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 30, 2025
children: [inspectWithNoCustomRetry(error, inspectOptions)],
});
currentTest.failures = 1;
currentTest.attrs.failure = error?.message ?? '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the change the good, I wonder if we have to treat this as potentially breaking? @nodejs/test_runner @nodejs/tsc any thoughts? I'm fine landing as a semver-patch but want to be sure.

Copy link
Member

@MoLow MoLow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. also not sure rgarding semver-major vs patch

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

@codecov
Copy link

codecov bot commented Sep 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.87%. Comparing base (bcb802c) to head (dc807aa).
⚠️ Report is 29 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #59685      +/-   ##
==========================================
- Coverage   89.91%   89.87%   -0.04%     
==========================================
  Files         667      667              
  Lines      196600   196855     +255     
  Branches    38601    38646      +45     
==========================================
+ Hits       176780   176933     +153     
- Misses      12269    12359      +90     
- Partials     7551     7563      +12     
Files with missing lines Coverage Δ
lib/internal/test_runner/reporter/junit.js 94.96% <ø> (+0.59%) ⬆️

... and 41 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.

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

Labels

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 failure element and attribute are incorrect when using node:assert

7 participants