Improve setTimeout stub

Making it sync breaks bluebird internals
(e.g. detection of unhandled rejections).

With this patch we make sure it's quick enough but still async
This commit is contained in:
Mariusz Nowak 2019-05-14 11:45:54 +02:00
parent c4e5509ba5
commit 73ea7fd9e0
No known key found for this signature in database
GPG Key ID: AA6F4CCD415BF299

View File

@ -255,7 +255,10 @@ describe('AwsProvider', () => {
describe('#request()', () => {
beforeEach(() => {
sinon.stub(global, 'setTimeout', (cb) => { cb(); });
const originalSetTimeout = setTimeout;
sinon.stub(global, 'setTimeout', (cb, timeout) => {
return originalSetTimeout(cb, Math.min(timeout || 0, 10));
});
});
afterEach(() => {