私はアプリケーションコードを変更する必要がないソリューションを見つけたと思います。それはきれいではありませんが、動作するようです:
/**
* If you have a problem...
* if no one else can help...
* and if you can find them...
* maybe you can hire...
* fakeXHR.
*
* Overwrites XMLHttpRequest and auto resoles with status and response
* @param {Number} status The statuscode to resolve with
* @param {String} response, The response to resolve with
*/
function fakeXHR(status, response) {
browser.executeScript(function (args) {
var status = args[0];
var response = args[1];
function FakeXHR() {
this.open = function() {}
this.send = function() {}
this.setRequestHeader = function() {}
setTimeout(function() {
this.response = response;
this.status = status;
this.onload();
}.bind(this), 0);
}
XMLHttpRequest = FakeXHR;
}, [status, response])
}
http://stackoverflow.com/a/35141543/725866あなたが探してますがでHTTPクライアントを置換する方法を示している正確に何ではないかもしれませんモック –
ありがとう、しかし、私は別のやり方で取り組んだ、私は自分の質問に答えました... –