简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM