1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Enable Chrome E2E logs (#11295)

Chrome logs are now enabled for E2E tests when the 'ENABLE_CHROME_LOGS'
environment variable is set to anything other than `false`.

This was helpful to me in debugging Chrome crashes on CI, the ones with
the error "unknown error: DevToolsActivePort file doesn't exist". This
was the only way to discover the cause of the error. It's also useful
for discovering console errors from the background process or from the
UI.

It's disabled by default because it makes the test output quite noisy
and difficult to read.
This commit is contained in:
Mark Stacey 2021-06-15 15:18:21 -02:30 committed by GitHub
parent feb989c12b
commit f7c37cab51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 3 deletions

View File

@ -0,0 +1,19 @@
diff --git a/node_modules/selenium-webdriver/chromium.js b/node_modules/selenium-webdriver/chromium.js
index d828ce5..87176f4 100644
--- a/node_modules/selenium-webdriver/chromium.js
+++ b/node_modules/selenium-webdriver/chromium.js
@@ -197,6 +197,14 @@ class ServiceBuilder extends remote.DriverService.Builder {
return this.addArguments('--log-path=' + path);
}
+ /**
+ * Enables Chrome logging.
+ * @returns {!ServiceBuilder} A self reference.
+ */
+ enableChromeLogging() {
+ return this.addArguments('--enable-chrome-logs');
+ }
+
/**
* Enables verbose logging.
* @return {!ServiceBuilder} A self reference.

View File

@ -14,10 +14,21 @@ class ChromeDriver {
const builder = new Builder()
.forBrowser('chrome')
.setChromeOptions(options);
if (port) {
const service = new chrome.ServiceBuilder().setPort(port);
builder.setChromeService(service);
const service = new chrome.ServiceBuilder();
// Enables Chrome logging.
// Especially useful for discovering why Chrome has crashed, but can also
// be useful for revealing console errors (from the page or background).
if (
process.env.ENABLE_CHROME_LOGGING &&
process.env.ENABLE_CHROME_LOGGING !== 'false'
) {
service.setStdio('inherit').enableChromeLogging();
}
if (port) {
service.setPort(port);
}
builder.setChromeService(service);
const driver = builder.build();
const chromeDriver = new ChromeDriver(driver);
const extensionId = await chromeDriver.getExtensionIdByName('MetaMask');