sindresorhus/delay

(BUG) SINON <> DELAY - Bug when using Sinon 'useFakeTimers' and Delay

Closed this issue · 2 comments

When using Sinon in my project to test my application, I realized that the test never stopped running and after some time I ended up discovering this "incompatibility".

Here is an example code to reproduce the problem:

const sinon = require('sinon'); // 9.0.2
const delay = require('delay'); // 4.3.0

async function run() {
  sinon.useFakeTimers(1590721200000);
  await delay(1000);
  console.log('This message will never be executed !!!');
}
run();

delay is working fine without Sinon fake timers, so I think this issue should be in the Sinon issue tracker instead.

delay is working fine without Sinon fake timers, so I think this issue should be in the Sinon issue tracker instead.

I don't think it's a problem in either repository, I just need help trying to solve it, maybe a work around.

@sindresorhus how could I mock the lib delay? maybe it would help me?