Skip to content

Documentation / local-testing-binary / LocalTestingBinary

Class: LocalTestingBinary

Defined in: local-testing-binary/src/local-testing-binary.ts:136

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.

Example

ts
const localTesting = new BrowserStack.LocalTestingBinary({ accessKey: "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

Constructor

new LocalTestingBinary(options?): LocalTestingBinary

Defined in: local-testing-binary/src/local-testing-binary.ts:158

Constructs a new instance of the ScreenshotsClient class.

Parameters

ParameterTypeDescription
options?LocalTestingBinaryOptionsOptional configuration options for the client.

Returns

LocalTestingBinary

Overrides

LocalTestingClient.constructor

Properties

PropertyTypeDefault valueDescriptionInherited fromDefined in
authHeader?stringundefinedHTTP Basic Auth header derived from username and access key.LocalTestingClient.authHeadercore/src/api-client.ts:55
authTokenstringundefined-LocalTestingClient.authTokenlocal-testing/src/client.ts:15
baseUrlsobjectundefinedBase URLs used for API requests.LocalTestingClient.baseUrlscore/src/api-client.ts:53
baseUrls.sdkstringundefined--core/src/api-client.ts:53
baseUrls.sdkCloudstringundefined--core/src/api-client.ts:53
binHomestringundefined--local-testing-binary/src/local-testing-binary.ts:146
clientTimeout?numberundefined-LocalTestingClient.clientTimeoutcore/src/api-client.ts:66
commandTimeoutMsnumberundefined--local-testing-binary/src/local-testing-binary.ts:144
fetchFn(input, init?) => Promise<Response>undefinedFetch implementation used to make HTTP requests.LocalTestingClient.fetchFncore/src/api-client.ts:59
localIdentifierstringundefined--local-testing-binary/src/local-testing-binary.ts:137
registryCodecRegistryundefinedRegistry of request and response codecs.LocalTestingClient.registrycore/src/api-client.ts:61
state"stopped" | "starting" | "started" | "stopping""stopped"The last state of the BrowserStackLocal daemon command.-local-testing-binary/src/local-testing-binary.ts:152
userAgentstringundefinedUser-Agent string sent with every request.LocalTestingClient.userAgentcore/src/api-client.ts:57

Accessors

args

Get Signature

get args(): string[]

Defined in: local-testing-binary/src/local-testing-binary.ts:474

Returns

string[]


pid

Get Signature

get pid(): number | undefined

Defined in: local-testing-binary/src/local-testing-binary.ts:470

Returns

number | undefined

Methods

disconnectBinaryInstance()

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

Defined in: local-testing/src/client.ts:99

Parameters

ParameterType
localInstanceIdstring
query?Omit<{ auth_token: string; }, "auth_token">
options?ExecuteOptions

Returns

Promise<string>

Inherited from

LocalTestingClient.disconnectBinaryInstance


disconnectInstance()

disconnectInstance(localInstanceId, authToken?, options?): Promise<{ apiVersion: string; message: string; metaData: {[key: string]: unknown; params?: {[key: string]: unknown; }; }; }>

Defined in: openapi/generated/local-testing.client.ts:79

Disconnect a Local binary instance

Parameters

ParameterTypeDescription
localInstanceIdstring-
authToken?string-
options?ExecuteOptionsOptional abort signal and other request options

Returns

Promise<{ apiVersion: string; message: string; metaData: {[key: string]: unknown; params?: {[key: string]: unknown; }; }; }>

Inherited from

LocalTestingClient.disconnectInstance


downloadBinary()

downloadBinary(osArch, filenamePrefix?, options?): Promise<{ content: Uint8Array; filename: string; }>

Defined in: local-testing/src/client.ts:127

Parameters

ParameterTypeDefault value
osArch"win32" | "darwin-x64" | "linux-x64" | "linux-ia32" | "alpine"undefined
filenamePrefixstring"BrowserStackLocal"
options?ExecuteOptionsundefined

Returns

Promise<{ content: Uint8Array; filename: string; }>

Inherited from

LocalTestingClient.downloadBinary


execute()

protected execute<T>(spec): Promise<T>

Defined in: core/src/api-client.ts:126

Internal

Type Parameters

Type ParameterDefault type
Tunknown

Parameters

ParameterType
spec{[key: string]: unknown; baseUrl?: "sdk" | "sdkCloud"; method: HttpMethod; operationId: string; params?: { path?: Record<string, unknown>; query?: Record<string, unknown>; }; path: string; requestCodec?: string; requestCodecConfig?: unknown; requestInput?: unknown; responseCodec: string; responseCodecConfig: unknown; signal?: AbortSignal; }
spec.baseUrl?"sdk" | "sdkCloud"
spec.methodHttpMethod
spec.operationIdstring
spec.params?{ path?: Record<string, unknown>; query?: Record<string, unknown>; }
spec.params.path?Record<string, unknown>
spec.params.query?Record<string, unknown>
spec.pathstring
spec.requestCodec?string
spec.requestCodecConfig?unknown
spec.requestInput?unknown
spec.responseCodecstring
spec.responseCodecConfigunknown
spec.signal?AbortSignal

Returns

Promise<T>

Inherited from

LocalTestingClient.execute


getBinaryInstance()

getBinaryInstance(localInstanceId, query?, options?): Promise<{ commandLineParams?: string; disconnectReason?: string; email: string; endTime?: string; hostname?: string; id: string; lastActiveOn: string; localIdentifier: string; privateIP?: string[]; public-IP?: string; startTime: string; }>

Defined in: local-testing/src/client.ts:63

Parameters

ParameterType
localInstanceIdstring
query?Omit<{ auth_token: string; last?: number; state?: "running" | "all"; }, "auth_token">
options?ExecuteOptions

Returns

Promise<{ commandLineParams?: string; disconnectReason?: string; email: string; endTime?: string; hostname?: string; id: string; lastActiveOn: string; localIdentifier: string; privateIP?: string[]; public-IP?: string; startTime: string; }>

Inherited from

LocalTestingClient.getBinaryInstance


getBinaryInstances()

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

Defined in: local-testing/src/client.ts:37

Parameters

ParameterType
query?Omit<{ auth_token: string; last?: number; state?: "running" | "all"; }, "auth_token">
options?ExecuteOptions

Returns

Promise<object[]>

Inherited from

LocalTestingClient.getBinaryInstances


getInstance()

getInstance(localInstanceId, authToken?, options?): Promise<{ apiVersion: string; instances: object[]; metaData: {[key: string]: unknown; params?: {[key: string]: unknown; }; }; }>

Defined in: openapi/generated/local-testing.client.ts:58

Fetches details of a Local binary instance used for local testing. Note that the binary should have been started with the --enable-logging-for-api parameter.

Parameters

ParameterTypeDescription
localInstanceIdstring-
authToken?string-
options?ExecuteOptionsOptional abort signal and other request options

Returns

Promise<{ apiVersion: string; instances: object[]; metaData: {[key: string]: unknown; params?: {[key: string]: unknown; }; }; }>

Inherited from

LocalTestingClient.getInstance


getInstances()

getInstances(authToken?, last?, state?, options?): Promise<{ apiVersion: string; instances: object[]; metaData: {[key: string]: unknown; params?: {[key: string]: unknown; }; }; }>

Defined in: openapi/generated/local-testing.client.ts:37

Fetches list of recent binary instances for local testing. Note that the binary should have been started with the --enable-logging-for-api parameter.

Parameters

ParameterTypeDescription
authToken?string-
last?string-
state?string-
options?ExecuteOptionsOptional abort signal and other request options

Returns

Promise<{ apiVersion: string; instances: object[]; metaData: {[key: string]: unknown; params?: {[key: string]: unknown; }; }; }>

Inherited from

LocalTestingClient.getInstances


start()

start(): Promise<string | undefined>

Defined in: local-testing-binary/src/local-testing-binary.ts:216

Starts the BrowserStackLocal daemon.

Returns

Promise<string | undefined>

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


stop()

stop(): Promise<string | undefined>

Defined in: local-testing-binary/src/local-testing-binary.ts:245

Stops the BrowserStackLocal daemon.

Returns

Promise<string | undefined>

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


version()

version(): Promise<string>

Defined in: local-testing-binary/src/local-testing-binary.ts:184

Retrieves the version of the local testing binary.

Returns

Promise<string>

A promise that resolves to the version string.