Socket
Socket
Sign inDemoInstall

karma-sauce-launcher

Package Overview
Dependencies
Maintainers
3
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-sauce-launcher

A Karma plugin. Launch any browser on SauceLabs!


Version published
Weekly downloads
19K
decreased by-12.16%
Maintainers
3
Weekly downloads
 
Created
Source

karma-sauce-launcher

js-standard-style npm version npm downloads semantic-release

Build Status Dependency Status devDependency Status

Karma Plus Sauce

Run your unit tests on Sauce Labs' browser cloud!

Installation

Install karma-sauce-launcher as a devDependency in your package.json:

npm install karma-sauce-launcher --save-dev

Usage

This launcher is typically used in CI to run your unit tests across many browsers and platforms on Sauce Labs. However, you can also use it locally to debug tests in browsers not available on your machine. It is expected that you are already familiar with Karma when configuring this launcher, so if you are new to Karma, head over to the Karma website.

The Sauce Labs platform configurator can help to find the correct configuration for your desired test platform.

Adding karma-sauce-launcher to an existing Karma config

To configure this launcher, you need to add two properties to your top-level Karma config, sauceLabs and customLaunchers, set the browsers array to use Sauce Labs browsers, and add the sauceLabs reporter.

The sauceLabs object defines global properties for each browser/platform while the customLaunchers object configures individual browsers. The sauceLabs reporter allows your tests results to be properly displayed on https://saucelabs.com. Here is a sample Karma config to get the launcher running:

module.exports = function(config) {
  // Example set of browsers to run on Sauce Labs
  // Check out https://saucelabs.com/platforms for all browser/platform combos
  var customLaunchers = {
    sl_chrome: {
      base: 'SauceLabs',
      browserName: 'chrome',
      platform: 'Windows 7',
      version: '35'
    },
    sl_firefox: {
      base: 'SauceLabs',
      browserName: 'firefox',
      version: '30'
    },
    sl_ios_safari: {
      base: 'SauceLabs',
      browserName: 'iphone',
      platform: 'OS X 10.9',
      version: '7.1'
    },
    sl_ie_11: {
      base: 'SauceLabs',
      browserName: 'internet explorer',
      platform: 'Windows 8.1',
      version: '11'
    },
    sl_android: {
      base: 'SauceLabs',
      browserName: 'Browser',
      platform: 'Android',
      version: '4.4',
      deviceName: 'Samsung Galaxy S3 Emulator',
      deviceOrientation: 'portrait'
    }
  }

  config.set({

    // The rest of your karma config is here
    // ...
    sauceLabs: {
        testName: 'Web App Unit Tests'
    },
    customLaunchers: customLaunchers,
    browsers: Object.keys(customLaunchers),
    reporters: ['dots', 'saucelabs'],
    singleRun: true
  })
}

Note: this config assumes that process.env.SAUCE_USERNAME and process.env.SAUCE_ACCESS_KEY are set.

Example karma-sauce-launcher configs

For example configs using this launcher (using Travis CI), check out this repo's karma file, the karma-sauce-example repo (which demonstrates how to use Sauce locally), or AngularJS' Karma config.

sauceLabs config properties shared across all browsers

username

Type: String Default: process.env.SAUCE_USERNAME

Your Sauce Labs username (if you don't have an account, you can sign up here).

accessKey

Type: String Default: process.env.SAUCE_ACCESS_KEY

Your Sauce Labs access key which you will see on your account page.

region

Type: String

Detect datacenter to run tests in. Can be either eu or us.

headless

Type: Boolean

If set to true tests are being run on Sauce Labs headless platform on us-east-1. This option will be ignored if region is set.

proxy

Type: String

Proxy for connecting to Sauce REST API, which is used to communicate job updates of pass/fail.

startConnect

Type: Boolean Default: true

If true, Sauce Connect will be started automatically. Set this to false if you are launching tests locally and want to start Sauce Connect via a binary or the Mac app in the background to improve test speed.

connectOptions

Type: Object Default:

{
  username: 'yourUsername',
  accessKey: 'yourAccessKey',
  tunnelIdentifier: 'autoGeneratedTunnelID'
}

Options to send to Sauce Connect. Check here for all available options.

build

Type: String Default: One of the following environment variables: process.env.BUILD_NUMBER process.env.BUILD_TAG process.env.CI_BUILD_NUMBER process.env.CI_BUILD_TAG process.env.TRAVIS_BUILD_NUMBER process.env.CIRCLE_BUILD_NUM process.env.DRONE_BUILD_NUMBER

ID of the build currently running. This should be set by your CI.

testName

Type: String Default: 'Karma test'

Name of the unit test group you are running.

tunnelIdentifier

Type: String

Sauce Connect can proxy multiple sessions, this is an id of a session.

tags

Type: Array of Strings

Tags to use for filtering jobs in your Sauce Labs account.

recordVideo

Type: Boolean Default: false

Set to true if you want to record a video of your Karma session.

recordScreenshots

Type: Boolean Default: true

Set to false if you don't want to record screenshots.

public

Type: String Default: null

Control who can view job details. Available visibility levels are documented on the SauceLabs website.

customData

Type: Object Default: {}

Send arbitrary data alongside your tests. See the SauceLabs documentation for more details.

customLaunchers config properties

The customLaunchers object has browser names as keys and configs as values. Documented below are the different properties which you can configure for each browser/platform combo.

Note: You can learn about the available browser/platform combos on the Sauce Labs platforms page, platforms configurator page and REST API page.

base

Type: String Required: true

This defines the base configuration for the launcher. In this case it should always be SauceLabs so that browsers can use the base Sauce Labs config defined at the root sauceLabs property.

browserName

Type: String Required: true

Name of the browser.

browserVersion

Type: String Default: Latest browser version for all browsers except Chrome

Version of the browser to use.

platformName

Type: String Default: 'Linux' for Firefox/Chrome, 'Windows 7' for IE/Safari

Name of platform to run browser on.

sauce:options

Specific Sauce Labs capability options.

Behind the scenes

This launcher uses Sauce Connect in the background. If you are interested in security or want to see the system requirements, head over to the documentation.

Keywords

FAQs

Package last updated on 26 May 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc