Jasmine mocks ajax calls that don't work in IE

I tried to write a specification to fool Ajax calls. The test drive works great in browsers like Chrome and Firefox. But I encounter some problems when I run a IE test case (version 9.10). This issue occurs when regular Ajax calls are made using jQuery Ajax.

I get an error in IE as follows:

TypeError: Unable to get value of the property 'response': object is null or undefined. 

The test case I wrote is as follows

  describe("mocking ajax", function() { beforeEach(function() { jasmine.Ajax.install(); }); afterEach(function() { jasmine.Ajax.uninstall(); }); it("specifying response when you need it", function() { var doneFn = jasmine.createSpy("success"); var jqxhr = $.ajax({ url :"/any/service", success : function(data){ doneFn(data); } }); expect(doneFn).not.toHaveBeenCalled(); jasmine.Ajax.requests.mostRecent().response({ "status": 200, "contentType": 'text/plain', "responseText": 'awesome response' }); expect(doneFn).toHaveBeenCalledWith('awesome response'); }); }); 

Any help on this is welcome. Thanks in advance!

+7
javascript jquery internet-explorer tdd jasmine
source share
1 answer

Are you using jasmine-ajax? The issue raised about this in the github repository seems to have been fixed by a recent pull request.

IE Issue jasmine-ajax

0
source share

All Articles