mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
729 B
729 B
| title | outline |
|---|---|
| onConsoleLog | Config | deep |
onConsoleLog
function onConsoleLog(
log: string,
type: 'stdout' | 'stderr',
entity: TestModule | TestSuite | TestCase | undefined,
): boolean | void
Custom handler for console methods in tests. If you return false, Vitest will not print the log to the console. Note that Vitest ignores all other falsy values.
Can be useful for filtering out logs from third-party libraries.
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
onConsoleLog(log: string, type: 'stdout' | 'stderr'): boolean | void {
return !(log === 'message from third party library' && type === 'stdout')
},
},
})