vitest-dev / vitest-dev/vitest
CLI support for JUnit reporter includeConsoleOutput option
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.1k
- Forks
- 2k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 94
Description
Clear and concise description of the problem
As a developer using Vitest, I want to control the JUnit reporter’s includeConsoleOutput option from the CLI, so that I can enable or disable and output in CI without changing or branching my Vitest config.
Today, outputFile has dedicated CLI support, but includeConsoleOutput does not. The JUnit reporter supports this option in config, but it cannot be overridden from the CLI the way outputFile can.
This matters in CI because some environments want smaller JUnit XML files and some want full console output for debugging. Right now, the only way to switch this is through config-level reporter options, which is awkward for matrix jobs and one-off CI overrides.
Suggested solution
Add CLI support for the JUnit reporter’s includeConsoleOutput option.
A couple of possible shapes that would fit current CLI behavior:
A dedicated top-level flag, for example:
--junitIncludeConsoleOutput=false or --includeConsoleOutput=false
A reporter-scoped flag, if Vitest wants to support more reporter-specific CLI overrides in the future, for example:
--reporterOption.junit.includeConsoleOutput=false
My preference would be the smallest change that is consistent with existing conventions. A dedicated boolean flag seems simplest, especially since outputFile already has special CLI handling.
Alternative
Otherwise, we have to do some ugly config myself. For instance, I'm doing this nonsense:
CLI command:
npx cross-env CI=true VITEST_JUNIT_ONLY=true vitest run --outputFile=junit-core.xml src/standard
vite.config.ts:
const isJunitOnlyRun = process.env.VITEST_JUNIT_ONLY === "true";
export default defineConfig({
// ...
test: {
reporters: isJunitOnlyRun
? [["junit", { includeConsoleOutput: false }]]
: ["default", ["junit", { includeConsoleOutput: false }]],
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing CLI handling for outputFile and the JUnit reporter's includeConsoleOutput option. Compare the available flag shapes with current CLI conventions, then verify that a CLI override enables or disables system-out and system-err output without changing config.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, testing-qa
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100