Vitest

Vitest is a testing framework for JavaScript.

Enabling XML Output

Configure Vitest to produce JUnit XML output using the built in junit reporter command line option.

vitest --reporter=junit --outputFile=test-output.xml

Typically you will do this in the package.json script that runs your tests, like this:

"scripts": {
  "vitest": "vitest run --dir test --reporter=junit --outputFile=./test-output.xml",
}

For more details see the Vitest reporter docs.

Test Suite Naming

The generated XML contains nested testsuites and testcase tags. You can use the environment variables VITEST_JUNIT_SUITE_NAME and VITEST_JUNIT_CLASSNAME to configure their name and classname attributes, respectively. These can also be customized via reporter options:

export default defineConfig({
  test: {
    reporters: [
      ['junit', { suiteName: 'custom suite name', classname: 'custom-classname' }]
    ]
  },
})

For more details see the Vitest JUnit Reporter docs.

Last updated