title: Karma Chrome Headless not working on Jenkins
body: <p>When I run the below setup with Docker locally on my mac everything works fine.</p>
  
  <p>But same setup does not work on Jenkins running on Ubuntu 16.04</p>
  
  <p><strong>ChromiumHeadless have not captured in 60000 ms, killing.</strong></p>
  
  <p>Following error log is from <strong>Jenkins console:</strong></p>
  
  <pre><code>25 05 2018 06:35:09.076:INFO [karma]: Karma v2.0.2 server started at http://0.0.0.0:9222/
  25 05 2018 06:35:09.079:INFO [launcher]: Launching browser Chromium_no_sandbox with unlimited concurrency
  25 05 2018 06:35:09.090:INFO [launcher]: Starting browser ChromiumHeadless
  25 05 2018 06:36:09.128:WARN [launcher]: ChromiumHeadless have not captured in 60000 ms, killing.
  25 05 2018 06:36:09.139:INFO [launcher]: Trying to start ChromiumHeadless again (1/2).
  25 05 2018 06:37:09.140:WARN [launcher]: ChromiumHeadless have not captured in 60000 ms, killing.
  25 05 2018 06:37:09.147:INFO [launcher]: Trying to start ChromiumHeadless again (2/2).
  </code></pre>
  
  <p><strong>Package.json</strong> ...
  <code>"testProd": "./node_modules/karma/bin/karma start karma.conf-prod.js --single-run",</code></p>
  
  <p><strong>Dockerfile</strong></p>
  
  <pre><code>FROM zenika/alpine-node:latest
  LABEL name="product-web"
  
  # Update apk repositories
  RUN echo "http://dl-2.alpinelinux.org/alpine/edge/main" &gt; /etc/apk/repositories
  RUN echo "http://dl-2.alpinelinux.org/alpine/edge/community" &gt;&gt; /etc/apk/repositories
  RUN echo "http://dl-2.alpinelinux.org/alpine/edge/testing" &gt;&gt; /etc/apk/repositories
  
  # Install chromium
  RUN apk -U --no-cache \
      --allow-untrusted add \
      zlib-dev \
      chromium \
      xvfb \
      wait4ports \
      xorg-server \
      dbus \
      ttf-freefont \
      mesa-dri-swrast \
      grep \
      udev \
      &amp;&amp; apk del --purge --force linux-headers binutils-gold gnupg zlib-dev libc-utils \
      &amp;&amp; rm -rf /var/lib/apt/lists/* \
      /var/cache/apk/* \
      /usr/share/man \
      /tmp/* \
      /usr/lib/node_modules/npm/man \
      /usr/lib/node_modules/npm/doc \
      /usr/lib/node_modules/npm/html \
      /usr/lib/node_modules/npm/scripts
  
  WORKDIR /home/dev/code
  COPY . .
  
  #RUN rm -rf node_modules &amp;&amp; npm cache clear --force
  
  ENV CHROME_BIN=/usr/bin/chromium-browser
  ENV CHROME_PATH=/usr/lib/chromium/
  
  RUN npm install
  RUN npm run testProd &amp;&amp; npm run buildProd
  </code></pre>
  
  <p><strong>karma.conf-prod.js</strong></p>
  
  <pre><code>const path = require('path');
  module.exports = function(config) {
      config.set({
          basePath: '',
          browsers: ['ChromeHeadlessNoSandbox'],
      customLaunchers: {
          ChromeHeadlessNoSandbox: {
              base: 'ChromeHeadless',
              flags: [
                  '--no-sandbox',
                  '--user-data-dir=/tmp/chrome-test-profile',
                  '--disable-web-security'
              ]
          }
      },
          frameworks: ['mocha', 'chai'],
          captureConsole: true,
          files: [
              'node_modules/babel-polyfill/dist/polyfill.js',
              'test/root.js'
          ],
          preprocessors: {
              'src/index.js': ['webpack', 'sourcemap'],
              'test/root.js': ['webpack']
          },
          webpack: {
              devtool: 'inline-source-map',
              module: {
                  loaders: [
                      {
                          test: /\.js$/,
                          loader: 'babel-loader',
                          exclude: path.resolve(__dirname, 'node_modules'),
                          query: {
                              plugins: ['transform-decorators-legacy', 'transform-regenerator'],
                              presets: ['env', 'stage-1', 'react']
                          }
                      },
                      {
                          test: /\.json$/,
                          loader: 'json-loader',
                      },
                  ]
              },
              externals: {
                  'react/addons': true,
                  'react/lib/ExecutionEnvironment': true,
                  'react/lib/ReactContext': true
              }
          },
          webpackServer: {
              noInfo: true
          },
          reporters: ['spec'],
          port: 9222,
          logLevel: config.LOG_INFO
      });
  };
  </code></pre>
  
  <p>I even tried with <code>logLevel: config.LOG_DEBUG</code> but did not show anything missing or unusual.</p>