title: Running angular unit test in docker - Cannot load browser RangeError: Maximum call stack size exceeded
body: <p>I am having an issue running unit tests for an angular project inside a docker container. I've gone through everything I can think of but cant seem to find the issue. These tests run fine outside of docker using the same commands.</p>
  
  <p>I am using node:11.8.0-alpine with the latest version of chromium</p>
  
  <p>I am getting the below error:</p>
  
  <blockquote>
    <p>ERROR [launcher]: Cannot load browser "ChromeHeadless"!   RangeError:
    Maximum call stack size exceeded
        at String.match ()
        at /ng-app/node_modules/di/lib/annotation.js:30:17
        at Array.map ()
        at parse (/ng-app/node_modules/di/lib/annotation.js:29:42)
        at Array.invoke (/ng-app/node_modules/di/lib/injector.js:69:46)
        at Injector.get (/ng-app/node_modules/di/lib/injector.js:48:43)
        at module.(anonymous function) (/ng-app/node_modules/karma/lib/config.js:249:64)
        at Array.invoke (/ng-app/node_modules/di/lib/injector.js:75:15)
        at Injector.get (/ng-app/node_modules/di/lib/injector.js:48:43)
        at module.(anonymous function) (/ng-app/node_modules/karma/lib/config.js:249:64)
        at Array.invoke (/ng-app/node_modules/di/lib/injector.js:75:15)
        at Injector.get (/ng-app/node_modules/di/lib/injector.js:48:43)
        at module.(anonymous function) (/ng-app/node_modules/karma/lib/config.js:249:64)
        at Array.invoke (/ng-app/node_modules/di/lib/injector.js:75:15)
        at Injector.get (/ng-app/node_modules/di/lib/injector.js:48:43)
        at module.(anonymous function) (/ng-app/node_modules/karma/lib/config.js:249:64) 28 01 2019
    20:34:52.281:ERROR [karma-server]: Error: Found 1 load error
        at Server.webServer.listen (/ng-app/node_modules/karma/lib/server.js:182:27)
        at Object.onceWrapper (events.js:285:13)
        at Server.emit (events.js:202:15)
        at emitListeningNT (net.js:1290:10)
        at processTicksAndRejections (internal/process/next_tick.js:76:17) Cannot read property 'success' of undefined TypeError: Cannot read
    property 'success' of undefined
        at TestCommand.runSingleTarget (/ng-app/node_modules/@angular/cli/models/packages/angular/cli/models/architect-command.ts:242:21)
        at processTicksAndRejections (internal/process/next_tick.js:81:5) Segmentation fault</p>
  </blockquote>
  
  <p>Below is my karma config:</p>
  
  <pre><code>module.exports = function (config) {
    config.set({
      basePath: '',
      frameworks: ['jasmine', '@angular-devkit/build-angular'],
      plugins: [
        require('karma-jasmine'),
        require('karma-chrome-launcher'),
        require('karma-junit-reporter'),
        require('@angular-devkit/build-angular/plugins/karma')
      ],
      client: {
        clearContext: false // leave Jasmine Spec Runner output visible in browser
      },
      junitReporter: {
        outputDir: '/test-reports', // results will be saved as $outputDir/$browserName.xml
        outputFile: 'junit-report.xml', // if included, results will be saved as $outputDir/$browserName/$outputFile
        suite: '', // suite will become the package name attribute in xml testsuite element
        useBrowserName: false, // add browser name to report and classes names
      },
      reporters: ['junit'],
      port: 9876,
      colors: true,
      logLevel: config.LOG_INFO,
      autoWatch: false,
      browserNoActivityTimeout: 60000,
      browsers: ['ChromeHeadless'],
      customLaunchers: {
        ChromeHeadless: {
          base: 'ChromeHeadless',
          flags: [
            '--disable-web-security',
            '--disable-gpu',
            '--no-sandbox'
          ]
        }
      },
      singleRun: true
    });
  };
  </code></pre>
  
  <p>Versions:</p>
  
  <pre><code>"jasmine-core": "~3.3.0",
  "jasmine-spec-reporter": "~4.2.1",
  "karma": "~4.0.0",
  "karma-chrome-launcher": "~2.2.0",
  "karma-jasmine": "~2.0.1",
  "karma-jasmine-html-reporter": "^1.4.0",
  "karma-junit-reporter": "^1.2.0",
  "@angular-devkit/build-angular": "~0.12.2",
  "@angular/cli": "^7.2.3",
  "@angular/compiler-cli": "^7.2.2",
  </code></pre>