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 🙏

© 2025 – Pkg Stats / Ryan Hefner

browserstack-capabilities

v0.7.0

Published

An easier way to generate multiple capabilities based on JSON filters.

Downloads

496

Readme

browserstack-capabilities

An easier way to generate multiple capabilities based on JSON filters for Browserstack.

Installation

npm install browserstack-capabilities

Usage

The create method (currently the only method returned) accepts two parameters: an "include" and an "exclude" JSON filter.

The "include" filter will find all browsers that match the defined properties.

The "exclude" filter will return all browsers that don't match the defined properties.

A Simple Include

You do not have to include all properties in your search. Any properties not defined will be included in all variations.

var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);

var capabilities = bsCapabilities.create({
    browser: "ie",
    browser_version: "10.0"
});

console.log(capabilities);
// outputs:
// [{
//  device: null,
//  os: 'Windows',
//  browser: 'ie',
//  os_version: '8',
//  browser_version: '10.0'
// }, {
//  device: null,
//  os: 'Windows',
//  browser: 'ie',
//  os_version: '7',
//  browser_version: '10.0'
// }]

A Complex Include

You can define multiple values per property:

var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);

var capabilities = bsCapabilities.create({
    browser: "ie",
    browser_version: ["11.0", "10.0"],
    os_version: ["10", "8.1", "7"]
});

console.log(capabilities);
// outputs:
// [{
//   device: null,
//   os: 'Windows',
//   browser: 'ie',
//   os_version: '10',
//   browser_version: '11.0'
// }, {
//   device: null,
//   os: 'Windows',
//   browser: 'ie',
//   os_version: '8.1',
//   browser_version: '11.0'
// }, {
//   device: null,
//   os: 'Windows',
//   browser: 'ie',
//   os_version: '7',
//   browser_version: '11.0'
// }, {
//   device: null,
//   os: 'Windows',
//   browser: 'ie',
//   os_version: '7',
//   browser_version: '10.0'
// }]

Combining Includes and Excludes

Includes and excludes can be combined to create complex scenarios. For example, I want all version of IE11 & IE10, except I don't care about IE11 on Windows 7:

var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);

var capabilities = bsCapabilities.create({
    browser: "ie",
    browser_version: ["11.0", "10.0"],
    os_version: ["10", "8.1", "7"]
}, {
    browser_version: "11.0",
    os_version: "7"
});

console.log(capabilities);
// outputs:
// [{
//   device: null,
//   os: 'Windows',
//   browser: 'ie',
//   os_version: '10',
//   browser_version: '11.0'
// }, { 
//   device: null,
//   os: 'Windows',
//   browser: 'ie',
//   os_version: '8.1',
//   browser_version: '11.0'
// }, {
//   device: null,
//   os: 'Windows',
//   browser: 'ie',
//   os_version: '7',
//   browser_version: '10.0'
// }]

Properties

The following properties are defined in the JSON browser data:

  • device
  • os
  • browser
  • os_version
  • browser_version

You can generate sample capabilities for single browsers on the Browserstack website.

Multiple OSes

Because each OS has a unique version and/or device name, you can create combinations for them by including the information together:

var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);

var capabilities = bsCapabilities.create({
    browser: "firefox",
    os: ["Windows", "OS X"],
    browser_version: "42.0",
    os_version: ["10", "8.1", "El Capitan", "Yosemite"]
});

console.log(capabilities);
// outputs:
// [{
//   device: null,
//   os: 'Windows',
//   browser: 'firefox',
//   os_version: '10',
//   browser_version: '42.0'
// }, {
//   device: null,
//   os: 'Windows',
//   browser: 'firefox',
//   os_version: '8.1',
//   browser_version: '42.0'
// }, {
//   device: null,
//   os: 'OS X',
//   browser: 'firefox',
//   os_version: 'El Capitan',
//   browser_version: '42.0'
// }, {
//   device: null,
//   os: 'OS X',
//   browser: 'firefox',
//   os_version: 'Yosemite',
//   browser_version: '42.0'
// }]

Multiple Browsers

You can create combinations for multiple browsers at the same time by passing an array of filters into the create function:

var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);

var capabilities = bsCapabilities.create([{
  browser: "firefox",
  browser_version: "42.0",
  os: "Windows",
  os_version: ["10", "8.1"]
},{
  browser: "chrome",
  browser_version: "46.0",
  os: "Windows",
  os_version: ["10", "8.1"]
}]);

console.log(capabilities);
// outputs:
// [{
//   device: null,
//   os: 'Windows',
//   browser: 'firefox',
//   os_version: '10',
//   browser_version: '42.0'
// }, {
//   device: null,
//   os: 'Windows',
//   browser: 'firefox',
//   os_version: '8.1',
//   browser_version: '42.0'
// }, {
//   device: null,
//   os: 'Windows',
//   browser: 'chrome',
//   os_version: '10',
//   browser_version: '46.0'
// }, {
//   device: null,
//   os: 'Windows',
//   browser: 'chrome',
//   os_version: '8.1',
//   browser_version: '46.0'
// }]

If you prefer, you can create combinations for different browsers separately. Once created, you can concat the combinations:

var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);

var ff = bsCapabilities.create({
    browser: "firefox",
    os: "Windows",
    browser_version: "42.0",
    os_version: ["10", "8.1"]
});

var chrome = bsCapabilities.create({
    browser: "chrome",
    os: "Windows",
    browser_version: "46.0",
    os_version: ["10", "8.1"]
});

var capabilities = ff.concat(chrome);

console.log(capabilities);
// outputs:
// [{
//   device: null,
//   os: 'Windows',
//   browser: 'firefox',
//   os_version: '10',
//   browser_version: '42.0'
// }, {
//   device: null,
//   os: 'Windows',
//   browser: 'firefox',
//   os_version: '8.1',
//   browser_version: '42.0'
// }, {
//   device: null,
//   os: 'Windows',
//   browser: 'chrome',
//   os_version: '10',
//   browser_version: '46.0'
// }, {
//   device: null,
//   os: 'Windows',
//   browser: 'chrome',
//   os_version: '8.1',
//   browser_version: '46.0'
// }]

Current/latest/previous version of a browser

You can select the current (exclude betas), latest (include betas) or previous version of a browser for an OS by passing in the string "current", "latest" or "previous" as the browser version:

var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);

var capabilities = bsCapabilities.create({
  browser: "ie",
  browser_version: ["current"],
  os: "Windows",
  os_version: ["XP", "7", "8", "8.1", "10"]
});

console.log(capabilities);
// outputs:
// [{
//   os: 'Windows',
//   os_version: 'XP',
//   browser: 'ie',
//   device: null,
//   browser_version: '8.0'
// }, {
//   os: 'Windows',
//   os_version: '7',
//   browser: 'ie',
//   device: null,
//   browser_version: '11.0'
// }, {
//   os: 'Windows',
//   os_version: '8',
//   browser: 'ie',
//   device: null,
//   browser_version: '10.0'
// }, {
//   os: 'Windows',
//   os_version: '8.1',
//   browser: 'ie',
//   device: null,
//   browser_version: '11.0'
// }, {
//   os: 'Windows',
//   os_version: '10',
//   browser: 'ie',
//   device: null,
//   browser_version: '11.0'
// }]

Defaults

You can pass in additional defaults as the third parameter, and they will be applied to all results:

var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);

var capabilities = bsCapabilities.create({
  browser: 'ie',
  browser_version: ['10.0', '11.0'],
  os: 'Windows',
  os_version: '7'
}, 
null,
{
  resolution: '1600x1200'
});

console.log(capabilities);
// outputs:
// [{
//   device: null,
//   os: 'Windows',
//   browser: 'ie',
//   os_version: '7',
//   browser_version: '10.0',
//   real_mobile: null,
//   resolution: '1600x1200'
// }, {
//   device: null,
//   os: 'Windows',
//   browser: 'ie',
//   os_version: '7',
//   browser_version: '11.0',
//   real_mobile: null,
//   resolution: '1600x1200'
// }]