From ed9a088c5b27738a3000b0bb567f3d24e057fe8c Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Tue, 10 Apr 2018 15:07:44 -0500 Subject: [PATCH] Issue #2375. Add some diagnostic logging for checkServer --- tests/functional/lib/setup.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/tests/functional/lib/setup.js b/tests/functional/lib/setup.js index 0d4b2460e..d0b3174ec 100644 --- a/tests/functional/lib/setup.js +++ b/tests/functional/lib/setup.js @@ -10,8 +10,8 @@ var url = function(path, params) { return params ? base + params : base; }; -/* -This method makes a call to our API and +/* +This method makes a call to our API and checks that the server is returning fixture data, it will also check if there's anything wrong with the server. */ @@ -20,23 +20,31 @@ intern.registerPlugin("checkServer", function() { return new Promise(function(resolve, reject) { var request = http.get(url("/api/issues/100"), function(response) { response.on("data", function(data) { - var json = JSON.parse(data); - if (!json.hasOwnProperty("_fixture")) { - reject( - new Error( - ` + try { + var json = JSON.parse(data); + if (!json.hasOwnProperty("_fixture")) { + console.log("Intern checkServer has failed: (json)\n\n", json); + reject( + new Error( + ` ======================================================= It seems like you didn't start the server in test mode. - Open another terminal and window type: + Open another terminal and window type: \x1b[32m npm run start:test\x1b[0m or \x1b[32m python run.py -t\x1b[0m ======================================================= ` - ) + ) + ); + } else { + resolve("All is well!"); + } + } catch (e) { + console.log(e); + reject( + new Error("Intern checkServer has failed trying to parse json") ); - } else { - resolve("All is well!"); } }); }); @@ -48,7 +56,7 @@ intern.registerPlugin("checkServer", function() { ` ====================================================== Oops, something went wrong. Try restarting the server. - Open another terminal and window type: + Open another terminal and window type: \x1b[32m npm run start:test\x1b[0m or \x1b[32m python run.py -t\x1b[0m