@@ -213,8 +213,11 @@ describe("connection tests", function () {
213
213
214
214
client . on ( 'error' , function ( err ) {
215
215
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 ) ) ;
218
221
done ( ) ;
219
222
} ) ;
220
223
} ) ;
@@ -464,9 +467,9 @@ describe("connection tests", function () {
464
467
} ;
465
468
client . on ( "ready" , function ( ) {
466
469
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
468
471
// 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 ) ) ;
470
473
assert ( delayed ) ;
471
474
end ( ) ;
472
475
} ) ;
@@ -495,9 +498,9 @@ describe("connection tests", function () {
495
498
} ;
496
499
client . on ( "ready" , function ( ) {
497
500
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
499
502
// 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 ) ) ;
501
504
assert ( delayed ) ;
502
505
end ( ) ;
503
506
} ) ;
0 commit comments