You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use the request npm module (https://github.com/mikeal/request) for doing requests, but it freezes when useFakeTimers uses the setImmediate method. Seems like faking the global setImmediate function is not done correctly by SinonJS.
The code that does not work (be aware: this is a stupid test, but just points out that the code freezes):
var sinon = require('sinon');
var libRequest = require('request');
var now = new Date.now();
var clock;
it('is a testing example!', function (done) {
clock = sinon.useFakeTimers(now);
libRequest.get({
url: 'http://www.example.com'
}, function() {
done();
});
});
The workaround is kind-a simple for our use-case, since we are only testing functionality that has to do with the Date object:
var sinon = require('sinon');
var libRequest = require('request');
var now = new Date.now();
var clock;
it('is a testing example!', function (done) {
clock = sinon.useFakeTimers(now, 'Date');
libRequest.get({
url: 'http://www.example.com'
}, function() {
done();
});
});
However, the issue is that faking the setImmediate function seems to break stuff, which needs to be resolved.
The text was updated successfully, but these errors were encountered:
We use the request npm module (https://github.com/mikeal/request) for doing requests, but it freezes when useFakeTimers uses the
setImmediate
method. Seems like faking the globalsetImmediate
function is not done correctly by SinonJS.The code that does not work (be aware: this is a stupid test, but just points out that the code freezes):
The code freezes and never finishes, probably because the request module uses the
setImmediate
function somewhere in its code (https://github.com/mikeal/request/search?q=setImmediate&ref=cmdform).The workaround is kind-a simple for our use-case, since we are only testing functionality that has to do with the
Date
object:However, the issue is that faking the
setImmediate
function seems to break stuff, which needs to be resolved.The text was updated successfully, but these errors were encountered: