title: How to mock delay with sinon?
body: <p>I have a method in a service that requires to wait 5000 ms exactly before returning.
  I need to unit test that method. I want to mock the delay using sinon <code>fakeTimers</code> because I don't want the entire unit test to actually wait 5000 ms.
  But I have 2 problems.</p>
  
  <p>1) The test freezes as soon as I use sinon fakeTimers. I am looking for a way to tick 5000 ms when the code reaches the delay line.</p>
  
  <p>2) How do I "assert" sure the value is returned exactly after 5000 ms, not 4999 ms, not 5001 ms ? (is that even possible ? )</p>
  
  <pre><code>class MyService {
      async doSomething(){
  
          await this.delay(5000)
          return 'Done'
      }
      delay(millis: number) {
          return new Promise((resolve, reject) =&gt; {
              setTimeout(() =&gt; {
                  resolve();
              }, millis);
          });
      }
  }
  describe('My Service', ()=&gt;{
      it('should return done after 5s',async ()=&gt;{
          const clock  = sinon.useFakeTimers(0)
          clock.tick(5000)
          const service = new MyService()
          const ans = await service.doSomething()
          expect(ans).to.equal('Done')
      })
  })
  </code></pre>