From be5fc7524a2b08f1ef9c5ef2abad863b6ff49156 Mon Sep 17 00:00:00 2001 From: Roy Sutton Date: Thu, 13 Aug 2020 18:37:28 -0400 Subject: [PATCH] Add excpetion catcher Enact-DCO-1.0-Signed-off-by: Roy Sutton roy.sutton@lge.com --- screenshot/errorHandler.js | 6 ++++++ screenshot/index.js | 1 + utils/runTest.js | 4 ++++ 3 files changed, 11 insertions(+) create mode 100644 screenshot/errorHandler.js diff --git a/screenshot/errorHandler.js b/screenshot/errorHandler.js new file mode 100644 index 00000000..3db9a79b --- /dev/null +++ b/screenshot/errorHandler.js @@ -0,0 +1,6 @@ +// A little utility to catch errors executing the test generation routines + +window.addEventListener('error', errorMsg => { + window.__TEST_DATA = 'Error occurred: ' + errorMsg.message; + return false; +}, {capture: true}); diff --git a/screenshot/index.js b/screenshot/index.js index 2dc66e58..05195c96 100644 --- a/screenshot/index.js +++ b/screenshot/index.js @@ -1,3 +1,4 @@ +import './errorHandler'; import React from 'react'; import {render} from 'react-dom'; import App, {testMetadata} from 'UI_TEST_APP_ENTRY'; diff --git a/utils/runTest.js b/utils/runTest.js index affc7fde..64c0e4b0 100644 --- a/utils/runTest.js +++ b/utils/runTest.js @@ -20,6 +20,10 @@ const runTest = ({concurrency, Page, skin, testName, ...rest}) => { return window.__TEST_DATA; // eslint-disable-line no-undef }); + if (typeof testCases === 'string') { + throw new Error(`Test data failed to load: ${testCases}.\n\nLoad page in a browser to view the error.`) + } + expect(testCases).to.be.an('object', 'Test data failed to load'); describe(testName, function () {