npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

karma-electron-launcher

v0.3.0

Published

A Karma Plugin. Launcher for github electron shell.

Downloads

3,681

Readme

karma-electron-launcher

Launcher for electron.


Karma launcher for GitHub Electron inspired by Karma Nodewebkit Launcher.


Installation

The easiest way is to keep karma-electron-launcher as a devDependency in your package.json.

For electron<=0.34.3, use karma-electron-launcher@~0.0.5.

{
  "devDependencies": {
    "karma": "~0.10",
    "karma-electron-launcher": "~0.3.0"
  }
}

You can do it on the command line by:

npm install karma-electron-launcher --save-dev

Configuration

// karma.conf.js
module.exports = function(config) {
  config.set({
    browsers: ['Electron']
  });
};

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

karma start --browsers Electron

Locally-installed Node modules

If you're using locally-installed Node modules via require in your code in the node_modules directory, you should be able to just require them, and they should be found by the testing environment.

Configuring the Electron BrowserWindow

Options passed to the new BrowserWindow() constructor can be defined by adding an electronOpts object to your karma config. Eg.

// karma.conf.js
module.exports = function(config) {
  config.set({
    browsers: ['Electron'],
    electronOpts: {
      title: 'my window title',
      // ...
    }
  });
};

Available options are specified in the Electron docs. By default, only the window dimensions (400x300) are set.

Application seeds

If you are looking for an application seed to start from you can check this one out: Karma Electron Launcher Simple Seed

Pass command line switches through to Chromium

If you need to pass command line switches through to Chromium then you can use the commandLineSwitches property of electronOpts. Define your switch as an array if it also accepts arguments. Supported switches are listed in the Electron docs.

// karma.conf.js
module.exports = function(config) {
  config.set({
    browsers: ['Electron'],
    electronOpts: {
      commandLineSwitches: [
        'disable-http-cache',
        'disable-http2',
        ['remote-debugging-port', '8315'],
        ['host-rules', 'MAP * 127.0.0.1'],
        ['js-flags', '--harmony_proxies --harmony_collections'],
      ],
    },
  });
};

Switches that are supported by Chromium but not specified in the Electron docs currently work too but this is an undocumented feature and may unexpectedly break:

// karma.conf.js
module.exports = function(config) {
  config.set({
    browsers: ['Electron'],
    electronOpts: {
      commandLineSwitches: [
        '--use-fake-ui-for-media-stream',
        '--use-fake-device-for-media-stream',
      ],
    },
  });
};

Configuring custom launchers

If you need to configure custom launchers differently to each other, then define electronOpts within the custom launcher config. This will be merged with electronOpts in the parent config object and override any properties already set. Custom launchers also allow you to provide additional flags to the electron executable.

// karma.conf.js
module.exports = function(config) {
  config.set({
    browsers: ['Electron', 'MyFirstLauncher', 'MySecondLauncher'],
    electronOpts: {
      title: 'default title',
    },
    customLaunchers: {
      MyFirstLauncher: {
        base: 'Electron',
      },
      MySecondLauncher: {
        base: 'Electron',
        electronOpts: {
          title: 'my custom title',
        },
        flags: ['--no-sandbox'],
      },
    },
  });
};

In this example the Electron and MyFirstLauncher launchers will have the title default title whereas MySecondLauncher will have the title my custom title.