test: tests for error handling

This commit is contained in:
Evan You
2019-08-30 16:08:10 -04:00
parent d5684e1a9d
commit be28f976af
4 changed files with 329 additions and 11 deletions

View File

@@ -2,7 +2,8 @@ import {
ComponentInstance,
LifecycleHooks,
currentInstance,
setCurrentInstance
setCurrentInstance,
ComponentRenderProxy
} from './component'
import { callWithAsyncErrorHandling, ErrorTypeStrings } from './errorHandling'
import { warn } from './warning'
@@ -92,7 +93,11 @@ export function onRenderTracked(
}
export function onErrorCaptured(
hook: Function,
hook: (
err: Error,
instance: ComponentRenderProxy | null,
info: string
) => boolean | void,
target: ComponentInstance | null = currentInstance
) {
injectHook(LifecycleHooks.ERROR_CAPTURED, hook, target)

View File

@@ -443,6 +443,5 @@ function hasPropsChanged(prevProps: Data, nextProps: Data): boolean {
return true
}
}
console.log(111)
return false
}

View File

@@ -88,7 +88,7 @@ export function handleError(
errorCapturedHooks[i](
err,
instance && instance.renderProxy,
contextVNode
ErrorTypeStrings[type]
)
) {
return