Open piuccio opened 8 years ago
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.