[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

fix: use "black" foreground for labeled terminal message to ensure contrast (#10076)

authored by

Hiroshi Ogawa and committed by
GitHub
(Apr 7, 2026, 9:16 PM +0200) 203f07af 2fdcab87

+16 -12
+5 -6
packages/vitest/src/node/config/resolveConfig.ts
··· 25 25 import { benchmarkConfigDefaults, configDefaults } from '../../defaults' 26 26 import { isAgent, isCI, stdProvider } from '../../utils/env' 27 27 import { getWorkersCountByPercentage } from '../../utils/workers' 28 + import { withLabel } from '../reporters/renderers/utils' 28 29 import { BaseSequencer } from '../sequencers/BaseSequencer' 29 30 import { RandomSequencer } from '../sequencers/RandomSequencer' 30 31 ··· 157 158 && viteConfig.test!.environment !== 'happy-dom' 158 159 ) { 159 160 logger.console.warn( 160 - c.yellow( 161 - `${c.inverse(c.yellow(' Vitest '))} Your config.test.environment ("${ 162 - viteConfig.test.environment 163 - }") conflicts with --dom flag ("happy-dom"), ignoring "${ 164 - viteConfig.test.environment 165 - }"`, 161 + withLabel( 162 + 'yellow', 163 + 'Vitest', 164 + `Your config.test.environment ("${viteConfig.test.environment}") conflicts with --dom flag ("happy-dom"), ignoring "${viteConfig.test.environment}"`, 166 165 ), 167 166 ) 168 167 }
+2 -5
packages/vitest/src/node/packageInstaller.ts
··· 3 3 import { isPackageExists } from 'local-pkg' 4 4 import c from 'tinyrainbow' 5 5 import { isTTY } from '../utils/env' 6 + import { withLabel } from './reporters/renderers/utils' 6 7 7 8 const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) 8 9 ··· 32 33 } 33 34 34 35 process.stderr.write( 35 - c.red( 36 - `${c.inverse( 37 - c.red(' MISSING DEPENDENCY '), 38 - )} Cannot find dependency '${dependency}'\n\n`, 39 - ), 36 + withLabel('red', 'MISSING DEPENDENCY', `Cannot find dependency '${dependency}'\n\n`), 40 37 ) 41 38 42 39 if (!isTTY) {
+1 -1
packages/vitest/src/node/reporters/renderers/utils.ts
··· 270 270 271 271 export function withLabel(color: 'red' | 'green' | 'blue' | 'cyan' | 'yellow', label: string, message?: string) { 272 272 const bgColor = `bg${color.charAt(0).toUpperCase()}${color.slice(1)}` as `bg${Capitalize<typeof color>}` 273 - return `${c.bold(c[bgColor](` ${label} `))} ${message ? c[color](message) : ''}` 273 + return `${c.bold(c.black(c[bgColor](` ${label} `)))} ${message ? c[color](message) : ''}` 274 274 } 275 275 276 276 export function padSummaryTitle(str: string): string {
+8
scripts/demo-with-label.ts
··· 1 + // pnpm dlx tsx scripts/demo-with-label.ts 2 + import { withLabel } from '../packages/vitest/src/node/reporters/renderers/utils.ts' 3 + 4 + console.log(withLabel('red', 'ERROR', 'This is an error message')) 5 + console.log(withLabel('green', 'SUCCESS', 'This is a success message')) 6 + console.log(withLabel('blue', 'INFO', 'This is an info message')) 7 + console.log(withLabel('cyan', 'DEBUG', 'This is a debug message')) 8 + console.log(withLabel('yellow', 'WARNING', 'This is a warning message'))