File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -2191,6 +2191,30 @@ export default defineConfig({
21912191})
21922192` ` `
21932193
2194+ ### onUnhandledError < NonProjectOption / > {#onunhandlederror }
2195+
2196+ - ** Type :** ` (error: (TestError | Error) & { type: string }) => boolean | void `
2197+
2198+ A custom handler to filter out unhandled errors that should not be reported . If an error is filtered out , it will no longer affect the test results .
2199+
2200+ If you want unhandled errors to be reported without impacting the test outcome , consider using the [` dangerouslyIgnoreUnhandledErrors ` ](#dangerouslyIgnoreUnhandledErrors ) option
2201+
2202+ ` ` ` ts
2203+ import type { ParsedStack } from 'vitest'
2204+ import { defineConfig } from 'vitest/config'
2205+
2206+ export default defineConfig({
2207+ test: {
2208+ onUnhandledError(error): boolean | void {
2209+ // Ignore all errors with the name "MySpecialError".
2210+ if (error.name === 'MySpecialError') {
2211+ return false
2212+ }
2213+ },
2214+ },
2215+ })
2216+ ` ` `
2217+
21942218### diff
21952219
21962220- ** Type :** ` string `
You can’t perform that action at this time.
0 commit comments