@rkuzsma/karma-docker-launcher

A Karma plugin. Launcher for browsers in Docker images.

karma-docker-launcher

Docker image launcher for Karma

This plugin allows you to use any Docker image containing a browser as a browser launcher.

Installation

Install using

$ npm install @rkuzsma/karma-docker-launcher --save-dev

Configuration

// karma.conf.js
module.exports = function(config) {
  config.set({
    plugins: [
      // Karma automatically require()s packages that start with karma-*,
      // but it does not recognize scoped packages, so we must be explicit.
      '@rkuzsma/karma-docker-launcher',
      'karma-*'
    ],
    browsers: [
      'DockerFirefoxHeadless',
      'DockerChromeHeadless'
    ],
    customLaunchers: {
      DockerFirefoxHeadless: {
        base: 'Docker',
        // Use your favorite Firefox headless image, e.g.:
        image: 'rkuzsma/firefox-headless-stable:latest'
        containerCommand: 'firefox ' +
          '-p headless ' +
          '-no-remote ' +
          '-headless ' +
          '-url $KARMA_URL'
      },
      DockerChromeHeadless: {
        base: 'Docker',
        // Use your favorite Chrome headless image, e.g.:
        image: 'alpeware/chrome-headless-stable:latest',
        containerCommand: 'google-chrome-stable ' +
          '--headless ' +
          '--no-sandbox ' +
          '--remote-debugging-port=9222 ' +
          '--user-data-dir=/userdata ' +
          '--no-default-browser-check ' +
          '--no-first-run ' +
          '--disable-default-apps ' +
          '--disable-popup-blocking ' +
          '--disable-translate ' +
          '--disable-background-timer-throttling ' +
          '--disable-renderer-backgrounding ' +
          '--disable-device-discovery-notifications ' +
          '--disable-software-rasterizer ' +
          '--no-gpu ' +
          '--mute-audio ' +
          '--hide-scrollbars ' +
          '$KARMA_URL'
      }
    }
  });
}

$KARMA_URL will be replaced at runtime with the URL of the Karma web server. If you are running Karma on localhost, the $KARMA_URL will point to host.docker.internal so that the container can access it.

For more information on Karma see the homepage.

HomePage

https://github.com/rkuzsma/karma-docker-launcher#readme

Repository

git://github.com/rkuzsma/karma-docker-launcher.git