• This repository has been archived on 28/Jul/2023
  • Stars
    star
    150
  • Rank 247,323 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 11 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Karma plugin. Launch any browser on BrowserStack!

karma-browserstack-launcher

js-standard-style npm version npm downloads

Build Status Dependency Status devDependency Status

Use any browser on BrowserStack!

Installation

The easiest way is to keep karma-browserstack-launcher as a devDependency in your package.json. Just run,

$ npm install karma-browserstack-launcher --save-dev

and it will be added automatically.

Configuration

// karma.conf.js
module.exports = function(config) {
  config.set({
    // global config of your BrowserStack account
    browserStack: {
      username: 'jamesbond',
      accessKey: '007'
    },

    // define browsers
    customLaunchers: {
      bs_firefox_mac: {
        base: 'BrowserStack',
        browser: 'firefox',
        browser_version: '21.0',
        os: 'OS X',
        os_version: 'Mountain Lion'
      },
      bs_iphone5: {
        base: 'BrowserStack',
        device: 'iPhone 5',
        os: 'ios',
        os_version: '6.0'
      }
    },

    browsers: ['bs_firefox_mac', 'bs_iphone5']
  })
}

Global options

  • username your BS username, you can also use BROWSERSTACK_USERNAME env variable.
  • accessKey your BS access key, you can also use BROWSERSTACK_ACCESS_KEY env variable.
  • startTunnel do you wanna establish the BrowserStack tunnel ? (defaults to true)
  • tunnelIdentifier/localIdentifier in case you want to start the BrowserStack tunnel outside karma by setting startTunnel to false, set the identifier passed to the -localIdentifier option here (optional)
  • retryLimit how many times do you want to retry to capture the browser ? (defaults to 3)
  • captureTimeout the browser capture timeout (defaults to 120)
  • timeout the BS worker timeout (defaults to 300
  • build the BS worker build name (optional)
  • name the BS worker name (optional)
  • project the BS worker project name (optional)
  • proxyHost the host of your proxy for communicating with BrowserStack REST API and BrowserStackLocal (optional)
  • proxyPort the port of your proxy (optional)
  • proxyUser the username used for authentication with your proxy (optional)
  • proxyPass the password used for authentication with your proxy (optional)
  • proxyProtocol the protocol of your proxy (optional. default: http. valid: http or https)
  • forcelocal force traffic through the local BrowserStack tunnel, passes flag through to BrowserStackTunnel
  • video enable video recording of session on BrowserStack (defaults to true)

Per browser options

  • device name of the device
  • real_mobile or realMobile allows the session to run on a real mobile device instead of an emulator / simulator (optional, defaults to false)
  • browser name of the browser
  • browser_version version of the browser
  • os which platform ?
  • os_version version of the platform
  • build the BS worker build name (optional, defaults to global)
  • name the BS worker name (optional, defaults to global)
  • project the BS worker project name (optional, defaults to global)

Note: you can also pass through any additional options supported by browserstack. (EG. url, resolution, etc.)
See https://www.browserstack.com/automate/capabilities for a full list of supported options.

BrowserStack reporter

To report session results back to BrowserStack for display on your BrowserStack dashboard, use the following additional configuration:

// karma.conf.js
module.exports = function(config) {
  config.set({
    // The rest of your karma config is here
    // ...
    reporters: ['dots', 'BrowserStack']
  })
}

Browserstack iOS simulators

By default, your Selenium and JS tests will run on real iOS devices on BrowserStack. Since we are in the implementation phase, we are still working on a few things, such as adding more devices, ability to test on local URLs, etc.

In case your tests are facing any issues on real iOS devices, we also provide iOS simulators where you can run your automated tests smoothly.

To access our iOS simulators, use the following capabilities:

customLaunchers: {
  iPad_3: {
    real_mobile: false,
    device: 'iPad 3rd (6.0)',
    os: 'ios',
    'os_version': '6.0',
    'browser_version': null,
    browser: 'Mobile Safari'
  }
}

List of iOS simulators you can test on:

  • device: 'iPad 3rd', 'os_version': '5.1'
  • device: 'iPad 3rd (6.0)', 'os_version': '6.0'
  • device: 'iPad Mini', 'os_version': '7.0'
  • device: 'iPad 4th', 'os_version': '7.0'
  • device: 'iPhone 4S', 'os_version': '5.1'
  • device: 'iPhone 4S (6.0)', 'os_version': '6.0'
  • device: 'iPhone 5', 'os_version': '6.0'
  • device: 'iPhone 5S', 'os_version': '7.0'

CI/CD Build Environment Variables

Many CI/CD systems will make the name or ID of the currently running build available via an environment variable. The follow environment variables below are supported by default:

  • 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

BrowserStack's REST API documentation explains how to retrieve a list of desired capabilities for browsers.


For more information on Karma see the homepage.


Check out sample code working with karma-browserstack-launcher here.

More Repositories

1

karma

Spectacular Test Runner for JavaScript
JavaScript
11,952
star
2

karma-coverage

A Karma plugin. Generate code coverage.
JavaScript
768
star
3

karma-jasmine

A Karma plugin - adapter for Jasmine testing framework.
JavaScript
542
star
4

grunt-karma

Grunt plugin for Karma.
JavaScript
468
star
5

karma-chrome-launcher

A Karma plugin. Launcher for Chrome and Chrome Canary.
JavaScript
467
star
6

karma-mocha

A Karma plugin. Adapter for Mocha testing framework.
JavaScript
379
star
7

gulp-karma

Example of using Karma with Gulp.
JavaScript
310
star
8

karma-phantomjs-launcher

A Karma plugin. Launcher for PhantomJS.
JavaScript
281
star
9

karma-ng-html2js-preprocessor

A Karma plugin. Compile AngularJS 1.x and 2.x templates to JavaScript on the fly.
CoffeeScript
266
star
10

karma-sauce-launcher

A Karma plugin. Launch any browser on SauceLabs!
TypeScript
199
star
11

karma-junit-reporter

A Karma plugin. Report results in junit xml format.
JavaScript
176
star
12

karma-firefox-launcher

A Karma plugin. Launcher for Firefox.
JavaScript
104
star
13

karma-html2js-preprocessor

A Karma plugin. Convert HTML files into JS strings to serve them in a script tag.
CoffeeScript
74
star
14

karma-commonjs

A Karma plugin. Test CommonJS modules.
JavaScript
73
star
15

karma-webdriver-launcher

A plugin for Karma. Launch any browser with WebDriver.
JavaScript
66
star
16

karma-ie-launcher

A Karma plugin. Launcher for Internet Explorer.
JavaScript
59
star
17

karma-coffee-preprocessor

A Karma plugin. Compile coffee script on the fly.
JavaScript
53
star
18

karma-cli

The Karma command line interface.
JavaScript
52
star
19

karma-qunit

A Karma plugin. Adapter for QUnit testing framework.
JavaScript
51
star
20

maven-karma-plugin

Maven plugin for running tests using Karma.
Java
45
star
21

karma-requirejs

A Karma plugin. Adapter for RequireJS framework.
JavaScript
39
star
22

karma-teamcity-reporter

A Karma plugin. Report results for Teamcity CI.
JavaScript
34
star
23

karma-intellij

Reporter for IntelliJ / WebStorm.
JavaScript
34
star
24

karma-growl-reporter

A Karma plugin. Report results with growl.
JavaScript
27
star
25

karma-ng-scenario

A Karma plugin. Adapter for Angular's Scenario Runner.
JavaScript
25
star
26

karma-runner.github.com

Homepage of Karma - The Spectacular JavaScript Test Runner.
HTML
24
star
27

karma-edge-launcher

A Karma plugin. Launcher for Microsoft Edge.
JavaScript
21
star
28

karma-safari-launcher

A Karma plugin. Launcher for Safari.
JavaScript
19
star
29

karma-closure

A Karma plugin. Resolve Google Closure dependencies on the fly.
JavaScript
18
star
30

karma-dart

DEPRECATED. A plugin for Dart language.
JavaScript
16
star
31

karma-slimerjs-launcher

A Karma launcher for SlimerJS
JavaScript
13
star
32

karma-traceur-preprocessor

A Karma plugin. Compile ES6 script on the fly using traceur-compiler.
JavaScript
13
star
33

karma-nodeunit

A Karma plugin - adapter for Node unit testing framework.
JavaScript
12
star
34

karma-script-launcher

A Karma plugin. Launcher for custom scripts.
JavaScript
9
star
35

integration-tests

JavaScript
8
star
36

karma-dojo

A Karma plugin. Adapter for Dojo Toolkit.
JavaScript
7
star
37

karma-opera-launcher

A Karma plugin. Launcher for Opera.
JavaScript
7
star
38

test-device-manager

Keep-alive test browsers and redirect them to a test server on command.
JavaScript
6
star
39

karma-ember-preprocessor

A Karma plugin. Preprocessor for Ember.js templates (handlebars).
JavaScript
6
star
40

karma-googmodule-preprocessor

A Karma preprocessor to handle Closure's goog.module() system
JavaScript
5
star
41

shared-karma-files

Shared configs for all the Karma repos.
CoffeeScript
2
star