From 43a523cc5825a34ab3e4901c5e6597d0f1ee6f98 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 1 Apr 2020 18:24:10 +0200 Subject: [PATCH] script/cli-e2e-test: better error output when page load fails --- scripts/cli-e2e-test.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/cli-e2e-test.js b/scripts/cli-e2e-test.js index 3d4b9c04d1..c1e90ea0ce 100644 --- a/scripts/cli-e2e-test.js +++ b/scripts/cli-e2e-test.js @@ -19,6 +19,8 @@ const childProcess = require('child_process'); const { spawn } = childProcess; const Browser = require('zombie'); +const EXPECTED_LOAD_ERRORS = /connect ECONNREFUSED|did not get to load all resources/; + Browser.localhost('localhost', 3000); async function main() { @@ -146,11 +148,15 @@ async function waitForPageWithText( await browser.visit(path); break; } catch (error) { - attempts++; - if (attempts > maxAttempts) { - throw new Error( - `Failed to load page '${path}', max number of attempts reached`, - ); + if (error.message.match(EXPECTED_LOAD_ERRORS)) { + attempts++; + if (attempts > maxAttempts) { + throw new Error( + `Failed to load page '${path}', max number of attempts reached`, + ); + } + } else { + throw error; } } } @@ -164,7 +170,7 @@ async function waitForPageWithText( } function handleError(err) { - process.stdout.write(`${err.name}: ${err.message}\n`); + process.stdout.write(`${err.name}: ${err.stack || err.message}\n`); if (typeof err.code === 'number') { process.exit(err.code); } else {