Registry / testing / browserstack-node-sdk

browserstack-node-sdk

JSON →
library1.52.0jsnpmunverified

The `browserstack-node-sdk` is a Node.js library designed to facilitate running Selenium WebDriver tests on the BrowserStack cloud platform using popular JavaScript test runners like Jest, Mocha, and Cucumber. Currently at version 1.52.0, it primarily offers a command-line interface (CLI) to configure and execute tests against various browser and OS combinations defined in a `browserstack.yml` configuration file. While the SDK supports programmatic integration, its common usage pattern involves an `npx setup` command to initialize project configuration and wrapper CLI commands (e.g., `browserstack-node-sdk jest`) to orchestrate test execution on BrowserStack. Release cadence is frequent, indicated by minor version increments, focusing on compatibility and new platform support rather than major breaking changes. Its key differentiator is simplifying the integration of existing Node.js test suites with BrowserStack's extensive device farm through a streamlined setup and execution workflow, abstracting away much of the boilerplate associated with configuring remote Selenium grids.

npm install browserstack-node-sdk
INSTALL
IMPORT
SIG · BROWSERSTACK-NODE-
B
browserstack-node-sdk
testingjavascriptv1.52.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

setup
✓ import { setup } from 'browserstack-node-sdk';
✗ const setup = require('browserstack-node-sdk').setup;
Used for programmatic initialization of the browserstack.yml configuration file.
runCLI
✓ import { runCLI } from 'browserstack-node-sdk';
✗ const runCLI = require('browserstack-node-sdk').runCLI;
Allows programmatic execution of the BrowserStack CLI commands for test runners, mirroring `browserstack-node-sdk <runner>`. Typically not needed for standard CLI usage.
getBrowserstackConfig
✓ import { getBrowserstackConfig } from 'browserstack-node-sdk';
✗ const getBrowserstackConfig = require('browserstack-node-sdk').getBrowserstackConfig;
Retrieves the parsed contents of the `browserstack.yml` file, useful for custom integrations or validation.

Demonstrates installation, initial setup with environment variables, and execution of tests on BrowserStack via the generated CLI commands.

npm i -D browserstack-node-sdk npx setup --username process.env.BROWSERSTACK_USERNAME ?? '' --key process.env.BROWSERSTACK_ACCESS_KEY ?? '' # This command adds a new script to your package.json, e.g., 'browserstack-jest-test' # It also creates a browserstack.yml file with configuration. # Example of running Jest tests via the SDK: npm run browserstack-jest-test
browserstack-node-sdk --version
Debug
Known issues
gotchaAuthentication failures are common if `BROWSERSTACK_USERNAME` or `BROWSERSTACK_ACCESS_KEY` are incorrect or not provided via environment variables or the `browserstack.yml` file. Ensure these credentials are valid and accessible.
fix
Set `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables, or verify them in `browserstack.yml`. Run `npx setup` again if the `browserstack.yml` is missing or corrupted.
affects: >=1.0.0
gotchaNetwork connectivity issues, such as VPN/proxy misconfigurations or corporate firewall restrictions, can prevent the SDK from communicating with BrowserStack cloud services, leading to `SDK-GEN-002` errors.
fix
Ensure outbound access to `*.browserstack.com` is allowed. Validate proxy settings and try running tests on an alternative network to rule out local environment issues.
affects: >=1.0.0
gotchaThe SDK relies on a `.browserstack` directory in the user's home directory for session and cache information. Permissions issues or its absence can cause `SDK-GEN-001` errors.
fix
Ensure the `.browserstack` folder exists and has read/write permissions. On Linux/macOS, use `chmod -R 755 ~/.browserstack`.
affects: >=1.0.0
gotchaCompatibility issues can arise if the test framework (Jest, Mocha, Cucumber) or its dependencies are recently updated or incorrectly installed, leading to `SDK-TRA-006` errors.
fix
Check for recent updates to your test framework. If issues persist, revert to a known-working version or compare your project's dependencies against BrowserStack's sample projects.
affects: >=1.0.0
gotchaThe `browserstack.yml` configuration file is crucial for defining platforms and capabilities. Incorrect syntax, missing required fields, or an invalid structure will lead to test execution failures.
fix
Refer to the official BrowserStack documentation and sample `browserstack.yml` files (e.g., in `jest-js-browserstack` repo) to ensure correct formatting and required fields. Use the SDK Config Generator if available.
affects: >=1.0.0
Errors
Common errors & fixes
Authentication failed. Please check your BrowserStack Username and Access Key.
Incorrect or missing BrowserStack credentials.
fix
Set `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` as environment variables or update the `browserstack.yml` file.
browserstack.yml file not found at the root of your project.
The SDK configuration file is missing or misplaced.
fix
Run `npx setup --username <your_username> --key <your_access_key>` to generate the `browserstack.yml` file. Ensure it's in the project root.
Error: Test runner 'jest' not found. Please ensure it's installed and accessible.
The specified test runner (e.g., Jest, Mocha, Cucumber) is not installed or not in the PATH.
fix
Install the required test runner as a dev dependency (e.g., `npm i -D jest`) and ensure it's runnable from your project's scripts.
Local tunnel connection failed. Please check BrowserStackLocal logs for details.
Issues with `BrowserStackLocal` binary or network configuration preventing local testing.
fix
Check proxy settings, firewall rules, and ensure `browserstack-local` is correctly configured and can establish a connection. Consult BrowserStackLocal documentation for advanced troubleshooting.
Upgrade
Version history
1.52.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
39 hits · last 30 days
node
34
OpenAI (training)
2
Amazon
1
Resources
browserstack-node-sdk — npm install browserstack-node-sdk · libregistry