@@ -213,8 +213,11 @@ describe("connection tests", function () {
213213
214214 client . on ( 'error' , function ( err ) {
215215 assert ( / R e d i s c o n n e c t i o n i n b r o k e n s t a t e : c o n n e c t i o n t i m e o u t .* ?e x c e e d e d ./ . test ( err . message ) ) ;
216- assert ( Date . now ( ) - time < connect_timeout + 25 ) ;
217- assert ( Date . now ( ) - time >= connect_timeout - 3 ) ; // Timers sometimes trigger early (e.g. 1ms to early)
216+ // The code execution on windows is very slow at times
217+ var now = Date . now ( ) ;
218+ assert ( now - time < connect_timeout + 50 , 'The real timeout time should be below ' + ( connect_timeout + 50 ) + 'ms but is: ' + ( now - time ) ) ;
219+ // Timers sometimes trigger early (e.g. 1ms to early)
220+ assert ( now - time >= connect_timeout - 3 , 'The real timeout time should be above ' + connect_timeout + 'ms, but it is: ' + ( now - time ) ) ;
218221 done ( ) ;
219222 } ) ;
220223 } ) ;
@@ -464,9 +467,9 @@ describe("connection tests", function () {
464467 } ;
465468 client . on ( "ready" , function ( ) {
466469 var rest = Date . now ( ) - time ;
467- assert ( rest >= 500 ) ;
470+ assert ( rest >= 498 , 'Rest should be equal or above 500 ms but is: ' + rest ) ; // setTimeout might trigger early
468471 // Be on the safe side and accept 200ms above the original value
469- assert ( rest - 200 < 500 ) ;
472+ assert ( rest - 200 < 500 , 'Rest - 200 should be below 500 ms but is: ' + ( rest - 200 ) ) ;
470473 assert ( delayed ) ;
471474 end ( ) ;
472475 } ) ;
@@ -495,9 +498,9 @@ describe("connection tests", function () {
495498 } ;
496499 client . on ( "ready" , function ( ) {
497500 var rest = Date . now ( ) - time ;
498- assert ( rest >= 1000 ) ;
501+ assert ( rest >= 998 , '`rest` should be equal or above 1000 ms but is: ' + rest ) ; // setTimeout might trigger early
499502 // Be on the safe side and accept 200ms above the original value
500- assert ( rest - 200 < 1000 ) ;
503+ assert ( rest - 200 < 1000 , '`rest` - 200 should be below 1000 ms but is: ' + ( rest - 200 ) ) ;
501504 assert ( delayed ) ;
502505 end ( ) ;
503506 } ) ;
0 commit comments