Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
您必须返回一个将调用回调的函数,如下所示:
it ("Test Function",function(){ var data = <json_data>; spyOn($, "getJSON").andReturn({success: function(c){c(data)}}); });
为了更容易进行 ajax 测试,我会建议sinonJS,它有一种简单的方法来使用假服务器模拟 ajax 。