Ember.js can't mock ajax using jquery-mockjax

437 views Asked by At

I use jquery-mockjax to mock my AJAX request for my tests and after I upgraded my ember from 2.3.0 -> 2.10.0 it no longer works because my service is using Ember.$.ajax() instead of directly $.ajax()

any idea how to make mockjax still work with Ember.$.ajax()? Or shall I just replace all Ember.$.ajax() instance to $.ajax()? Is this the only way?

1

There are 1 answers

0
GantengX On BEST ANSWER

Figured out the reason why mockjax didn't work (failed on Ember 2.9 -> 2.10 upgrade). I actually have additional jQuery dependency in my bower file and on ember-cli-build I actually imported jQuery. In Ember 2.10, reimporting jQuery somehow overrides the global instance, hence Ember.$ !== $ while in the previous versions it worked fine.