diff --git a/docs/config/index.md b/docs/config/index.md index dafbf07761f3..3420beb87c16 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -1619,3 +1619,26 @@ By default Vitest will run all of your test cases even if some of them fail. Thi - **Version:** Since Vitest 0.32.3 Retry the test specific number of times if it fails. + +### onConsoleLog + +- **Type**: `(log: string, type: 'stdout' | 'stderr') => false | void` + +Custom handler for `console.log` in tests. If you return `false`, Vitest will not print the log to the console. + +Can be useful for filtering out logs from third-party libraries. + +```ts +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + onConsoleLog(log: string, type: 'stdout' | 'stderr'): boolean | void { + if (log === 'message from third party library' && type === 'stdout') { + return false; + } + }, + }, +}) +``` +