Version
v24.4.1
Platform
Microsoft Windows NT 10.0.19045.0 x64
Subsystem
test
What steps will reproduce the bug?
-
Create any test file, like
import { suite, test } from "node:test";
await suite('suiteName', () => {
test('testName', () => {});
});
-
Run the test via console
node --test --test-reporter=junit ".\src\junit.test.mts"
-
Check the report from stdout.
How often does it reproduce? Is there a required condition?
Always. Regardless the suite or test function arguments.
What is the expected behavior? Why is that the expected behavior?
There should be a way to set classname value for the JUnit report.
As of JUnit XML specification, classname is
Full class name for the class the test method is in.
For example, GitLab uses classname when rendering the test reports.
https://docs.gitlab.com/ci/testing/unit_test_reports/
The testcase classname attribute is used as the suite name, not the testsuite name attribute.
What do you see instead?
<testcase name="testName" time="0.000363" classname="test"/>
classname is always "test".
Additional information
I guess currently there's no way to set classname in a test event, so reports always get "test" instead:
|
currentTest.attrs.classname = event.data.classname ?? 'test'; |
Version
v24.4.1
Platform
Subsystem
test
What steps will reproduce the bug?
Create any test file, like
Run the test via console
Check the report from stdout.
How often does it reproduce? Is there a required condition?
Always. Regardless the suite or test function arguments.
What is the expected behavior? Why is that the expected behavior?
There should be a way to set
classnamevalue for the JUnit report.As of JUnit XML specification,
classnameisFor example, GitLab uses
classnamewhen rendering the test reports.https://docs.gitlab.com/ci/testing/unit_test_reports/
What do you see instead?
classnameis always"test".Additional information
I guess currently there's no way to set
classnamein a test event, so reports always get"test"instead:node/lib/internal/test_runner/reporter/junit.js
Line 118 in 931ec10