Don't know if this is the best place to report this. If it is not, please point me to where should I report this.
What did you expect to happen?
While using sinon fake timers, I expect that timeouts set inside a promise, which is wrapped in another promise, get triggered.
What actually happens
Timeouts set inside a Promise, which is wrapped in another promise, are not triggered.
How to reproduce
This works perfectly fine:
it(`should delay execution by 1 second`, function () {
const clock = sandbox.useFakeTimers();
const p = new Promise(function (resolve) {
setTimeout(resolve, 1000);
});
clock.tick(1000);
return p;
});
This doesn't work as expected, i.e. the resolve never gets called because the setTimeout callback is never triggered:
it(`should delay execution by 1 second`, function () {
const clock = sandbox.useFakeTimers();
const p = Promise.resolve()
.then(() => {
return new Promise(function (resolve) {
setTimeout(resolve, 1000); // resolve never gets called
});
});
clock.tick(1000);
return p;
});
Solved it. For future reference, this was what led me to the solution:
http://stackoverflow.com/a/43048888/582838
Most helpful comment
Solved it. For future reference, this was what led me to the solution:
http://stackoverflow.com/a/43048888/582838