Skip to content

Commit

Permalink
docs: add onConsoleLog (vitest-dev#4115)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelobotega authored and LorenzoBloedow committed Dec 19, 2023
1 parent 544360a commit 38152ca
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
},
},
})
```

0 comments on commit 38152ca

Please sign in to comment.