diff options
Diffstat (limited to 'tests/lib/screenshot-testing/support/test-environment.js')
-rw-r--r-- | tests/lib/screenshot-testing/support/test-environment.js | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/tests/lib/screenshot-testing/support/test-environment.js b/tests/lib/screenshot-testing/support/test-environment.js index d64bb4a56d..eb32f885b1 100644 --- a/tests/lib/screenshot-testing/support/test-environment.js +++ b/tests/lib/screenshot-testing/support/test-environment.js @@ -95,18 +95,19 @@ TestingEnvironment.prototype.callController = function (method, params) { }; TestingEnvironment.prototype._call = async function (params) { + let queryString = Object.keys(params).reduce(function (obj, name) { + if (params[name] instanceof Array) { + params[name].forEach(function(value, index) { + obj[name+'['+index+']'] = value; + }); + return obj; + } + obj[name] = params[name]; + return obj; + }, {}); let response = await request({ uri: resolveUrl(config.piwikUrl, '/tests/PHPUnit/proxy/index.php'), - qs: Object.keys(params).reduce(function (obj, name) { - if (params[name] instanceof Array) { - params[name].forEach(function(value, index) { - obj[name+'['+index+']'] = value; - }); - return obj; - } - obj[name] = params[name]; - return obj; - }, {}), + qs: queryString, }); if (response === '') { @@ -118,11 +119,11 @@ TestingEnvironment.prototype._call = async function (params) { try { response = JSON.parse(response); } catch (e) { - throw new Error("Unable to parse JSON response: " + response); + throw new Error("Unable to parse JSON response: " + response + " for query " + JSON.stringify(queryString)); } if (response.result === "error") { - throw new Error("API returned error: " + response.message); + throw new Error("API returned error: " + response.message + " for query " + JSON.stringify(queryString)); } return response; |