From 3020571b68fc1024fe88ac9c892d6265f031d2cb Mon Sep 17 00:00:00 2001 From: Jan Martin Date: Thu, 12 Sep 2024 13:28:53 -0700 Subject: [PATCH] test: allow Chrome sandbox opt-out (`--no-sandbox`) In some environments, e.g. containers or in some cases macOS, headless Chrome may not work with the sandbox enabled. This exposes an escape hatch to run tests in those environments. Example use: ```sh yarn bazel test \ //packages/angular_devkit/build_angular:build_angular_karma_test \ --test_env=PUPPETEER_EXECUTABLE_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \ --test_env=CHROME_NO_SANDBOX=1 ``` --- .../testing/builder/projects/hello-world-app/karma.conf.js | 5 ++++- .../test/hello-world-lib/projects/lib/karma.conf.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/testing/builder/projects/hello-world-app/karma.conf.js b/modules/testing/builder/projects/hello-world-app/karma.conf.js index 36d6f69333d6..7ad5e58e8efc 100644 --- a/modules/testing/builder/projects/hello-world-app/karma.conf.js +++ b/modules/testing/builder/projects/hello-world-app/karma.conf.js @@ -45,7 +45,10 @@ module.exports = function(config) { customLaunchers: { ChromeHeadlessCI: { base: 'ChromeHeadless', - flags: ['--disable-gpu'], + flags: [ + '--disable-gpu', + ...(process.env.CHROME_NO_SANDBOX === '1' ? ['--no-sandbox'] : []), + ], }, }, singleRun: false, diff --git a/packages/angular_devkit/build_angular/test/hello-world-lib/projects/lib/karma.conf.js b/packages/angular_devkit/build_angular/test/hello-world-lib/projects/lib/karma.conf.js index c109b07ac6b3..949ae97608d3 100644 --- a/packages/angular_devkit/build_angular/test/hello-world-lib/projects/lib/karma.conf.js +++ b/packages/angular_devkit/build_angular/test/hello-world-lib/projects/lib/karma.conf.js @@ -40,7 +40,10 @@ module.exports = function (config) { customLaunchers: { ChromeHeadlessCI: { base: 'ChromeHeadless', - flags: ['--disable-gpu'] + flags: [ + '--disable-gpu', + ...(process.env.CHROME_NO_SANDBOX === '1' ? ['--no-sandbox'] : []), + ], } }, singleRun: false