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!
javascript jquery internet-explorer tdd jasmine
tiger
source share