我正在学习用于UI测试的QUnit单元测试。
我想通过QUnit测试带有asyncTest函数的AJAX CORS调用,以下是我的代码,
asyncTest("Async Test", 1, function () {
$.getJSON("http://oursite.com/api/product" + "/?PageSize=' + 25 + '&ActiveOnly=' + 1
+ '&Index=' + 0", function (data) {
deepEqual(data, {
status: "ok"
});
start();
});
});
但是IE给了我以下错误
1.死于测试#1:无效字符 - {“description”:“无效字符”,“数字”: - 2146827274,“stack”:“SyntaxError:parseJSON中无效字符(http://oursite.com/scripts/json.js:532:13)at at ajax(http://oursite.com/Scripts/jquery- 2.0.3.js:7276:4)在匿名函数(http://oursite.com/Scripts/jquery-2.0.3.js:7447:3)at getJSON(http://oursite.com/Scripts/jquery-2.0.3.js:7430:3)atonymous function(http://oursite.com/scripts/custom/JSUnitTest.js:64:5)at run({ {3}})在匿名函数(http://oursite.com/scripts/qunit.js:102:4)处的匿名函数(http://oursite.com/scripts/qunit.js:232:5)处匿名函数(http://oursite.com/scripts/qunit.js:869:4)“,”toJSONString“:function(a){[code]}, “parseJSON”:function(a){[code]}}
请注意:qunit asyncTest甚至没有进行AJAX调用,我猜它甚至在它做任何事情之前就失败了。这是一个PARSING错误,但为什么呢? 任何帮助将不胜感激。提前谢谢。