Skip to content

Commit

Permalink
fix: --disable-gpu only on CI and CODESPACES (#23682)
Browse files Browse the repository at this point in the history
Fixes the problem reported by @bowensanders and @hjetpoluru where some Snaps E2E tests get errors in local testing.

Issue:- 
When executing snaps tests locally in chrome browser, the tests would pass, but the browser could not close properly. This resulted in a failure message being logged in the console as follows:
type="Error"><![CDATA[Error: Error: Failed to get WebGL context 

Test scenario :- test/e2e/snaps/test-snap-bip-32.spec.js
[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23682?quickstart=1)
  • Loading branch information
HowardBraham authored Mar 25, 2024
1 parent 8284b9c commit 737fdb1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/e2e/webdriver/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ class ChromeDriver {
static async build({ openDevToolsForTabs, port }) {
const args = [
`--proxy-server=${HTTPS_PROXY_HOST}`, // Set proxy in the way that doesn't interfere with Selenium Manager
'--disable-features=OptimizationGuideModelDownloading,OptimizationHintsFetching,OptimizationTargetPredicition,OptimizationHints,NetworkTimeServiceQuerying', // Stop chrome from calling home so much (auto-downloads of AI models; time sync)
'--disable-features=OptimizationGuideModelDownloading,OptimizationHintsFetching,OptimizationTargetPrediction,OptimizationHints,NetworkTimeServiceQuerying', // Stop chrome from calling home so much (auto-downloads of AI models; time sync)
'--disable-component-update', // Stop chrome from calling home so much (auto-update)
`--disable-gpu`,
`--disable-dev-shm-usage`,
'--disable-dev-shm-usage',
];

if (process.env.MULTIPROVIDER) {
Expand All @@ -43,25 +42,33 @@ class ChromeDriver {
} else {
args.push('--log-level=3');
}

if (process.env.CI || process.env.CODESPACES) {
args.push('--disable-gpu');
}

if (process.env.SELENIUM_HEADLESS) {
// TODO: Remove notice and consider non-experimental when results are consistent
console.warn(
'*** Running e2e tests in headless mode is experimental and some tests are known to fail for unknown reasons',
);
args.push('--headless=new');
}

const options = new chrome.Options().addArguments(args);
options.setAcceptInsecureCerts(true);
options.setUserPreferences({
'download.default_directory': `${process.cwd()}/test-artifacts/downloads`,
});

// Allow disabling DoT local testing
if (process.env.SELENIUM_USE_SYSTEM_DN) {
options.setLocalState({
'dns_over_https.mode': 'off',
'dns_over_https.templates': '',
});
}

const builder = new Builder()
.forBrowser('chrome')
.setChromeOptions(options);
Expand All @@ -73,9 +80,11 @@ class ChromeDriver {
if (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);
Expand Down

0 comments on commit 737fdb1

Please sign in to comment.