fix timing issue in weather tests => returning response by url instead of index

This commit is contained in:
Felix Wiedenbach
2020-02-10 18:56:55 +01:00
parent d7295948fd
commit de6a9f5811
2 changed files with 21 additions and 28 deletions

View File

@@ -3,7 +3,7 @@ function plugin (wdInstance, requests) {
throw new Error("You can't use WebdriverAjaxStub with this version of WebdriverIO");
}
function stub(requests, done) {
function stub({template, data}, done) {
window.XMLHttpRequest = function () {
this.open = function (method, url) {
this.method = method;
@@ -13,7 +13,7 @@ function plugin (wdInstance, requests) {
this.send = function () {
this.status = 200;
this.readyState = 4;
const response = requests.shift() || [];
const response = this.url.includes('.njk') ? template : data;
this.response = response;
this.responseText = response;
this.onreadystatechange();