Skip to content

shirish87/browserstack-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

480 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BrowserStack Client

npm Build Status

TypeScript SDK for all BrowserStack REST APIs. One package, every product, full type safety.

Installation

npm install @dot-slash/browserstack-client

Requirements

  • Node.js 22 or higher
  • A BrowserStack account with the relevant product subscriptions

Authentication

Set credentials in your environment — no constructor arguments needed:

export BROWSERSTACK_USERNAME=<your-username>
export BROWSERSTACK_ACCESS_KEY=<your-access-key>

Or pass them explicitly to any client constructor.

Usage

import {
  AutomateClient,
  AppAutomateClient,
  LocalTestingBinary,
  AccessibilityClient,
  TestManagementClient,
  TestReportingClient,
  ScreenshotsClient,
} from "@dot-slash/browserstack-client";

Tree-shaking: If bundle size matters (e.g. Lambda, browser), import from the product subpath instead — @dot-slash/browserstack-client/automate, /app-automate, /local-testing, /accessibility, /test-management, /test-reporting, /screenshots. Bundlers will then include only that product's code.

Automate — browser automation

import { AutomateClient } from "@dot-slash/browserstack-client";

const client  = new AutomateClient();
const plan    = await client.getPlan();
const builds  = await client.getBuilds();

App Automate — mobile app automation

import { AppAutomateClient } from "@dot-slash/browserstack-client";

const client   = new AppAutomateClient();
const projects = await client.getProjects();
const builds   = await client.getBuilds(projects[0].id);

Local Testing — tunnel management

import { LocalTestingBinary } from "@dot-slash/browserstack-client";

const tunnel = new LocalTestingBinary({ accessKey: process.env.BROWSERSTACK_ACCESS_KEY });

await tunnel.start();
// ... run tests against localhost ...
await tunnel.stop();

Accessibility

import { AccessibilityClient } from "@dot-slash/browserstack-client";

const client  = new AccessibilityClient();
const reports = await client.getWorkflowAnalyzerReports();

Test Management

import { TestManagementClient } from "@dot-slash/browserstack-client";

const client   = new TestManagementClient();
const projects = await client.getProjects();

Test Reporting & Analytics

import { TestReportingClient } from "@dot-slash/browserstack-client";

const client = new TestReportingClient();

const build = await client.startBuild({
  projectName: "my-project",
  buildName:   "my-build",
  framework:   "playwright",
});

// ... run tests ...

await client.finishBuild(build.buildHashedId, { status: "passed" });

Screenshots — cross-browser screenshots

import { ScreenshotsClient } from "@dot-slash/browserstack-client";

const client = new ScreenshotsClient();

await client.launch(
  {
    url: "https://example.com",
    browsers: [{ browser: "chrome", browser_version: "latest", os: "Windows", os_version: "11" }],
  },
  (screenshot) => console.log("captured:", screenshot.imageUrl)
);

CLI

A unified CLI is also available for local testing and product interactions:

npx @dot-slash/browserstack-cli local start
npx @dot-slash/browserstack-cli local run-with -- npm test
npx @dot-slash/browserstack-cli local stop

Individual packages

Only need one product? Install its focused package directly:

Package Product
@dot-slash/browserstack-automate Browser automation
@dot-slash/browserstack-app-automate Mobile app automation
@dot-slash/browserstack-local-testing Local tunnel binary
@dot-slash/browserstack-accessibility Accessibility testing
@dot-slash/browserstack-test-management Test case management
@dot-slash/browserstack-test-reporting Test analytics
@dot-slash/browserstack-screenshots Screenshot automation

Documentation

shirish87.github.io/browserstack-client

Thanks

Sponsored access to BrowserStack, courtesy BrowserStack.

About

node.js API client for BrowserStack APIs.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors