@@ -314,6 +314,7 @@ describe('endpoint definition typings', () => {
314314 getState : expect . any ( Function ) ,
315315 signal : expect . any ( Object ) ,
316316 type : expect . any ( String ) ,
317+ queryCacheKey : expect . any ( String ) ,
317318 }
318319 beforeEach ( ( ) => {
319320 baseQuery . mockClear ( )
@@ -355,6 +356,7 @@ describe('endpoint definition typings', () => {
355356 abort : expect . any ( Function ) ,
356357 forced : expect . any ( Boolean ) ,
357358 type : expect . any ( String ) ,
359+ queryCacheKey : expect . any ( String ) ,
358360 } ,
359361 undefined ,
360362 ] ,
@@ -368,6 +370,7 @@ describe('endpoint definition typings', () => {
368370 abort : expect . any ( Function ) ,
369371 forced : expect . any ( Boolean ) ,
370372 type : expect . any ( String ) ,
373+ queryCacheKey : expect . any ( String ) ,
371374 } ,
372375 undefined ,
373376 ] ,
@@ -499,8 +502,24 @@ describe('endpoint definition typings', () => {
499502 expect ( baseQuery . mock . calls ) . toEqual ( [
500503 [ 'modified1' , commonBaseQueryApi , undefined ] ,
501504 [ 'modified2' , commonBaseQueryApi , undefined ] ,
502- [ 'modified1' , { ...commonBaseQueryApi , forced : undefined } , undefined ] ,
503- [ 'modified2' , { ...commonBaseQueryApi , forced : undefined } , undefined ] ,
505+ [
506+ 'modified1' ,
507+ {
508+ ...commonBaseQueryApi ,
509+ forced : undefined ,
510+ queryCacheKey : undefined ,
511+ } ,
512+ undefined ,
513+ ] ,
514+ [
515+ 'modified2' ,
516+ {
517+ ...commonBaseQueryApi ,
518+ forced : undefined ,
519+ queryCacheKey : undefined ,
520+ } ,
521+ undefined ,
522+ ] ,
504523 ] )
505524 } )
506525
@@ -1128,3 +1147,38 @@ describe('custom serializeQueryArgs per endpoint', () => {
11281147 } )
11291148 } )
11301149} )
1150+
1151+ describe ( 'timeout behavior' , ( ) => {
1152+ test ( 'triggers TIMEOUT_ERROR' , async ( ) => {
1153+ const api = createApi ( {
1154+ baseQuery : fetchBaseQuery ( { baseUrl : 'https://example.com' , timeout : 5 } ) ,
1155+ endpoints : ( build ) => ( {
1156+ query : build . query < unknown , void > ( {
1157+ query : ( ) => '/success' ,
1158+ } ) ,
1159+ } ) ,
1160+ } )
1161+
1162+ const storeRef = setupApiStore ( api , undefined , {
1163+ withoutTestLifecycles : true ,
1164+ } )
1165+
1166+ server . use (
1167+ http . get (
1168+ 'https://example.com/success' ,
1169+ async ( ) => {
1170+ await delay ( 10 )
1171+ return HttpResponse . json ( { value : 'failed' } , { status : 500 } )
1172+ } ,
1173+ { once : true } ,
1174+ ) ,
1175+ )
1176+
1177+ const result = await storeRef . store . dispatch ( api . endpoints . query . initiate ( ) )
1178+
1179+ expect ( result ?. error ) . toEqual ( {
1180+ status : 'TIMEOUT_ERROR' ,
1181+ error : expect . stringMatching ( / ^ A b o r t E r r o r : / ) ,
1182+ } )
1183+ } )
1184+ } )
0 commit comments