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
I'm having an issue with requests completed after cleaning mocks
$.mockjax({
url: '/hello',
responseTime: 10000,
responseText: "whatever"
});
$.get('/hello', function () {
console.log('I don't expect to get here');
});
$.mockjax.clear();
The request is already in progress when I clear mockjax, but all clear does is prevent other request from starting. The ones already in progress cannot be stopped.
Do you have any suggestions?
Best would be implement #184 and handle this case in the clear or dispose. A quicker approach would be to keep track of pending requests.
I can't do it from my code because .response is called after responseTime and there's no event onBeforeRequest or beforeSend.
$.mockjax.mockedAjaxCalls() gets close to my need, but it only contains a list of requests, there's no reference to mockRequest = _ajax.call(). I could do with a $.mockjax.mockedAjaxRequests() but this method is not available.
The text was updated successfully, but these errors were encountered:
Hmm... This is tricky, the issue is that the setTimeout call is only used when responseTime is provided, otherwise we just call the underlying (original) $.ajax() method and it takes however long it takes. As such, implementing a beforeResponse event would not be consistent. Similarly, we can check to see if the mock is still valid after the setTimeout call expires, but it will not be consistent as we cannot do that for calls directly to $.ajax().
I'm open to ideas, but implementing #184 won't do this, even if you implemented a clear on that returned object because it could not be consistently applied. I'm open to options, but I don't see a clear winner yet.
Hi
I'm having an issue with requests completed after cleaning mocks
The request is already in progress when I clear mockjax, but all clear does is prevent other request from starting. The ones already in progress cannot be stopped.
Do you have any suggestions?
Best would be implement #184 and handle this case in the
clear
ordispose
. A quicker approach would be to keep track of pending requests.I can't do it from my code because
.response
is called afterresponseTime
and there's no eventonBeforeRequest
orbeforeSend
.$.mockjax.mockedAjaxCalls()
gets close to my need, but it only contains a list of requests, there's no reference tomockRequest = _ajax.call()
. I could do with a$.mockjax.mockedAjaxRequests()
but this method is not available.The text was updated successfully, but these errors were encountered: