Skip to content

browserstack-clientReadme | API


browserstack-client / JSTestingClient

Class: JSTestingClient

Represents a client for interacting with the BrowserStack JavaScript Testing API.

Index

See

https://www.browserstack.com/docs/automate/javascript-testing/api

Extends

  • APIClient

Constructors

new JSTestingClient(options)

new JSTestingClient(options?): JSTestingClient

Constructs a new instance of the JSTestingClient class.

Parameters

ParameterTypeDescription
options?BrowserStackOptionsOptional configuration options for the client.

Returns

JSTestingClient

Overrides

APIClient.constructor

Source

src/js-testing.ts:19

Methods

getAccountStatus()

getAccountStatus(): Promise<Object>

Retrieves the account status.

Returns

Promise<Object>

A Promise that resolves to the account status.

MemberTypeDescription
used_timenumberExample
10
running_sessionsnumberExample
0
session_limitnumberExample
0
total_available_timestringExample
Unlimited Testing Time

Source

src/js-testing.ts:31


getBrowsers()

getBrowsers(query, options)

getBrowsers<T>(query?, options?): Promise<Object & Object[]>

Retrieves a list of browsers from the server.

Type parameters
Type parameter
T extends true
Parameters
ParameterTypeDescription
query?Object & Object-
options?APIFetchOptions<Object>The fetch options for the request.
Returns

Promise<Object & Object[]>

A promise that resolves to a fetch response containing the list of browsers.

Source

src/js-testing.ts:35

getBrowsers(query, options)

getBrowsers<T>(query?, options?): Promise<Object>

Retrieves a list of browsers from the server.

Type parameters
Type parameter
T extends false
Parameters
ParameterTypeDescription
query?Object & Object-
options?APIFetchOptions<Object>The fetch options for the request.
Returns

Promise<Object>

A promise that resolves to a fetch response containing the list of browsers.

MemberType
WindowsObject
Windows.7Object & Object[]
Windows.8Object & Object[]
Windows.10Object & Object[]
Windows.11Object & Object[]
Windows.XPObject & Object[]
Windows.8.1Object & Object[]
OS XObject
OS X.Snow LeopardObject & Object[]
OS X.LionObject & Object[]
OS X.Mountain LionObject & Object[]
OS X.MavericksObject & Object[]
OS X.YosemiteObject & Object[]
OS X.El CapitanObject & Object[]
OS X.SierraObject & Object[]
OS X.High SierraObject & Object[]
OS X.MojaveObject & Object[]
OS X.CatalinaObject & Object[]
OS X.Big SurObject & Object[]
OS X.MontereyObject & Object[]
OS X.VenturaObject & Object[]
OS X.SonomaObject & Object[]
OS X.additionalPropertiesObject & Object[]
winphoneObject
winphone.8.1Object & Object[]
androidObject
android.14.0Object & Object[]
android.13.0Object & Object[]
android.12.0Object & Object[]
android.11.0Object & Object[]
android.10.0Object & Object[]
android.9.0Object & Object[]
android.8.1Object & Object[]
android.8.0Object & Object[]
android.7.1Object & Object[]
android.7.0Object & Object[]
android.6.0Object & Object[]
android.5.0Object & Object[]
android.4.4Object & Object[]
android.4.3Object & Object[]
android.4.2Object & Object[]
android.4.1Object & Object[]
android.4.0Object & Object[]
android.2.3Object & Object[]
android.2.2Object & Object[]
android.additionalProperties(Object & Object | Object & Object)[]
Source

src/js-testing.ts:40


createWorker()

createWorker(body, options?): Promise<Object>

Creates a worker for JS testing.

Parameters

ParameterTypeDescription
bodyObject & Object | ObjectThe request body.
options?APIFetchOptions<Object>The API fetch options.

Returns

Promise<Object>

A promise that resolves to the worker response.

MemberTypeDescription
idnumberDescription
ID of the worker

Example
122326697
urlstringDescription
URL of the worker

Example
https://www.google.com/ncr

Source

src/js-testing.ts:75


getWorkers()

getWorkers(options?): Promise<Object & Object & Object[]>

Retrieves a list of workers.

Parameters

ParameterTypeDescription
options?APIFetchOptions<Object>Optional parameters for the API request.

Returns

Promise<Object & Object & Object[]>

A promise that resolves to an array of Worker objects.

Source

src/js-testing.ts:91


getWorker()

getWorker(workerId, options?): Promise<Object & Object & Object>

Retrieves a worker by its ID.

Parameters

ParameterTypeDescription
workerIdnumberThe ID of the worker.
options?APIFetchOptions<Object>Additional options for the API request.

Returns

Promise<Object & Object & Object>

A Promise that resolves to the retrieved worker.

Source

src/js-testing.ts:104


deleteWorker()

deleteWorker(workerId, options?): Promise<Object>

Deletes a worker by worker ID.

Parameters

ParameterTypeDescription
workerIdnumberThe ID of the worker to delete.
options?APIFetchOptions<Object>Optional API fetch options.

Returns

Promise<Object>

A promise that resolves when the worker is deleted.

MemberTypeDescription
messagestringDescription
Status of the termination operation

Example
worker is running for 19.405956957 secs, minimum life is 30 sec
timenumberDescription
Duration of the worker

Example
45.786373558

Source

src/js-testing.ts:125


updateWorkerURL()

updateWorkerURL(workerId, body, options?): Promise<Object>

Updates the URL of a worker.

Parameters

ParameterTypeDescription
workerIdnumberThe ID of the worker.
bodyObjectThe request body containing the updated URL.
body.urlstringDescription
New URL for the worker

Example
https://www.google.com/ncr
options?APIFetchOptions<Object>Optional API fetch options.

Returns

Promise<Object>

A promise that resolves with the response from the server.

MemberTypeDescription
messagestringDescription
Status of the update URL operation

Example
Browser updated with new url

Source

src/js-testing.ts:147


getWorkerScreenshot()

getWorkerScreenshot(workerId, format, options)

getWorkerScreenshot(workerId, format, options?): Promise<ArrayBuffer>

Takes a screenshot of a worker.

Parameters
ParameterTypeDescription
workerIdnumberThe ID of the worker.
format"png"The format of the screenshot (e.g., "png", "json", "xml").
options?APIFetchOptions<Object>Additional options for the API request.
Returns

Promise<ArrayBuffer>

A Promise that resolves to the screenshot data.

Source

src/js-testing.ts:163

getWorkerScreenshot(workerId, format, options)

getWorkerScreenshot(workerId, format, options?): Promise<Object>

Takes a screenshot of a worker.

Parameters
ParameterTypeDescription
workerIdnumberThe ID of the worker.
format"json"The format of the screenshot (e.g., "png", "json", "xml").
options?APIFetchOptions<Object>Additional options for the API request.
Returns

Promise<Object>

A Promise that resolves to the screenshot data.

MemberType
urlstring
Source

src/js-testing.ts:169

getWorkerScreenshot(workerId, format, options)

getWorkerScreenshot(workerId, format, options?): Promise<string>

Takes a screenshot of a worker.

Parameters
ParameterTypeDescription
workerIdnumberThe ID of the worker.
format"xml"The format of the screenshot (e.g., "png", "json", "xml").
options?APIFetchOptions<Object>Additional options for the API request.
Returns

Promise<string>

A Promise that resolves to the screenshot data.

Source

src/js-testing.ts:175


ensureWorkerRunning()

ensureWorkerRunning(workerId, options?, pollInterval?): Promise<Object & Object & Object>

Awaits a worker with the specified workerId to attain "running" status.

Parameters

ParameterTypeDefault valueDescription
workerIdnumberundefinedThe ID of the worker to retrieve.
options?APIFetchOptions<Object>undefinedOptional API fetch options.
pollInterval?number10_000The interval (in milliseconds) at which to poll for the worker status. Default is 10000ms.

Returns

Promise<Object & Object & Object>

A promise that resolves with the running worker.

Source

src/js-testing.ts:215


launch()

launch(body, options?): Promise<Object>

High-level abstraction for launching a worker-browser with the specified options.

Parameters

ParameterTypeDescription
bodyObject & Object | ObjectThe request body for creating the worker.
options?APIFetchOptions<Object> & ObjectThe options for creating the worker.

Returns

Promise<Object>

A promise that resolves to the launched worker.

MemberTypeValueDescription
browserstring-Example
Chrome
browser_versionstring-Example
80.0
osstring-Example
Windows
os_versionstring-Example
10
devicestring-Example
null
real_mobileboolean-Example
null
idnumber-Description
ID of the worker.

Example
122326697
sessionIdunknown-Description
ID of the session.

Example
550709149fe79e949363b581e774d5ebffa1b8fe
status"running" | "queue"-Description
Current status of the worker.

Example
running @enum {string}
browser_urlstring-Description
Dashboard URL of the session

Example
updateURL(url) => Promise<Object>--
getScreenshot() => Promise<ArrayBuffer>--
getScreenshotURL() => Promise<string>--
terminate() => Promise<Object>--

Source

src/js-testing.ts:266