From f51a5c5c397c655e7b8cc182c620f85655e1d8a6 Mon Sep 17 00:00:00 2001
From: artin-phares <artin@artin.space>
Date: Wed, 26 Jun 2019 15:12:58 +0300
Subject: [PATCH] fix chrome headless issue when running as root

https://github.com/karma-runner/karma-chrome-launcher/issues/158
---
 tasks/utils/run-unit-tests.js | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tasks/utils/run-unit-tests.js b/tasks/utils/run-unit-tests.js
index 8b6993e..a427a0b 100644
--- a/tasks/utils/run-unit-tests.js
+++ b/tasks/utils/run-unit-tests.js
@@ -15,7 +15,7 @@ const KarmaServer = require('karma').Server;
  */
 function runUnitTests(opts) {
   return new Promise(function(resolve) {
-    let chrome = 'ChromeHeadless';
+    let chrome = 'ChromeHeadlessNoSandbox';
 
     if (require('os').platform() === 'win32') {
       // TODO: karma cannot capture headless chrome in windows 7,
@@ -47,6 +47,14 @@ function runUnitTests(opts) {
           stats: 'errors-only'
         },
 
+        customLaunchers: {
+          // chrome does not support running as root without --no-sandbox
+          ChromeHeadlessNoSandbox: {
+            base: 'ChromeHeadless',
+            flags: ['--no-sandbox']
+          }
+        },
+
         browsers: [chrome],
 
         frameworks: ['mocha'],