From 85f884c6413b8457b66ad9c2a7d18e9cb04833fc Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Thu, 9 Jul 2020 12:01:39 -0300 Subject: [PATCH] Check browser logs in `withFixtures` e2e test helper (#8947) e2e test that use the `withFixtures` helper now check for console errors after each successful test. If any errors are found, the test fails. It's currently enabled for Chrome only, because the Firefox driver throws an error when you attempt to get the browser logs. Not sure why exactly, but it's a long-standing problem. --- test/e2e/helpers.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index 2d4e030ca..26d280d36 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -23,6 +23,15 @@ async function withFixtures (options, callback) { await callback({ driver, }) + + if (process.env.SELENIUM_BROWSER === 'chrome') { + const errors = await driver.checkBrowserForConsoleErrors(driver) + if (errors.length) { + const errorReports = errors.map((err) => err.message) + const errorMessage = `Errors found in browser console:\n${errorReports.join('\n')}` + throw new Error(errorMessage) + } + } } finally { await fixtureServer.stop() await ganacheServer.quit()