Roo-Code/src/utils/vitest-verbosity.ts
Chris Hasson aee531a143
Show console logging in vitests when the --no-silent flag is set (#7467)
By default, all of the tests run in silent mode with monkey-patched the console logging so no console logging will ever appear in test output.
This confuses the agent- sometimes it will add console logging to help it debug things, and it won't see the logs that it expects.

Adds src/utils/vitest-verbosity.ts to handle verbosity resolution and console logging.
Modifies src/vitest.config.ts and webview-ui/vitest.config.ts to integrate the new verbosity control.
Removes manual console suppression from src/vitest.setup.ts and webview-ui/vitest.setup.ts as it's now handled dynamically.

Co-authored-by: Chris Hasson <noreply@example.com>
2025-08-28 12:51:21 -04:00

22 lines
782 B
TypeScript

export function resolveVerbosity(argv = process.argv, env = process.env) {
// Check if --no-silent flag is used (native vitest flag)
const cliNoSilent = argv.includes("--no-silent") || argv.includes("--silent=false")
const silent = !cliNoSilent // Silent by default
// Check if verbose reporter is requested
const wantsVerboseReporter = argv.some(
(a) => a === "--reporter=verbose" || a === "-r=verbose" || a === "--reporter",
)
return {
silent,
reporters: ["dot", ...(wantsVerboseReporter ? ["verbose"] : [])],
onConsoleLog: (_log: string, type: string) => {
// When verbose, show everything
// When silent, allow errors/warnings and drop info/log/warn noise
if (!silent || type === "stderr") return
return false // Drop info/log/warn noise
},
}
}