You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't set classname for testcase element in JUnit XML when using node:test #59417
I can replicate this issue. I would be happy to implement a fix for this.
An option could be to set the testname based on the name of the file: <testcase name="testName" classname="C:\path\to\src\junit.test"/> I think that the location is passed to the event.
Another one it could be to pass an object to the test function: test('testName', { classname: 'testName' }, () => {});, however this is only for the junit reporter and would create a breaking change.
The last option I can think of is to trasverse the suite a put the names like this:
I agree that the template approach might be over-engineering at this stage. Option 3 (suite hierarchy) seems like the most pragmatic solution - it's intuitive, doesn't break existing APIs, and solves the core problem.
We can always add template support later if there's proven demand for more complex formatting. @lluisemper Would it be okay if I implement the suite hierarchy approach? I think it's a solid first step that we can build upon.
Is anyone currently working on an implementation? If not, may I take this on and open a PR implementing the suite-hierarchy approach (setting the testcase classname from suite nesting)?
This issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
This issue has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
Activity
lluisemper commentedon Aug 11, 2025
I can replicate this issue. I would be happy to implement a fix for this.
An option could be to set the testname based on the name of the file:
<testcase name="testName" classname="C:\path\to\src\junit.test"/>I think that the location is passed to the event.Another one it could be to pass an object to the test function:
test('testName', { classname: 'testName' }, () => {});, however this is only for the junit reporter and would create a breaking change.The last option I can think of is to trasverse the suite a put the names like this:
<testcase name="adds positive numbers" classname="Math.Addition"/>I do prefer the third option, what do you think guys?
CuriousStork commentedon Aug 14, 2025
Hello, my two cents here.
I've checked how Playwright and Jest handling
classname-s. They use templates:Maybe templating is another option, if there's a good way to convey the template to the reporter both programmatically and via CLI.
Han5991 commentedon Aug 18, 2025
I agree that the template approach might be over-engineering at this stage. Option 3 (suite hierarchy) seems like the most pragmatic solution - it's intuitive, doesn't break existing APIs, and solves the core problem.
We can always add template support later if there's proven demand for more complex formatting.
@lluisemper Would it be okay if I implement the suite hierarchy approach? I think it's a solid first step that we can build upon.
lluisemper commentedon Aug 19, 2025
@Han5991 Sure, go ahead!💪 Let us know your findings in case we can be of any help
mag123c commentedon Oct 10, 2025
Is anyone currently working on an implementation? If not, may I take this on and open a PR implementing the suite-hierarchy approach (setting the testcase
classnamefrom suite nesting)?Han5991 commentedon Oct 10, 2025
@mag123c Sure, go ahead
github-actions commentedon May 9, 2026
This issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
CuriousStork commentedon May 14, 2026
The related PR #60220 is still not merged. Should we keep the issue active until it's landed?
github-actions commentedon Aug 14, 2026
This issue has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
CuriousStork commentedon Aug 18, 2026
The related PR #60220 is still not merged. Should we keep the issue active until it's landed?
test_runner: add classname hierarchy for JUnit reporter
test_runner: add classname hierarchy for JUnit reporter
test_runner: add classname hierarchy for JUnit reporter
test_runner: add classname hierarchy for JUnit reporter
test_runner: add classname hierarchy for JUnit reporter
test_runner: add classname hierarchy for JUnit reporter