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 1
1
import {
2
2
type VNode ,
3
+ computed ,
3
4
createApp ,
4
5
defineComponent ,
5
6
h ,
@@ -639,5 +640,35 @@ describe('error handling', () => {
639
640
)
640
641
} )
641
642
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
+
642
673
// native event handler handling should be tested in respective renderers
643
674
} )
You can’t perform that action at this time.
0 commit comments