@@ -12,8 +12,17 @@ export const reconnectStepDefinitions: StepDefinitions = ({ given, and, when, th
1212 let readyRunCount = 0 ;
1313 let errorHandlerRun = 0 ;
1414
15+ /**
16+ * This describe block and retry settings are calibrated to gRPC's retry time
17+ * and our testing container's restart cadence.
18+ */
19+ const retryTimes = 240 ;
20+ jest . retryTimes ( retryTimes ) ;
21+ const retryDelayMs = 5000 ;
22+
1523 beforeAll ( ( done ) => {
1624 client . addHandler ( ProviderEvents . Ready , ( ) => {
25+ readyRunCount ++ ;
1726 done ( ) ;
1827 } ) ;
1928 } ) ;
@@ -23,20 +32,17 @@ export const reconnectStepDefinitions: StepDefinitions = ({ given, and, when, th
2332 errorRunCount ++ ;
2433 } ) ;
2534
26- client . addHandler ( ProviderEvents . Ready , ( ) => {
27- readyRunCount ++ ;
28- } ) ;
2935 } ) ;
3036 then ( 'the PROVIDER_READY handler must run when the provider connects' , async ( ) => {
3137 // should already be at 1 from `beforeAll`
3238 expect ( readyRunCount ) . toEqual ( 1 ) ;
3339 } ) ;
3440 and ( "the PROVIDER_ERROR handler must run when the provider's connection is lost" , async ( ) => {
35- await new Promise ( ( resolve ) => setTimeout ( resolve , 10000 ) ) ;
41+ await new Promise ( ( resolve ) => setTimeout ( resolve , retryDelayMs ) ) ;
3642 expect ( errorRunCount ) . toBeGreaterThan ( 0 ) ;
3743 } ) ;
3844 and ( 'when the connection is reestablished the PROVIDER_READY handler must run again' , async ( ) => {
39- await new Promise ( ( resolve ) => setTimeout ( resolve , 10000 ) ) ;
45+ await new Promise ( ( resolve ) => setTimeout ( resolve , retryDelayMs ) ) ;
4046 expect ( readyRunCount ) . toBeGreaterThan ( 1 ) ;
4147 } ) ;
4248 when ( 'a flagd provider is set and initialization is awaited' , ( ) => {
0 commit comments