karma.conf.js
function allUsableBrowserLaunchers(config) {
  var browsers = [];

  // Load all launcher plugins.
  // The format of the items in this list is something like:
  // {
  //   'launcher:foo1': ['type', Function],
  //   'launcher:foo2': ['type', Function],
  // }
  // Where the launchers grouped together into one item were defined by a single
  // plugin, and the Functions in the inner array are the constructors for those
  // launchers.
  var plugins = require('karma/lib/plugin').resolve(['karma-*-launcher']);
  plugins.forEach(function(map) {
    Object.keys(map).forEach(function(name) {
      // Launchers should all start with 'launcher:', but occasionally we also
      // see 'test' come up for some reason.
      if (!name.startsWith('launcher:')) return;

      var browserName = name.split(':')[1];
      var pluginConstructor = map[name][1];

      // Most launchers requiring configuration through customLaunchers have
      // no DEFAULT_CMD.  Some launchers have DEFAULT_CMD, but not for this
      // platform.  Finally, WebDriver has DEFAULT_CMD, but still requires
      // configuration, so we simply blacklist it by name.
      var DEFAULT_CMD = pluginConstructor.prototype.DEFAULT_CMD;
      if (!DEFAULT_CMD || !DEFAULT_CMD[process.platform]) return;
      if (browserName == 'WebDriver') return;

      // Now that we've filtered out the browsers that can't be launched without
      // custom config or that can't be launched on this platform, we filter out
      // the browsers you don't have installed.
      var ENV_CMD = pluginConstructor.prototype.ENV_CMD;
      var browserPath = process.env[ENV_CMD] || DEFAULT_CMD[process.platform];

      if (!fs.existsSync(browserPath) &&
          !which.sync(browserPath, {nothrow: true})) return;

      browsers.push(browserName);
    });
  });

  // Once we've found the names of all the standard launchers, add to that list
  // the names of any custom launcher configurations.
  if (config.customLaunchers) {
    browsers.push.apply(browsers, Object.keys(config.customLaunchers));
  }

  return browsers;
}
function allUsableBrowserLaunchers(config) {
  var browsers = [];

  // Load all launcher plugins.
  // The format of the items in this list is something like:
  // {
  //   'launcher:foo1': ['type', Function],
  //   'launcher:foo2': ['type', Function],
  // }
  // Where the launchers grouped together into one item were defined by a single
  // plugin, and the Functions in the inner array are the constructors for those
  // launchers.
  var plugins = require('karma/lib/plugin').resolve(['karma-*-launcher']);
  plugins.forEach(function(map) {
    Object.keys(map).forEach(function(name) {
      // Launchers should all start with 'launcher:', but occasionally we also
      // see 'test' come up for some reason.
      if (!name.startsWith('launcher:')) return;

      var browserName = name.split(':')[1];
      var pluginConstructor = map[name][1];

      // Most launchers requiring configuration through customLaunchers have
      // no DEFAULT_CMD.  Some launchers have DEFAULT_CMD, but not for this
      // platform.  Finally, WebDriver has DEFAULT_CMD, but still requires
      // configuration, so we simply blacklist it by name.
      var DEFAULT_CMD = pluginConstructor.prototype.DEFAULT_CMD;
      if (!DEFAULT_CMD || !DEFAULT_CMD[process.platform]) return;
      if (browserName == 'WebDriver') return;

      // Now that we've filtered out the browsers that can't be launched without
      // custom config or that can't be launched on this platform, we filter out
      // the browsers you don't have installed.
      var ENV_CMD = pluginConstructor.prototype.ENV_CMD;
      var browserPath = process.env[ENV_CMD] || DEFAULT_CMD[process.platform];

      if (!fs.existsSync(browserPath) &&
          !which.sync(browserPath, {nothrow: true})) return;

      browsers.push(browserName);
    });
  });

  // Once we've found the names of all the standard launchers, add to that list
  // the names of any custom launcher configurations.
  if (config.customLaunchers) {
    browsers.push.apply(browsers, Object.keys(config.customLaunchers));
  }

  return browsers;
}
function allUsableBrowserLaunchers ( config ) { var browsers = [ ] ; // Load all launcher plugins. // The format of the items in this list is something like: // { //   'launcher:foo1': ['type', Function], //   'launcher:foo2': ['type', Function], // } // Where the launchers grouped together into one item were defined by a single // plugin, and the Functions in the inner array are the constructors for those // launchers. var plugins = require ( 'karma/lib/plugin' ) . resolve ( [ 'karma-*-launcher' ] ) ; plugins . forEach ( function ( map ) { Object . keys ( map ) . forEach ( function ( name ) { // Launchers should all start with 'launcher:', but occasionally we also // see 'test' come up for some reason. if ( ! name . startsWith ( 'launcher:' ) ) return ; var browserName = name . split ( ':' ) [ 1 ] ; var pluginConstructor = map [ name ] [ 1 ] ; // Most launchers requiring configuration through customLaunchers have // no DEFAULT_CMD.  Some launchers have DEFAULT_CMD, but not for this // platform.  Finally, WebDriver has DEFAULT_CMD, but still requires // configuration, so we simply blacklist it by name. var DEFAULT_CMD = pluginConstructor . prototype . DEFAULT_CMD ; if ( ! DEFAULT_CMD || ! DEFAULT_CMD [ process . platform ] ) return ; if ( browserName == 'WebDriver' ) return ; // Now that we've filtered out the browsers that can't be launched without // custom config or that can't be launched on this platform, we filter out // the browsers you don't have installed. var ENV_CMD = pluginConstructor . prototype . ENV_CMD ; var browserPath = process . env [ ENV_CMD ] || DEFAULT_CMD [ process . platform ] ; if ( ! fs . existsSync ( browserPath ) && ! which . sync ( browserPath , { nothrow : true } ) ) return ; browsers . push ( browserName ) ; } ) ; } ) ; // Once we've found the names of all the standard launchers, add to that list // the names of any custom launcher configurations. if ( config . customLaunchers ) { browsers . push . apply ( browsers , Object . keys ( config . customLaunchers ) ) ; } return browsers ; }
Determines which launchers and customLaunchers can be used and returns an array of strings.
Determines which launchers and customLaunchers can be used and returns an array of strings .