From 39b7ef6e0fd76b87b466f40a2364e949e44c60f1 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Fri, 11 May 2018 11:41:42 -0400 Subject: [PATCH] Testing: Fail E2E tests when uncaught page error occurs --- test/e2e/support/utils.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/e2e/support/utils.js b/test/e2e/support/utils.js index 1f6f0950323aaa..d73f7492f5e143 100644 --- a/test/e2e/support/utils.js +++ b/test/e2e/support/utils.js @@ -65,6 +65,17 @@ export async function newPost( postType ) { export async function newDesktopBrowserPage() { global.page = await browser.newPage(); + + page.on( 'pageerror', ( error ) => { + // Disable reason: `jest/globals` doesn't include `fail`, but it is + // part of the global context supplied by the underlying Jasmine: + // + // https://jasmine.github.io/api/3.0/global.html#fail + + // eslint-disable-next-line no-undef + fail( error ); + } ); + await page.setViewport( { width: 1000, height: 700 } ); }