UNPKG

3.29 kBMarkdownView Raw
1# node-browserstack
2
3A node.js JavaScript client for working with [BrowserStack](http://browserstack.com) through its [API](https://github.com/browserstack/api).
4
5## Installation
6
7```
8npm install browserstack
9```
10
11## Usage
12
13```javascript
14var BrowserStack = require( "browserstack" );
15var client = BrowserStack.createClient({
16 username: "foo",
17 password: "p455w0rd!!1"
18});
19
20client.getBrowsers(function( error, browsers ) {
21 console.log( "The following browsers are available for testing" );
22 console.log( browsers );
23});
24```
25
26## API
27
28### BrowserStack.createClient( settings )
29
30Creates a new client instance.
31
32* `settings`: A hash of settings that apply to all requests for the new client.
33 * `username`: The username for the BrowserStack account.
34 * `password`: The password for the BrowserStack account.
35 * `version` (optional; default: `1`): Which version of the BrowserStack API to use.
36
37*Note: A special value of "latest" is supported for `version`, which will use the latest stable version.*
38
39### client.getBrowsers( callback )
40
41Gets the list of available browsers.
42
43* `callback` (`function( error, browsers )`): A callback to invoke when the API call is complete.
44 * `browsers`: An array of objects with `browser` and `version` properties.
45
46### client.createWorker( settings, callback )
47
48Creates a worker.
49
50* `settings`: A hash of settings for the worker.
51 * `browser`: Which browser to use in the new worker.
52 * `version`: Which version of the specified browser to use.
53 * `url` (optional): Which URL to navigate to upon creation.
54 * `timeout` (optional): Maximum life of the worker (in seconds). Use 0 for "forever" (BrowserStack will kill the worker after 1,800 seconds).
55* `callback` (`function( error, worker )`): A callback to invoke when the API call is complete.
56 * `worker` An object with an `id` property for the worker that was created.
57
58### client.getWorker( id, callback )
59
60Gets the status of a worker.
61
62* `id`: The id of the worker.
63* `callback` (`function( error, worker )`): A callback to invoke when the API call is complete.
64 * `worker`: An object with `id`, `browser`, and `status` properties for the worker.
65
66### client.terminateWorker( id, callback )
67
68Terminates an active worker.
69
70* `id`: The id of the worker to terminate.
71* `callback` (`function( error, data )`): A callback to invoke when the API call is complete.
72 * `data`: An object with a `time` property indicating how long the worker was alive.
73
74### client.getWorkers( callback )
75
76Gets the status of all workers.
77
78* `callback` (`function( error, workers )`): A callback to invoke when the API call is complete.
79 * `workers`: An array of objects containing with `id`, `browser`, and `status` properties.
80
81### client.getLatest( browser, callback )
82
83Gets the latest version of a browser.
84
85* `browser`: Which browser to get the latest version for.
86* `callback` (`function( error, version )`): A callback to invoke when the version is determined.
87 * `version`: The latest version of the browser.
88
89### client.getLatest( callback )
90
91Gets the latest version of all browsers.
92
93* `callback` (`function( error, versions )`): A callback to invoke when the versions are determined.
94 * `versions`: An hash of browser names and versions.
95
96## License
97
98node-browserstack is licensed under the MIT license.