
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
browserstack-capabilities
Advanced tools
An easier way to generate multiple capabilities based on JSON filters.
An easier way to generate multiple capabilities based on JSON filters for Browserstack.
npm install browserstack-capabilities
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.
You do not have to include all properties in your search. Any properties not defined will be included in all variations.
var bsCapabilities = require("browserstack-capabilities");
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'
// }]
You can define multiple values per property:
var bsCapabilities = require("browserstack-capabilities");
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'
// }]
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 bsCapabilities = require("browserstack-capabilities");
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'
// }]
The following properties are defined in the JSON browser data:
You can generate sample capabilities for single browsers on the Browserstack website.
Because each OS has a unique version and/or device name, you can create combinations for them by including the information together:
var bsCapabilities = require("browserstack-capabilities");
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'
// }]
It's recommended that you create combinations for different browsers separately, due to the singular nature of the "version" property. Once created, you can concat the combinations:
var bsCapabilities = require("browserstack-capabilities");
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'
// }]
FAQs
An easier way to generate multiple capabilities based on JSON filters.
The npm package browserstack-capabilities receives a total of 112 weekly downloads. As such, browserstack-capabilities popularity was classified as not popular.
We found that browserstack-capabilities demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.