Clear and concise description of the problem
As a developer using Vitest I want configure the JUnit reporter the same way I can configure jest-junit so that the generated JUnit XML file still looks the same after a migration from Jest to Vitest.
Vitest's built-in JUnit reporter names <testsuite> elements with the relative file path and names <testcase> elements with the full test hierarchy joined by >. This differs substantially from jest-junit, which offers rich template-based naming through suiteNameTemplate, classNameTemplate, titleTemplate, and ancestorSeparator. Migrating from jest to Vitest therefore produces noticeably different CI XML output.
Suggested solution
Four new opt-in options are added to the JUnitOptions interface. Defaults are unchanged so existing reports are not affected.
New options
| Option |
Type |
Default |
Description |
suiteNameTemplate |
string | function |
– |
Template for <testsuite name>. Placeholders: {title}, {filename}, {filepath}, {basename}, {displayName} |
titleTemplate |
string | function |
– |
Template for <testcase name>. Same placeholders as classnameTemplate. |
ancestorSeparator |
string |
" > " |
Separator for ancestor describe names when building {classname} and the default test title. |
noStackTrace |
boolean |
false |
Omit stack trace text from <failure> bodies (message attribute is still written). |
Alternative
No response
Additional context
No response
Validations
Related PR: #10189
Clear and concise description of the problem
As a developer using Vitest I want configure the JUnit reporter the same way I can configure jest-junit so that the generated JUnit XML file still looks the same after a migration from Jest to Vitest.
Vitest's built-in JUnit reporter names
<testsuite>elements with the relative file path and names<testcase>elements with the full test hierarchy joined by>. This differs substantially from jest-junit, which offers rich template-based naming throughsuiteNameTemplate,classNameTemplate,titleTemplate, andancestorSeparator. Migrating from jest to Vitest therefore produces noticeably different CI XML output.Suggested solution
Four new opt-in options are added to the
JUnitOptionsinterface. Defaults are unchanged so existing reports are not affected.New options
suiteNameTemplatestring | function<testsuite name>. Placeholders:{title},{filename},{filepath},{basename},{displayName}titleTemplatestring | function<testcase name>. Same placeholders asclassnameTemplate.ancestorSeparatorstring" > "{classname}and the default test title.noStackTracebooleanfalse<failure>bodies (message attribute is still written).Alternative
No response
Additional context
No response
Validations
Related PR: #10189