Skip to content

Commit

Permalink
docs: add onConsoleLog (#4115)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelobotega committed Sep 12, 2023
1 parent 3c30585 commit 19922d9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/config/index.md
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') {

Check failure on line 1637 in docs/config/index.md

View workflow job for this annotation

GitHub Actions / lint

Unnecessary { after 'if' condition
return false;

Check failure on line 1638 in docs/config/index.md

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon
}
},
},
})
```

0 comments on commit 19922d9

Please sign in to comment.