Skip to content

Commit e26a47d

Browse files
authored
Merge pull request #233 from yashLadha/add/binary_path_env
add/binary path env
2 parents 3eb401f + d3ee2ba commit e26a47d

File tree

3 files changed

+80
-78
lines changed

3 files changed

+80
-78
lines changed

README.md

+76-76
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ Sample Usage:
4343
`browserstack-runner` can also be used as a module. To run your tests, inside your project do -
4444

4545
```node
46-
var browserstackRunner = require('browserstack-runner');
46+
var browserstackRunner = require("browserstack-runner");
4747

48-
var config = require('./browserstack.json');
48+
var config = require("./browserstack.json");
4949

5050
browserstackRunner.run(config, function(error, report) {
51-
if(error) {
51+
if (error) {
5252
console.log("Error:" + error);
5353
return;
5454
}
@@ -58,6 +58,7 @@ browserstackRunner.run(config, function(error, report) {
5858
```
5959

6060
The callback to `browserstackRunner.run` is called with two params -
61+
6162
- `error`: This parameter is either `null` or an `Error` object (if test execution failed) with message as the reason of why executing the tests on `BrowserStack` failed.
6263
- `report`: This is an array which can be used to keep track of the executed tests and suites in a run. Each object in the array has the following keys -
6364
- `browser`: The name of the browser the test executed on.
@@ -74,10 +75,7 @@ The structure of the `report` object is as follows -
7475
{
7576
"name": "isOdd()",
7677
"suiteName": "Odd Tests",
77-
"fullName": [
78-
"Odd Tests",
79-
"isOdd()"
80-
],
78+
"fullName": ["Odd Tests", "isOdd()"],
8179
"status": "passed",
8280
"runtime": 2,
8381
"errors": [],
@@ -108,18 +106,13 @@ The structure of the `report` object is as follows -
108106
"childSuites": [
109107
{
110108
"name": "Odd Tests",
111-
"fullName": [
112-
"Odd Tests"
113-
],
109+
"fullName": ["Odd Tests"],
114110
"childSuites": [],
115111
"tests": [
116112
{
117113
"name": "isOdd()",
118114
"suiteName": "Odd Tests",
119-
"fullName": [
120-
"Odd Tests",
121-
"isOdd()"
122-
],
115+
"fullName": ["Odd Tests", "isOdd()"],
123116
"status": "passed",
124117
"runtime": 2,
125118
"errors": [],
@@ -181,17 +174,17 @@ To run browser tests on BrowserStack infrastructure, you need to create a `brows
181174

182175
### Parameters for `browserstack.json`
183176

184-
* `username`: BrowserStack username (Or `BROWSERSTACK_USERNAME` environment variable)
185-
* `key`: BrowserStack [access key](https://www.browserstack.com/accounts/local-testing) (Or `BROWSERSTACK_KEY` environment variable)
186-
* `test_path`: Path to the test page which will run the tests when opened in a browser.
187-
* `test_framework`: Specify test framework which will run the tests. Currently supporting qunit, jasmine, jasmine1.3.1, jasmine2 and mocha.
188-
* `test_server_port`: Specify test server port that will be opened from BrowserStack. If not set the default port 8888 will be used. Find a [list of all supported ports on browerstack.com](https://www.browserstack.com/question/664).
189-
* `timeout`: Specify worker timeout with BrowserStack.
190-
* `browsers`: A list of browsers on which tests are to be run. Find a [list of all supported browsers and platforms on browerstack.com](https://www.browserstack.com/list-of-browsers-and-platforms?product=js_testing).
191-
* `build`: A string to identify your test run in Browserstack. In `TRAVIS` setup `TRAVIS_COMMIT` will be the default identifier.
192-
* `proxy`: Specify a proxy to use for the local tunnel. Object with `host`, `port`, `username` and `password` properties.
193-
* `exit_with_fail`: If set to true the cli process will exit with fail if any of the tests failed. Useful for automatic build systems.
194-
* `tunnel_pid_file`: Specify a path to file to save the tunnel process id into. Can also by specified using the `--pid` flag while launching browserstack-runner from the command line.
177+
- `username`: BrowserStack username (Or `BROWSERSTACK_USERNAME` environment variable)
178+
- `key`: BrowserStack [access key](https://www.browserstack.com/accounts/local-testing) (Or `BROWSERSTACK_KEY` environment variable)
179+
- `test_path`: Path to the test page which will run the tests when opened in a browser.
180+
- `test_framework`: Specify test framework which will run the tests. Currently supporting qunit, jasmine, jasmine1.3.1, jasmine2 and mocha.
181+
- `test_server_port`: Specify test server port that will be opened from BrowserStack. If not set the default port 8888 will be used. Find a [list of all supported ports on browerstack.com](https://www.browserstack.com/question/664).
182+
- `timeout`: Specify worker timeout with BrowserStack.
183+
- `browsers`: A list of browsers on which tests are to be run. Find a [list of all supported browsers and platforms on browerstack.com](https://www.browserstack.com/list-of-browsers-and-platforms?product=js_testing).
184+
- `build`: A string to identify your test run in Browserstack. In `TRAVIS` setup `TRAVIS_COMMIT` will be the default identifier.
185+
- `proxy`: Specify a proxy to use for the local tunnel. Object with `host`, `port`, `username` and `password` properties.
186+
- `exit_with_fail`: If set to true the cli process will exit with fail if any of the tests failed. Useful for automatic build systems.
187+
- `tunnel_pid_file`: Specify a path to file to save the tunnel process id into. Can also by specified using the `--pid` flag while launching browserstack-runner from the command line.
195188

196189
A sample configuration file:
197190

@@ -232,32 +225,35 @@ A sample configuration file:
232225
`browsers` parameter is a list of objects, where each object contains the details of the browsers on which you want to run your tests. This object differs for browsers on desktop platforms and browsers on mobile platforms. Browsers on desktop platform should contain `browser`, `browser_version`, `os`, `os_version` parameters set as required and the `cli_key` parameter is optional and can be used in the command line when tests need to be run on a set of browsers from the `browserstack.json` file.
233226

234227
Example:
228+
235229
```json
236230
{
237-
"browser": "ie",
238-
"browser_version": "10.0",
239-
"os": "Windows",
240-
"os_version": "8",
241-
"cli_key": 1
231+
"browser": "ie",
232+
"browser_version": "10.0",
233+
"os": "Windows",
234+
"os_version": "8",
235+
"cli_key": 1
242236
}
243237
```
244238

245239
For mobile platforms, `os`, `os_version` and `device` parameters are required.
246240

247241
Example:
242+
248243
```json
249-
[{
250-
"os": "ios",
251-
"os_version": "8.3",
252-
"device": "iPhone 6 Plus",
253-
"cli_key": 1
254-
},
255-
{
256-
"os": "android",
257-
"os_version": "4.0",
258-
"device": "Google Nexus",
259-
"cli_key": 2
260-
}
244+
[
245+
{
246+
"os": "ios",
247+
"os_version": "8.3",
248+
"device": "iPhone 6 Plus",
249+
"cli_key": 1
250+
},
251+
{
252+
"os": "android",
253+
"os_version": "4.0",
254+
"device": "Google Nexus",
255+
"cli_key": 2
256+
}
261257
]
262258
```
263259

@@ -266,48 +262,52 @@ For a full list of supported browsers, platforms and other details, [visit the B
266262
#### Compact `browsers` configuration
267263

268264
When `os` and `os_version` granularity is not desired, following configuration can be used:
269-
* `[browser]_current` or *browser*_latest: will assign the latest version of the *browser*.
270-
* `[browser]_previous`: will assign the previous version of the *browser*.
271-
* `[browser]_[version]`: will assign the *version* specified of the *browser*. Minor versions can be concatenated with underscores.
265+
266+
- `[browser]_current` or _browser_\_latest: will assign the latest version of the _browser_.
267+
- `[browser]_previous`: will assign the previous version of the _browser_.
268+
- `[browser]_[version]`: will assign the _version_ specified of the _browser_. Minor versions can be concatenated with underscores.
272269

273270
This can also be mixed with fine-grained configuration.
274271

275272
Example:
273+
276274
```json
277275
{
278276
"browsers": [
279-
"chrome_previous",
280-
"chrome_latest",
281-
"firefox_previous",
282-
"firefox_latest",
283-
"ie_6",
284-
"ie_11",
285-
"opera_12_1",
286-
"safari_5_1",
287-
{
288-
"browser": "ie",
289-
"browser_version": "10.0",
290-
"device": null,
291-
"os": "Windows",
292-
"os_version": "8",
293-
"cli_key": 1
294-
}
277+
"chrome_previous",
278+
"chrome_latest",
279+
"firefox_previous",
280+
"firefox_latest",
281+
"ie_6",
282+
"ie_11",
283+
"opera_12_1",
284+
"safari_5_1",
285+
{
286+
"browser": "ie",
287+
"browser_version": "10.0",
288+
"device": null,
289+
"os": "Windows",
290+
"os_version": "8",
291+
"cli_key": 1
292+
}
295293
]
296294
}
297295
```
296+
298297
**Note:**
299298
These shortcuts work only for browsers on desktop platforms supported by BrowserStack.
300299

301300
### Proxy support for BrowserStack local
302301

303302
Add the following in `browserstack.json`
303+
304304
```json
305305
{
306306
"proxy": {
307-
"host": "localhost",
308-
"port": 3128,
309-
"username": "foo",
310-
"password": "bar"
307+
"host": "localhost",
308+
"port": 3128,
309+
"username": "foo",
310+
"password": "bar"
311311
}
312312
}
313313
```
@@ -316,19 +316,18 @@ Add the following in `browserstack.json`
316316

317317
To avoid duplication of system or user specific information across several configuration files, use these environment variables:
318318

319-
* `BROWSERSTACK_USERNAME`: BrowserStack user name.
320-
* `BROWSERSTACK_KEY`: BrowserStack key.
321-
* `TUNNEL_ID`: Identifier for the current instance of the tunnel process. In `TRAVIS` setup `TRAVIS_JOB_ID` will be the default identifier.
322-
* `BROWSERSTACK_JSON`: Path to the browserstack.json file. If null, `browserstack.json` in the root directory will be used.
323-
319+
- `BROWSERSTACK_USERNAME`: BrowserStack user name.
320+
- `BROWSERSTACK_KEY`: BrowserStack key.
321+
- `TUNNEL_ID`: Identifier for the current instance of the tunnel process. In `TRAVIS` setup `TRAVIS_JOB_ID` will be the default identifier.
322+
- `BROWSERSTACK_JSON`: Path to the browserstack.json file. If null, `browserstack.json` in the root directory will be used.
323+
- `BROWSERSTACK_LOCAL_BINARY_PATH`: Path to the browserstack local binary present on the system. If null, `BrowserStackLocal` in the `lib/` directory will be used.
324324

325325
### Secure Information
326326

327327
To avoid checking in the BrowserStack `username` and `key` in your source control system, the corresponding environment variables can be used.
328328

329329
These can also be provided by a build server, for example [using secure environment variables on Travis CI](http://about.travis-ci.org/docs/user/build-configuration/#Secure-environment-variables).
330330

331-
332331
### Code Sample
333332

334333
Check out code sample [here](https://github.com/browserstack/browserstack-runner-sample).
@@ -348,11 +347,12 @@ To run a larger suite of tests ensuring compatibility with older versions of QUn
348347
Tests are also run for every pull request, courtesy [Travis CI](https://travis-ci.org/).
349348

350349
### Timeout issue with Travis CI
351-
352-
You might face [build timeout issue on Travis](https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received) if runner takes more than 10 minutes to run tests.
353350

354-
There are 2 possible ways to solve this problem:
355-
1. Run a script which does `console.log` every 1-2 minutes. This will output to console and hence avoid Travis build timeout
356-
2. Use `travis_wait` function provided by Travis-CI. You can prefix `browserstack-runner` command by `travis-wait` in your `travis.yml` file
351+
You might face [build timeout issue on Travis](https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received) if runner takes more than 10 minutes to run tests.
352+
353+
There are 2 possible ways to solve this problem:
354+
355+
1. Run a script which does `console.log` every 1-2 minutes. This will output to console and hence avoid Travis build timeout
356+
2. Use `travis_wait` function provided by Travis-CI. You can prefix `browserstack-runner` command by `travis-wait` in your `travis.yml` file
357357

358358
We would recommend using `travis_wait` function. It also allows you to configure wait time (ex: `travis_wait 20 browserstack-runner`, this will extend wait time to 20 minutes). Read more about `travis_wait` [here](https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received)

bin/cli.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,11 @@ function runTests(config, callback) {
421421
}
422422
}
423423

424-
exports.run = function(user_config, callback) {
424+
exports.run = function(userConfig, callback) {
425425
callback = callback || function() {};
426426

427427
try {
428-
config = new (require('../lib/config').config)(user_config);
428+
config = new (require('../lib/config').config)(userConfig);
429429

430430
client = BrowserStack.createClient({
431431
username: config.username,

lib/local.js

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ var Log = require('./logger'),
1111
var Tunnel = function Tunnel(key, port, uniqueIdentifier, config, callback) {
1212
var that = {};
1313

14+
localBinary = process.env.BROWSERSTACK_LOCAL_BINARY_PATH || localBinary;
15+
1416
function tunnelLauncher() {
1517
var tunnelOptions = getTunnelOptions(key, uniqueIdentifier);
1618

0 commit comments

Comments
 (0)