jasmine-ajax

Mocking jQuery ajax calls with Jasmine

寵の児 提交于 2020-01-25 22:02:29
问题 I am using Jasmine 2.5.2 to write unit tests for code that performs Ajax requests using jQuery 3.1.1 . I would like to mock out the Ajax call, providing my own response status and text. I am using the Jasmine ajax plug-in (https://github.com/pivotal/jasmine-ajax). Following the example on https://jasmine.github.io/2.0/ajax.html, which uses the XMLHttpRequest object, works fine. describe("mocking ajax", function() { describe("suite wide usage", function() { beforeEach(function() { jasmine.Ajax