【发布时间】:2015-04-28 20:49:32
【问题描述】:
我想用僵尸 js 来测试我的小节点应用程序。 我正在使用带有僵尸的模拟资源,但是当我写的时候
主体:对象
在 mock.the xhr 总是因为
而失败Request Failed: parsererror, SyntaxError: Unexpected token o
当我写作时
正文:'json 内容'
xhr 运行良好
测试这个客户端js
var xhrGetRiver = $.getJSON("api/1/settings/rivers/fs/")
xhrGetRiver.done(function(json) {
console.log(json);
$.each(json, function(index, fsriver) {
insertFSRiver(fsriver);
});
});
xhrGetRiver.fail(function(jqxhr, textStatus, error) {
var err = textStatus + ', ' + error;
console.log("Request Failed: " + err);
});
我已经写了这个测试
var data = [];
var json = {
"id": "test",
"properties": {
"url": "/tmp",
"server": "192.168.9.2",
"port": 22,
"username": "testUser",
"password": "test",
"protocol": "ssh",
"update_rate": "15m",
"includes": "*.docx"
}
};
data.push(json);
this.browser.resources.mock('/api/1/settings/rivers/fs/', {
statusCode: 200,
headers: { 'ContentType': 'application/json' },
body: data // xhr fail
//body: '[ { "id":... ... } ]' // Work well
【问题讨论】:
标签: javascript jquery json zombie.js