Closed andreineculau closed 10 years ago
Is this for mocking a response or for use in production such as concatenating 3 services?
I'm also running into the bug. I use deferred objects heavily in my web app and for unit testing it I need the mock ajax requests to return a deferred object that will resolve() when the request is complete (or reject() if they're set up to fail). Right now the ajax requests look like they never complete because I don't use the older callback model
Actually, I solved the problem. Had included sinon-qunit which activated fake timers. So the mockjax setTimeout was never getting called. :-P
Is there planned any progress on this?
Btw @fracmak, how exactly did you solve it :)?
it was a conflict between sinon and mockjax. Sinon had taken over setTimeout and prevented them from running except after certain calls, which prevented mockjax from completing. Once I figured that out async/promises worked just fine
I don't believe this is an issue with mockjax any longer. The library actually calls the underlying jQuery ajax()
method but simply passes in a fake xhr implementation. It then returns whatever is returned by jQuery's ajax()
method. In fact, there are specific tests for deferred objects.
Unless there are other concerns I'm going to close this one for now.
Just what the title says. Right now it's impossible to "resolve" the request at a later stage (don't read timeout).
Shouldn't you return a $.Deferred object instead?
Eg. I want to hook up into an ajax call and perform 3 other ajax calls "invisibly", concatenate the payloads and return one single payload