Skip to content

Commit f9ae74f

Browse files
committed
updated README
1 parent 0eaf577 commit f9ae74f

File tree

1 file changed

+108
-30
lines changed

1 file changed

+108
-30
lines changed

README.md

Lines changed: 108 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,127 @@
22

33
[![Build Status](https://travis-ci.org/browserstack/browserstack-local-nodejs.svg?branch=master)](https://travis-ci.org/browserstack/browserstack-local-nodejs)
44

5-
## Setup
5+
A simple Nodejs wrapper for BrowserStack Local Binary.
6+
7+
## Installation
68

79
```
8-
npm install browserstack
10+
npm install browserstack-local
911
```
1012

11-
## API
13+
## Example
1214

13-
### Constructor
15+
```
16+
var browserstack = require('browserstack-local');
1417
15-
* `new browserstack.Local()`: creates an instance of Local
18+
# creates an instance of Local
19+
var bs_local = new browserstack.Local();
1620
17-
### Methods
21+
# replace <browserstack-accesskey> with your key. You can also set an environment variable - "BROWSERSTACK_ACCESS_KEY".
22+
var bs_local_args = { '-key': '<browserstack-accesskey>' };
1823
19-
* `start(options, callback)`: starts Local instance with options. The options available are detailed below.
20-
* `stop(callback)`: stops the Local instance
21-
* `isRunning()`: checks if Local instance is running and returns a corresponding boolean value
24+
# starts the Local instance with the required arguments
25+
bs_local.start(bs_local_args, function() {
26+
console.log("Started BrowserStackLocal");
27+
});
2228
23-
The first and only argument to any callback function will be an error object.
29+
# check if BrowserStack local instance is running
30+
console.log(bs_local.isRunning());
2431
25-
### Options
32+
# stop the Local instance
33+
bs_local.stop(function() {
34+
console.log("Stopped BrowserStackLocal");
35+
});
2636
27-
* `key`: BrowserStack Access Key
28-
* `v`: Provides verbose logging
29-
* `f`: If you want to test local folder rather internal server, provide path to folder as value of this option
30-
* `force`: Kill other running Browserstack Local
31-
* `only`: Restricts Local Testing access to specified local servers and/or folders
32-
* `forcelocal`: Route all traffic via local machine
33-
* `onlyAutomate`: Disable Live Testing and Screenshots, just test Automate
34-
* `proxyHost`: Hostname/IP of proxy, remaining proxy options are ignored if this option is absent
35-
* `proxyPort`: Port for the proxy, defaults to 3128 when -proxyHost is used
36-
* `proxyUser`: Username for connecting to proxy (Basic Auth Only)
37-
* `proxyPass`: Password for USERNAME, will be ignored if USERNAME is empty or not specified
38-
* `localIdentifier`: If doing simultaneous multiple local testing connections, set this uniquely for different processes
39-
* `hosts`: List of hosts and ports where Local must be enabled for eg. localhost,3000,1,localhost,3001,0
40-
* `logfile`: Path to file where Local logs be saved to
41-
* `binarypath`: Optional path to Local binary
37+
```
4238

39+
## Arguments
4340

44-
## Tests
41+
Apart from the key, all other BrowserStack Local modifiers are optional. For the full list of modifiers, refer [BrowserStack Local modifiers](https://www.browserstack.com/local-testing#modifiers). For examples, refer below -
4542

46-
To run the test suite run - `npm test`.
43+
#### Verbose Logging
44+
To enable verbose logging -
45+
```
46+
bs_local_args = { '-key': '<browserstack-accesskey>', 'v': 'true' }
47+
```
4748

48-
## Example
49+
#### Folder Testing
50+
To test local folder rather internal server, provide path to folder as value of this option -
51+
```
52+
bs_local_args = { 'key': '<browserstack-accesskey>', 'f': '/my/awesome/folder' }
53+
```
54+
55+
#### Force Start
56+
To kill other running Browserstack Local instances -
57+
```
58+
bs_local_args = { 'key': '<browserstack-accesskey>', 'force': 'true' }
59+
```
60+
61+
#### Only Automate
62+
To disable local testing for Live and Screenshots, and enable only Automate -
63+
```
64+
bs_local_args = { 'key': '<browserstack-accesskey>', 'onlyAutomate': 'true' }
65+
```
66+
67+
#### Force Local
68+
To route all traffic via local(your) machine -
69+
```
70+
bs_local_args = { 'key': '<browserstack-accesskey>', 'forcelocal': 'true' }
71+
```
72+
73+
#### Proxy
74+
To use a proxy for local testing -
75+
76+
* proxyHost: Hostname/IP of proxy, remaining proxy options are ignored if this option is absent
77+
* proxyPort: Port for the proxy, defaults to 3128 when -proxyHost is used
78+
* proxyUser: Username for connecting to proxy (Basic Auth Only)
79+
* proxyPass: Password for USERNAME, will be ignored if USERNAME is empty or not specified
80+
81+
```
82+
bs_local_args = { 'key': '<browserstack-accesskey>', 'proxyHost': '127.0.0.1', 'proxyPort': '8000', 'proxyUser': 'user', 'proxyPass': 'password' }
83+
```
84+
85+
#### Local Identifier
86+
If doing simultaneous multiple local testing connections, set this uniquely for different processes -
87+
```
88+
bs_local_args = { 'key': '<browserstack-accesskey>', 'localIdentifier': 'randomstring' }
89+
```
90+
91+
## Additional Arguments
92+
93+
#### Binary Path
94+
95+
By default, BrowserStack local wrappers try downloading and executing the latest version of BrowserStack binary in ~/.browserstack or the present working directory or the tmp folder by order. But you can override these by passing the -binarypath argument.
96+
Path to specify local Binary path -
97+
```
98+
bs_local_args = { 'key': '<browserstack-accesskey>', 'binarypath': '/browserstack/BrowserStackLocal' }
99+
```
100+
101+
#### Logfile
102+
To save the logs to the file while running with the '-v' argument, you can specify the path of the file. By default the logs are saved in the local.log file in the present woring directory.
103+
To specify the path to file where the logs will be saved -
104+
```
105+
bs_local_args = { 'key': '<browserstack-accesskey>', 'v': 'true', 'logfile': '/browserstack/logs.txt' }
106+
```
107+
108+
## Contribute
109+
110+
### Instructions
111+
112+
To run the test suite run, `npm test`.
113+
114+
### Reporting bugs
115+
116+
You can submit bug reports either in the Github issue tracker.
117+
118+
Before submitting an issue please check if there is already an existing issue. If there is, please add any additional information give it a "+1" in the comments.
119+
120+
When submitting an issue please describe the issue clearly, including how to reproduce the bug, which situations it appears in, what you expect to happen, what actually happens, and what platform (operating system and version) you are using.
121+
122+
### Pull Requests
123+
124+
We love pull requests! We are very happy to work with you to get your changes merged in, however, please keep the following in mind.
49125

50-
To run the example run - `node node-example.js`.
126+
* Adhere to the coding conventions you see in the surrounding code.
127+
* Include tests, and make sure all tests pass.
128+
* Before submitting a pull-request, clean up the git history by going over your commits and squashing together minor changes and fixes into the corresponding commits. You can do this using the interactive rebase command.

0 commit comments

Comments
 (0)