From e8bc46b6e414a83e490fc4444bd2264faf361ce5 Mon Sep 17 00:00:00 2001 From: InfiniteXyy Date: Fri, 28 Jul 2023 18:03:23 +0800 Subject: [PATCH] feat: support config junit reporter className with env (#3808) --- docs/config/index.md | 2 +- packages/vitest/src/node/reporters/junit.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index d1cea17e35b4..f3028ada12fb 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -486,7 +486,7 @@ Custom reporters for output. Reporters can be [a Reporter instance](https://gith - `'basic'` - give a reporter like default reporter in ci - `'verbose'` - keep the full task tree visible - `'dot'` - show each task as a single dot - - `'junit'` - JUnit XML reporter (you can configure `testsuites` tag name with `VITEST_JUNIT_SUITE_NAME` environmental variable) + - `'junit'` - JUnit XML reporter (you can configure `testsuites` tag name with `VITEST_JUNIT_SUITE_NAME` environmental variable, and `classname` tag property with `VITEST_JUNIT_CLASSNAME`) - `'json'` - give a simple JSON summary - `'html'` - outputs HTML report based on [`@vitest/ui`](/guide/ui) - `'hanging-process'` - displays a list of hanging processes, if Vitest cannot exit process safely. This might be a heavy operation, enable it only if Vitest consistently cannot exit process diff --git a/packages/vitest/src/node/reporters/junit.ts b/packages/vitest/src/node/reporters/junit.ts index c1dc5bbf844c..c8b4e0460434 100644 --- a/packages/vitest/src/node/reporters/junit.ts +++ b/packages/vitest/src/node/reporters/junit.ts @@ -168,7 +168,7 @@ export class JUnitReporter implements Reporter { async writeTasks(tasks: Task[], filename: string): Promise { for (const task of tasks) { await this.writeElement('testcase', { - classname: filename, + classname: process.env.VITEST_JUNIT_CLASSNAME ?? filename, name: task.name, time: getDuration(task), }, async () => {