tig*_*ger 7 javascript tdd jquery internet-explorer jasmine
我尝试编写一个允许Ajax调用被嘲笑的规范.测试用例在Chrome和Firefox等浏览器上运行得非常好.但是当我在IE上运行测试用例(版本9,10)时,我遇到了一些问题.当使用jQuery Ajax进行正常的Ajax调用时会出现此问题.
我在IE中收到错误如下:
TypeError: Unable to get value of the property 'response': object is null or undefined.
Run Code Online (Sandbox Code Playgroud)
我写的测试用例如下
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');
});
});
Run Code Online (Sandbox Code Playgroud)
有关此问题的任何帮助表示赞赏.提前致谢!
| 归档时间: |
|
| 查看次数: |
644 次 |
| 最近记录: |