Socket
Socket
Sign inDemoInstall

karma-chrome-launcher

Package Overview
Dependencies
2
Maintainers
4
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-chrome-launcher

A Karma plugin. Launcher for Chrome and Chrome Canary.


Version published
Maintainers
4
Weekly downloads
2,296,844
decreased by-1.75%

Weekly downloads

Package description

What is karma-chrome-launcher?

The karma-chrome-launcher npm package is a plugin for Karma, a test runner for JavaScript. It allows developers to execute tests in the Chrome browser. It can launch Chrome in various modes, control browser instances, and integrate with continuous integration systems.

What are karma-chrome-launcher's main functionalities?

Launching Chrome for testing

This feature allows you to configure Karma to use Chrome as the browser for running tests. You simply add 'Chrome' to the 'browsers' array in your Karma configuration.

module.exports = function(config) {
  config.set({
    browsers: ['Chrome'],
    // ... other Karma configuration ...
  });
};

Running tests in headless Chrome

This feature enables you to run tests in a headless Chrome instance, which is useful for continuous integration environments where you don't need a visible UI.

module.exports = function(config) {
  config.set({
    browsers: ['ChromeHeadless'],
    // ... other Karma configuration ...
  });
};

Customizing Chrome flags

This feature allows you to customize the Chrome instance by adding command-line flags to alter its behavior for testing purposes.

module.exports = function(config) {
  config.set({
    customLaunchers: {
      Chrome_with_flags: {
        base: 'Chrome',
        flags: ['--disable-web-security', '--disable-gpu']
      }
    },
    browsers: ['Chrome_with_flags'],
    // ... other Karma configuration ...
  });
};

Other packages similar to karma-chrome-launcher

Readme

Source

karma-chrome-launcher

js-standard-style npm version npm downloads

Build Status Dependency Status devDependency Status

Launcher for Google Chrome, Google Chrome Canary and Google Chromium.

Installation

The easiest way is to keep karma-chrome-launcher as a devDependency in your package.json, by running

$ npm i -D karma-chrome-launcher

Configuration

// karma.conf.js
module.exports = function(config) {
  config.set({
    browsers: ['Chrome', 'Chrome_without_security'], // You may use 'ChromeCanary', 'Chromium' or any other supported browser

    // you can define custom flags
    customLaunchers: {
      Chrome_without_security: {
        base: 'Chrome',
        flags: ['--disable-web-security', '--disable-site-isolation-trials']
      }
    }
  })
}

The --user-data-dir is set to a temporary directory but can be overridden on a custom launcher as shown below. One reason to do this is to have a permanent Chrome user data directory inside the project directory to be able to install plugins there (e.g. JetBrains IDE Support plugin).

customLaunchers: {
  Chrome_with_debugging: {
    base: 'Chrome',
    chromeDataDir: path.resolve(__dirname, '.chrome')
  }
}

You can pass list of browsers as a CLI argument too:

$ karma start --browsers Chrome,Chrome_without_security

Headless Chromium with Puppeteer

The Chrome DevTools team created Puppeteer - it will automatically install Chromium for all platforms and contains everything you need to run it from within your CI.

Available Browsers

Note: Headless mode requires a browser version >= 59

  • Chrome (CHROME_BIN)
  • ChromeHeadless (CHROME_BIN)
  • Chromium (CHROMIUM_BIN)
  • ChromiumHeadless (CHROMIUM_BIN)
  • ChromeCanary (CHROME_CANARY_BIN)
  • ChromeCanaryHeadless (CHROME_CANARY_BIN)
  • Dartium (DARTIUM_BIN)
Usage
$ npm i -D puppeteer karma-chrome-launcher
// karma.conf.js
process.env.CHROME_BIN = require('puppeteer').executablePath()

module.exports = function(config) {
  config.set({
    browsers: ['ChromeHeadless']
  })
}

For more information on Karma see the homepage.

Keywords

FAQs

Last updated on 20 Apr 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc