import * as SUT from './index' ; describe ( 'sleep N milliseconds' , ( ) : void => { test ( 'should wait' , async ( ) : Promise < void > => { const wait = 3000 ; const startTime = new Date ( ) . getTime ( ) ; await SUT . sleep ( wait ) ; const endTime = new Date ( ) . getTime ( ) ; const duration = endTime - startTime ; const actualDiff = duration - wait ; console . log ( `measured duration - sleep duration = ${ actualDiff } ms` ) ; expect ( Math . abs ( actualDiff ) ) . toBeLessThan ( 500 ) ; } ) ; } ) ;