feat(createRenderer): handle errors in function refs (#403)
This commit is contained in:
committed by
Evan You
parent
34989ef7fe
commit
325e15ef41
@@ -7,7 +7,8 @@ import {
|
||||
watch,
|
||||
ref,
|
||||
nextTick,
|
||||
mockWarn
|
||||
mockWarn,
|
||||
createComponent
|
||||
} from '@vue/runtime-test'
|
||||
|
||||
describe('error handling', () => {
|
||||
@@ -208,6 +209,29 @@ describe('error handling', () => {
|
||||
expect(fn).toHaveBeenCalledWith(err, 'render function')
|
||||
})
|
||||
|
||||
test('in function ref', () => {
|
||||
const err = new Error('foo')
|
||||
const ref = () => {
|
||||
throw err
|
||||
}
|
||||
const fn = jest.fn()
|
||||
|
||||
const Comp = {
|
||||
setup() {
|
||||
onErrorCaptured((err, instance, info) => {
|
||||
fn(err, info)
|
||||
return true
|
||||
})
|
||||
return () => h(Child)
|
||||
}
|
||||
}
|
||||
|
||||
const Child = createComponent(() => () => h('div', { ref }))
|
||||
|
||||
render(h(Comp), nodeOps.createElement('div'))
|
||||
expect(fn).toHaveBeenCalledWith(err, 'ref function')
|
||||
})
|
||||
|
||||
test('in watch (simple usage)', () => {
|
||||
const err = new Error('foo')
|
||||
const fn = jest.fn()
|
||||
|
||||
Reference in New Issue
Block a user