@@ -1064,7 +1064,15 @@ describe('useMutation', () => {
10641064 } )
10651065 } )
10661066
1067- it ( 'should go to error state if onError callback errors' , async ( ) => {
1067+ it ( 'should go to error state if onError callback errors' , async ( {
1068+ onTestFinished,
1069+ } ) => {
1070+ const unhandledRejectionFn = vi . fn ( )
1071+ process . on ( 'unhandledRejection' , ( error ) => unhandledRejectionFn ( error ) )
1072+ onTestFinished ( ( ) => {
1073+ process . off ( 'unhandledRejection' , unhandledRejectionFn )
1074+ } )
1075+
10681076 const error = new Error ( 'error from onError' )
10691077 const mutateFnError = new Error ( 'mutateFnError' )
10701078
@@ -1074,10 +1082,7 @@ describe('useMutation', () => {
10741082 await sleep ( 10 )
10751083 throw mutateFnError
10761084 } ,
1077- onError : ( ) => {
1078- console . log ( 'REJECTING....' )
1079- Promise . reject ( error )
1080- } ,
1085+ onError : ( ) => Promise . reject ( error ) ,
10811086 } )
10821087
10831088 return (
@@ -1104,7 +1109,15 @@ describe('useMutation', () => {
11041109 ) . toBeInTheDocument ( )
11051110 } )
11061111
1107- it ( 'should go to error state if onSettled callback errors' , async ( ) => {
1112+ it ( 'should go to error state if onSettled callback errors' , async ( {
1113+ onTestFinished,
1114+ } ) => {
1115+ const unhandledRejectionFn = vi . fn ( )
1116+ process . on ( 'unhandledRejection' , ( error ) => unhandledRejectionFn ( error ) )
1117+ onTestFinished ( ( ) => {
1118+ process . off ( 'unhandledRejection' , unhandledRejectionFn )
1119+ } )
1120+
11081121 const error = new Error ( 'error from onSettled' )
11091122 const mutateFnError = new Error ( 'mutateFnError' )
11101123 const onError = vi . fn ( )
0 commit comments