Skip to content

Commit 6e2ef8b

Browse files
committedNov 16, 2016
update browserstack local with new commands
1 parent b7c2c23 commit 6e2ef8b

File tree

4 files changed

+89
-56
lines changed

4 files changed

+89
-56
lines changed
 

‎README.md

+3-10
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Apart from the key, all other BrowserStack Local modifiers are optional. For the
4343
#### Verbose Logging
4444
To enable verbose logging -
4545
```node
46-
bs_local_args = { 'key': '<browserstack-accesskey>', 'v': 'true' }
46+
bs_local_args = { 'key': '<browserstack-accesskey>', 'verbose': 'true' }
4747
```
4848

4949
#### Folder Testing
@@ -67,7 +67,7 @@ bs_local_args = { 'key': '<browserstack-accesskey>', 'onlyAutomate': 'true' }
6767
#### Force Local
6868
To route all traffic via local(your) machine -
6969
```node
70-
bs_local_args = { 'key': '<browserstack-accesskey>', 'forcelocal': 'true' }
70+
bs_local_args = { 'key': '<browserstack-accesskey>', 'forceLocal': 'true' }
7171
```
7272

7373
#### Proxy
@@ -90,19 +90,12 @@ bs_local_args = { 'key': '<browserstack-accesskey>', 'localIdentifier': 'randoms
9090

9191
## Additional Arguments
9292

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-
```node
98-
bs_local_args = { 'key': '<browserstack-accesskey>', 'binarypath': '/browserstack/BrowserStackLocal' }
99-
```
10093

10194
#### Logfile
10295
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.
10396
To specify the path to file where the logs will be saved -
10497
```node
105-
bs_local_args = { 'key': '<browserstack-accesskey>', 'v': 'true', 'logfile': '/browserstack/logs.txt' }
98+
bs_local_args = { 'key': '<browserstack-accesskey>', 'verbose': 'true', 'logFile': '/browserstack/logs.txt' }
10699
```
107100

108101
## Contribute

‎lib/Local.js

+36-28
Original file line numberDiff line numberDiff line change
@@ -121,29 +121,33 @@ function Local(){
121121
this.key = value;
122122
break;
123123

124-
case 'v':
125-
if(value)
126-
this.verboseFlag = '-vvv';
124+
case 'verbose':
125+
if(value.toString() !== 'true')
126+
this.verboseFlag = value;
127+
else {
128+
this.verboseFlag = 1;
129+
}
127130
break;
128131

129132
case 'force':
130133
if(value)
131-
this.forceFlag = '-force';
134+
this.forceFlag = '--force';
132135
break;
133136

134137
case 'only':
135138
if(value)
136-
this.onlyFlag = '-only';
139+
this.onlyHosts = value;
137140
break;
138141

139142
case 'onlyAutomate':
140143
if(value)
141-
this.onlyAutomateFlag = '-onlyAutomate';
144+
this.onlyAutomateFlag = '--only-automate';
142145
break;
143146

144147
case 'forcelocal':
148+
case 'forceLocal':
145149
if(value)
146-
this.forceLocalFlag = '-forcelocal';
150+
this.forceLocalFlag = '--force-local';
147151
break;
148152

149153
case 'localIdentifier':
@@ -152,6 +156,7 @@ function Local(){
152156
break;
153157

154158
case 'f':
159+
case 'folder':
155160
if(value){
156161
this.folderFlag = '-f';
157162
this.folderPath = value;
@@ -179,30 +184,27 @@ function Local(){
179184
break;
180185

181186
case 'forceproxy':
187+
case 'forceProxy':
182188
if(value)
183-
this.forceProxyFlag = '-forceproxy';
184-
break;
185-
186-
case 'hosts':
187-
if(value)
188-
this.hosts = value;
189+
this.forceProxyFlag = '--force-proxy';
189190
break;
190191

191192
case 'logfile':
193+
case 'logFile':
192194
if(value)
193195
this.logfile = value;
194196
break;
195197

196-
case 'binarypath':
198+
case 'parallelRuns':
197199
if(value)
198-
this.binaryPath = value;
200+
this.parallelRunsFlag = value;
199201
break;
200202

201203
default:
202204
if(value.toString().toLowerCase() == 'true'){
203-
this.userArgs.push('-' + key);
205+
this.userArgs.push('--' + key);
204206
} else {
205-
this.userArgs.push('-' + key);
207+
this.userArgs.push('--' + key);
206208
this.userArgs.push(value);
207209
}
208210
break;
@@ -226,36 +228,44 @@ function Local(){
226228
};
227229

228230
this.getBinaryArgs = function(){
229-
var args = ['-d', this.opcode, '-logFile', this.logfile];
231+
var args = ['--daemon', this.opcode, '--log-file', this.logfile];
230232
if(this.folderFlag)
231233
args.push(this.folderFlag);
232-
args.push(this.key);
234+
if(this.key) {
235+
args.push('--key');
236+
args.push(this.key);
237+
}
233238
if(this.folderPath)
234239
args.push(this.folderPath);
235240
if(this.forceLocalFlag)
236241
args.push(this.forceLocalFlag);
237242
if(this.localIdentifierFlag){
238-
args.push('-localIdentifier');
243+
args.push('--local-identifier');
239244
args.push(this.localIdentifierFlag);
240245
}
241-
if(this.onlyFlag)
242-
args.push(this.onlyFlag);
246+
if(this.parallelRunsFlag){
247+
args.push('--parallel-runs');
248+
args.push(this.parallelRunsFlag);
249+
}
250+
if(this.onlyHosts)
251+
args.push('--only');
252+
args.push(this.onlyHosts);
243253
if(this.onlyAutomateFlag)
244254
args.push(this.onlyAutomateFlag);
245255
if(this.proxyHost){
246-
args.push('-proxyHost');
256+
args.push('--proxy-host');
247257
args.push(this.proxyHost);
248258
}
249259
if(this.proxyPort){
250-
args.push('-proxyPort');
260+
args.push('--proxy-port');
251261
args.push(this.proxyPort);
252262
}
253263
if(this.proxyUser){
254-
args.push('-proxyUser');
264+
args.push('--proxy-user');
255265
args.push(this.proxyUser);
256266
}
257267
if(this.proxyPass){
258-
args.push('-proxyPass');
268+
args.push('--proxy-pass');
259269
args.push(this.proxyPass);
260270
}
261271
if(this.forceProxyFlag)
@@ -264,8 +274,6 @@ function Local(){
264274
args.push(this.forceFlag);
265275
if(this.verboseFlag)
266276
args.push(this.verboseFlag);
267-
if(this.hosts)
268-
args.push(this.hosts);
269277
for(var i in this.userArgs){
270278
args.push(this.userArgs[i]);
271279
}

‎node-example.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var capabilities = {
1313
}
1414

1515
var options = {
16-
'-key': process.env.BROWSERSTACK_ACCESS_KEY,
16+
'key': process.env.BROWSERSTACK_ACCESS_KEY,
1717
//hosts: [{
1818
// name: 'localhost',
1919
// port: 8080,

‎test/local.js

+49-17
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,17 @@ describe('Local', function () {
5050
});
5151

5252
it('should enable verbose', function (done) {
53-
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'v': true }, function(){
54-
expect(bsLocal.getBinaryArgs().indexOf('-vvv')).to.not.equal(-1);
53+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'verbose': true }, function(){
54+
expect(bsLocal.getBinaryArgs().indexOf('--verbose')).to.not.equal(-1);
55+
expect(bsLocal.getBinaryArgs().indexOf('1')).to.not.equal(-1);
56+
done();
57+
});
58+
});
59+
60+
it('should enable verbose with log level', function (done) {
61+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'verbose': 2 }, function(){
62+
expect(bsLocal.getBinaryArgs().indexOf('--verbose')).to.not.equal(-1);
63+
expect(bsLocal.getBinaryArgs().indexOf('2')).to.not.equal(-1);
5564
done();
5665
});
5766
});
@@ -64,63 +73,85 @@ describe('Local', function () {
6473
});
6574
});
6675

76+
it('should set folder testing with folder option', function (done) {
77+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'folder': '/var/html' }, function(){
78+
expect(bsLocal.getBinaryArgs().indexOf('-f')).to.not.equal(-1);
79+
expect(bsLocal.getBinaryArgs().indexOf('/var/html')).to.not.equal(-1);
80+
done();
81+
});
82+
});
83+
6784
it('should enable force', function (done) {
6885
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'force': true }, function(){
69-
expect(bsLocal.getBinaryArgs().indexOf('-force')).to.not.equal(-1);
86+
expect(bsLocal.getBinaryArgs().indexOf('--force')).to.not.equal(-1);
7087
done();
7188
});
7289
});
7390

7491
it('should enable only', function (done) {
7592
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'only': true }, function(){
76-
expect(bsLocal.getBinaryArgs().indexOf('-only')).to.not.equal(-1);
93+
expect(bsLocal.getBinaryArgs().indexOf('--only')).to.not.equal(-1);
7794
done();
7895
});
7996
});
8097

8198
it('should enable onlyAutomate', function (done) {
8299
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'onlyAutomate': true }, function(){
83-
expect(bsLocal.getBinaryArgs().indexOf('-onlyAutomate')).to.not.equal(-1);
100+
expect(bsLocal.getBinaryArgs().indexOf('--only-automate')).to.not.equal(-1);
84101
done();
85102
});
86103
});
87104

88105
it('should enable forcelocal', function (done) {
89106
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'forcelocal': true }, function(){
90-
expect(bsLocal.getBinaryArgs().indexOf('-forcelocal')).to.not.equal(-1);
107+
expect(bsLocal.getBinaryArgs().indexOf('--force-local')).to.not.equal(-1);
108+
done();
109+
});
110+
});
111+
112+
it('should enable forcelocal with camel case', function (done) {
113+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'forceLocal': true }, function(){
114+
expect(bsLocal.getBinaryArgs().indexOf('--force-local')).to.not.equal(-1);
91115
done();
92116
});
93117
});
94118

95119
it('should enable custom boolean args', function (done) {
96120
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'boolArg1': true, 'boolArg2': true }, function(){
97-
expect(bsLocal.getBinaryArgs().indexOf('-boolArg1')).to.not.equal(-1);
98-
expect(bsLocal.getBinaryArgs().indexOf('-boolArg2')).to.not.equal(-1);
121+
expect(bsLocal.getBinaryArgs().indexOf('--boolArg1')).to.not.equal(-1);
122+
expect(bsLocal.getBinaryArgs().indexOf('--boolArg2')).to.not.equal(-1);
99123
done();
100124
});
101125
});
102126

103127
it('should enable custom keyval args', function (done) {
104128
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'customKey1': 'custom value1', 'customKey2': 'custom value2' }, function(){
105-
expect(bsLocal.getBinaryArgs().indexOf('-customKey1')).to.not.equal(-1);
129+
expect(bsLocal.getBinaryArgs().indexOf('--customKey1')).to.not.equal(-1);
106130
expect(bsLocal.getBinaryArgs().indexOf('custom value1')).to.not.equal(-1);
107-
expect(bsLocal.getBinaryArgs().indexOf('-customKey2')).to.not.equal(-1);
131+
expect(bsLocal.getBinaryArgs().indexOf('--customKey2')).to.not.equal(-1);
108132
expect(bsLocal.getBinaryArgs().indexOf('custom value2')).to.not.equal(-1);
109133
done();
110134
});
111135
});
112136

113137
it('should enable forceproxy', function (done) {
114138
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'forceproxy': true }, function(){
115-
expect(bsLocal.getBinaryArgs().indexOf('-forceproxy')).to.not.equal(-1);
139+
expect(bsLocal.getBinaryArgs().indexOf('--force-proxy')).to.not.equal(-1);
140+
done();
141+
});
142+
});
143+
144+
it('should enable forceproxy with camel case', function (done) {
145+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'forceProxy': true }, function(){
146+
expect(bsLocal.getBinaryArgs().indexOf('--force-proxy')).to.not.equal(-1);
116147
done();
117148
});
118149
});
119150

120151

121152
it('should set localIdentifier', function (done) {
122153
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'localIdentifier': 'abcdef' }, function(){
123-
expect(bsLocal.getBinaryArgs().indexOf('-localIdentifier')).to.not.equal(-1);
154+
expect(bsLocal.getBinaryArgs().indexOf('--local-identifier')).to.not.equal(-1);
124155
expect(bsLocal.getBinaryArgs().indexOf('abcdef')).to.not.equal(-1);
125156
done();
126157
});
@@ -135,20 +166,21 @@ describe('Local', function () {
135166
'proxyUser': 'user',
136167
'proxyPass': 'pass'
137168
}, function(){
138-
expect(bsLocal.getBinaryArgs().indexOf('-proxyHost')).to.not.equal(-1);
169+
expect(bsLocal.getBinaryArgs().indexOf('--proxy-host')).to.not.equal(-1);
139170
expect(bsLocal.getBinaryArgs().indexOf('localhost')).to.not.equal(-1);
140-
expect(bsLocal.getBinaryArgs().indexOf('-proxyPort')).to.not.equal(-1);
171+
expect(bsLocal.getBinaryArgs().indexOf('--proxy-port')).to.not.equal(-1);
141172
expect(bsLocal.getBinaryArgs().indexOf(8080)).to.not.equal(-1);
142-
expect(bsLocal.getBinaryArgs().indexOf('-proxyUser')).to.not.equal(-1);
173+
expect(bsLocal.getBinaryArgs().indexOf('--proxy-user')).to.not.equal(-1);
143174
expect(bsLocal.getBinaryArgs().indexOf('user')).to.not.equal(-1);
144-
expect(bsLocal.getBinaryArgs().indexOf('-proxyPass')).to.not.equal(-1);
175+
expect(bsLocal.getBinaryArgs().indexOf('--proxy-pass')).to.not.equal(-1);
145176
expect(bsLocal.getBinaryArgs().indexOf('pass')).to.not.equal(-1);
146177
done();
147178
});
148179
});
149180

150181
it('should set hosts', function (done) {
151-
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'hosts': 'localhost,8000,0' }, function(){
182+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: 'localhost,8000,0'}, function(){
183+
expect(bsLocal.getBinaryArgs().indexOf('--only')).to.not.equal(-1);
152184
expect(bsLocal.getBinaryArgs().indexOf('localhost,8000,0')).to.not.equal(-1);
153185
done();
154186
});

0 commit comments

Comments
 (0)