Skip to content

browserstack-clientReadme | API


browserstack-client / LocalTestingBinary

Class: LocalTestingBinary

Represents a client for interacting with the BrowserStack Local binary and APIs. Extends features of LocalTestingClient for the node.js runtime. Download, spawn, and control the BrowserStack Local binary.

Index

  • version — Retrieves the version of the local testing binary.

  • start — Starts the BrowserStackLocal daemon.

  • stop — Stops the BrowserStackLocal daemon.

  • getBinaryInstances — Retrieves a list of recent Local binary instances from the server.

  • getBinaryInstance — Retrieves details of a Local binary instance from the server.

  • disconnectBinaryInstance — Disconnects a binary instance.

Example

ts
const localTesting = new BrowserStack.LocalTestingBinary({ key: "my-key" });
await localTesting.start();
console.log(localTesting.state); // "started"
console.log(localTesting.pid); // 12345
await localTesting.stop();
console.log(localTesting.state); // "stopped"
console.log(localTesting.pid); // undefined

Extends

Constructors

new LocalTestingBinary(options)

new LocalTestingBinary(options?): LocalTestingBinary

Constructs a new instance of the ScreenshotsClient class.

Parameters

ParameterTypeDescription
options?LocalTestingBinaryOptionsOptional configuration options for the client.

Returns

LocalTestingBinary

Overrides

LocalTestingClient.constructor

Source

src/local-testing-binary.ts:68

Properties

PropertyModifierTypeDescription
statepublic"stopped" | "starting" | "started" | "stopping"The last state of the BrowserStackLocal daemon command.
options?privateLocalTestingBinaryOptionsOptional configuration options for the client.

Accessors

pid

get pid(): undefined | number

Returns

undefined | number

Source

src/local-testing-binary.ts:489


args

get args(): string[]

Returns

string[]

Source

src/local-testing-binary.ts:493

Methods

version()

version(): Promise<string>

Retrieves the version of the local testing binary.

Returns

Promise<string>

A promise that resolves to the version string.

Source

src/local-testing-binary.ts:94


start()

start(): Promise<undefined | string>

Starts the BrowserStackLocal daemon.

Returns

Promise<undefined | string>

A promise that resolves to a string if the binary starts successfully, or undefined if there is an error.

Source

src/local-testing-binary.ts:124


stop()

stop(): Promise<undefined | string>

Stops the BrowserStackLocal daemon.

Returns

Promise<undefined | string>

A promise that resolves to a string if the daemon stops successfully, or undefined otherwise.

Source

src/local-testing-binary.ts:153


getBinaryInstances()

getBinaryInstances(query?, options?): Promise<Object[]>

Retrieves a list of recent Local binary instances from the server.

Parameters

ParameterTypeDescription
query?Omit<Object, "auth_token">-
options?APIFetchOptions<Object>The fetch options for the request.

Returns

Promise<Object[]>

A promise that resolves to a fetch response containing the list of active Local instances.

Inherited from

LocalTestingClient.getBinaryInstances

Source

src/local-testing.ts:44


getBinaryInstance()

getBinaryInstance(localInstanceId, query?, options?): Promise<Object>

Retrieves details of a Local binary instance from the server.

Parameters

ParameterTypeDescription
localInstanceIdstringThe ID of the local binary instance to retrieve.
query?Omit<Object, "auth_token">Optional query parameters for the request.
options?APIFetchOptions<Object>Optional fetch options for the request.

Returns

Promise<Object>

A promise that resolves to the retrieved local binary instance.

MemberTypeDescription
idstringDescription
Unique identifier for the Local instance.

Example
QUERTY1
emailstringDescription
User account that started the Local instance.

Example
john@browserstack.com
hostnamestringDescription
Hostname for the machine running the Local instance.

Example
my-local-box
lastActiveOnstringDescription
Timestamp at which the Local instance was last active.

Example
2013-03-14 16:25:45 UTC
startTimestringDescription
Timestamp at which the Local instance was started.

Example
2013-03-14 16:25:45 UTC
endTimestringDescription
Timestamp at which the Local instance was terminated.

Example
2013-03-14 16:25:45 UTC
disconnectReasonstringDescription
Reason for termination of the Local instance.

Example
User terminated the instance.
commandLineParamsstringDescription
Command line parameters used to start the Local instance.

Example
--key <access_key> --enable-logging-for-api --local-identifier <local_identifier>
localIdentifierstringDescription
Identifier for the Local instance.

Example
4207442b2b0567368956dba064c22a3235a76214
public-IPstringDescription
Public IP address of the machine running the Local instance.

Example
8.8.4.4
privateIPstring[]Example
[ "127.0.0.1", "10.100.100.1" ]

Inherited from

LocalTestingClient.getBinaryInstance

Throws

If no local binary instance is found with the specified ID.

Source

src/local-testing.ts:71


disconnectBinaryInstance()

disconnectBinaryInstance(localInstanceId, query?, options?): Promise<string>

Disconnects a binary instance.

Parameters

ParameterTypeDescription
localInstanceIdstringThe ID of the local binary instance to disconnect.
query?Omit<Object, "auth_token">Optional query parameters for the request.
options?APIFetchOptions<Object>Optional API fetch options.

Returns

Promise<string>

A promise that resolves to a string representing the message from the server.

Inherited from

LocalTestingClient.disconnectBinaryInstance

Source

src/local-testing.ts:109