File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
packages/runtime-core/__tests__ Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 11import {
22 type VNode ,
3+ computed ,
34 createApp ,
45 defineComponent ,
56 h ,
@@ -639,5 +640,35 @@ describe('error handling', () => {
639640 )
640641 } )
641642
643+ // #11286
644+ test ( 'handle error in computed' , async ( ) => {
645+ const err = new Error ( )
646+ const handler = vi . fn ( )
647+
648+ const count = ref ( 1 )
649+ const x = computed ( ( ) => {
650+ if ( count . value === 2 ) throw err
651+ return count . value + 1
652+ } )
653+
654+ const app = createApp ( {
655+ setup ( ) {
656+ return ( ) => x . value
657+ } ,
658+ } )
659+
660+ app . config . errorHandler = handler
661+ app . mount ( nodeOps . createElement ( 'div' ) )
662+
663+ count . value = 2
664+
665+ await nextTick ( )
666+ expect ( handler ) . toHaveBeenCalledWith (
667+ err ,
668+ { } ,
669+ ErrorTypeStrings [ ErrorCodes . COMPONENT_UPDATE ] ,
670+ )
671+ } )
672+
642673 // native event handler handling should be tested in respective renderers
643674} )
You can’t perform that action at this time.
0 commit comments