Skip to content

Commit 9ed4fc8

Browse files
authored
Merge pull request #24 from Blackbaud-PatrickOFriel/update-tunnel-flags
Update browserstack local with new commands
2 parents b7c2c23 + 9dd6ad2 commit 9ed4fc8

File tree

4 files changed

+126
-54
lines changed

4 files changed

+126
-54
lines changed

README.md

Lines changed: 9 additions & 9 deletions
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
@@ -91,18 +91,18 @@ bs_local_args = { 'key': '<browserstack-accesskey>', 'localIdentifier': 'randoms
9191
## Additional Arguments
9292

9393
#### 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-
```
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+
```
100100

101101
#### Logfile
102102
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.
103103
To specify the path to file where the logs will be saved -
104104
```node
105-
bs_local_args = { 'key': '<browserstack-accesskey>', 'v': 'true', 'logfile': '/browserstack/logs.txt' }
105+
bs_local_args = { 'key': '<browserstack-accesskey>', 'verbose': 'true', 'logFile': '/browserstack/logs.txt' }
106106
```
107107

108108
## Contribute

lib/Local.js

Lines changed: 43 additions & 27 deletions
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,18 +184,20 @@ function Local(){
179184
break;
180185

181186
case 'forceproxy':
187+
case 'forceProxy':
182188
if(value)
183-
this.forceProxyFlag = '-forceproxy';
189+
this.forceProxyFlag = '--force-proxy';
184190
break;
185191

186-
case 'hosts':
192+
case 'logfile':
193+
case 'logFile':
187194
if(value)
188-
this.hosts = value;
195+
this.logfile = value;
189196
break;
190197

191-
case 'logfile':
198+
case 'parallelRuns':
192199
if(value)
193-
this.logfile = value;
200+
this.parallelRunsFlag = value;
194201
break;
195202

196203
case 'binarypath':
@@ -200,9 +207,9 @@ function Local(){
200207

201208
default:
202209
if(value.toString().toLowerCase() == 'true'){
203-
this.userArgs.push('-' + key);
210+
this.userArgs.push('--' + key);
204211
} else {
205-
this.userArgs.push('-' + key);
212+
this.userArgs.push('--' + key);
206213
this.userArgs.push(value);
207214
}
208215
break;
@@ -226,46 +233,55 @@ function Local(){
226233
};
227234

228235
this.getBinaryArgs = function(){
229-
var args = ['-d', this.opcode, '-logFile', this.logfile];
236+
var args = ['--daemon', this.opcode, '--log-file', this.logfile];
230237
if(this.folderFlag)
231238
args.push(this.folderFlag);
232-
args.push(this.key);
239+
if(this.key) {
240+
args.push('--key');
241+
args.push(this.key);
242+
}
233243
if(this.folderPath)
234244
args.push(this.folderPath);
235245
if(this.forceLocalFlag)
236246
args.push(this.forceLocalFlag);
237247
if(this.localIdentifierFlag){
238-
args.push('-localIdentifier');
248+
args.push('--local-identifier');
239249
args.push(this.localIdentifierFlag);
240250
}
241-
if(this.onlyFlag)
242-
args.push(this.onlyFlag);
251+
if(this.parallelRunsFlag){
252+
args.push('--parallel-runs');
253+
args.push(this.parallelRunsFlag.toString());
254+
}
255+
if(this.onlyHosts) {
256+
args.push('--only');
257+
args.push(this.onlyHosts);
258+
}
243259
if(this.onlyAutomateFlag)
244260
args.push(this.onlyAutomateFlag);
245261
if(this.proxyHost){
246-
args.push('-proxyHost');
262+
args.push('--proxy-host');
247263
args.push(this.proxyHost);
248264
}
249265
if(this.proxyPort){
250-
args.push('-proxyPort');
266+
args.push('--proxy-port');
251267
args.push(this.proxyPort);
252268
}
253269
if(this.proxyUser){
254-
args.push('-proxyUser');
270+
args.push('--proxy-user');
255271
args.push(this.proxyUser);
256272
}
257273
if(this.proxyPass){
258-
args.push('-proxyPass');
274+
args.push('--proxy-pass');
259275
args.push(this.proxyPass);
260276
}
261277
if(this.forceProxyFlag)
262278
args.push(this.forceProxyFlag);
263279
if(this.forceFlag)
264280
args.push(this.forceFlag);
265-
if(this.verboseFlag)
266-
args.push(this.verboseFlag);
267-
if(this.hosts)
268-
args.push(this.hosts);
281+
if(this.verboseFlag){
282+
args.push('--verbose');
283+
args.push(this.verboseFlag.toString());
284+
}
269285
for(var i in this.userArgs){
270286
args.push(this.userArgs[i]);
271287
}

node-example.js

Lines changed: 1 addition & 1 deletion
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

Lines changed: 73 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,25 @@ 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);
64+
done();
65+
});
66+
});
67+
68+
it('should enable verbose with log level string', function (done) {
69+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'verbose': '2' }, function(){
70+
expect(bsLocal.getBinaryArgs().indexOf('--verbose')).to.not.equal(-1);
71+
expect(bsLocal.getBinaryArgs().indexOf('2')).to.not.equal(-1);
5572
done();
5673
});
5774
});
@@ -64,68 +81,106 @@ describe('Local', function () {
6481
});
6582
});
6683

84+
it('should set folder testing with folder option', function (done) {
85+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'folder': '/var/html' }, function(){
86+
expect(bsLocal.getBinaryArgs().indexOf('-f')).to.not.equal(-1);
87+
expect(bsLocal.getBinaryArgs().indexOf('/var/html')).to.not.equal(-1);
88+
done();
89+
});
90+
});
91+
6792
it('should enable force', function (done) {
6893
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'force': true }, function(){
69-
expect(bsLocal.getBinaryArgs().indexOf('-force')).to.not.equal(-1);
94+
expect(bsLocal.getBinaryArgs().indexOf('--force')).to.not.equal(-1);
7095
done();
7196
});
7297
});
7398

7499
it('should enable only', function (done) {
75100
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'only': true }, function(){
76-
expect(bsLocal.getBinaryArgs().indexOf('-only')).to.not.equal(-1);
101+
expect(bsLocal.getBinaryArgs().indexOf('--only')).to.not.equal(-1);
77102
done();
78103
});
79104
});
80105

81106
it('should enable onlyAutomate', function (done) {
82107
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'onlyAutomate': true }, function(){
83-
expect(bsLocal.getBinaryArgs().indexOf('-onlyAutomate')).to.not.equal(-1);
108+
expect(bsLocal.getBinaryArgs().indexOf('--only-automate')).to.not.equal(-1);
84109
done();
85110
});
86111
});
87112

88113
it('should enable forcelocal', function (done) {
89114
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'forcelocal': true }, function(){
90-
expect(bsLocal.getBinaryArgs().indexOf('-forcelocal')).to.not.equal(-1);
115+
expect(bsLocal.getBinaryArgs().indexOf('--force-local')).to.not.equal(-1);
116+
done();
117+
});
118+
});
119+
120+
it('should enable forcelocal with camel case', function (done) {
121+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'forceLocal': true }, function(){
122+
expect(bsLocal.getBinaryArgs().indexOf('--force-local')).to.not.equal(-1);
91123
done();
92124
});
93125
});
94126

95127
it('should enable custom boolean args', function (done) {
96128
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);
129+
expect(bsLocal.getBinaryArgs().indexOf('--boolArg1')).to.not.equal(-1);
130+
expect(bsLocal.getBinaryArgs().indexOf('--boolArg2')).to.not.equal(-1);
99131
done();
100132
});
101133
});
102134

103135
it('should enable custom keyval args', function (done) {
104136
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);
137+
expect(bsLocal.getBinaryArgs().indexOf('--customKey1')).to.not.equal(-1);
106138
expect(bsLocal.getBinaryArgs().indexOf('custom value1')).to.not.equal(-1);
107-
expect(bsLocal.getBinaryArgs().indexOf('-customKey2')).to.not.equal(-1);
139+
expect(bsLocal.getBinaryArgs().indexOf('--customKey2')).to.not.equal(-1);
108140
expect(bsLocal.getBinaryArgs().indexOf('custom value2')).to.not.equal(-1);
109141
done();
110142
});
111143
});
112144

113145
it('should enable forceproxy', function (done) {
114146
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'forceproxy': true }, function(){
115-
expect(bsLocal.getBinaryArgs().indexOf('-forceproxy')).to.not.equal(-1);
147+
expect(bsLocal.getBinaryArgs().indexOf('--force-proxy')).to.not.equal(-1);
148+
done();
149+
});
150+
});
151+
152+
it('should enable forceproxy with camel case', function (done) {
153+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'forceProxy': true }, function(){
154+
expect(bsLocal.getBinaryArgs().indexOf('--force-proxy')).to.not.equal(-1);
116155
done();
117156
});
118157
});
119158

120159

121160
it('should set localIdentifier', function (done) {
122161
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'localIdentifier': 'abcdef' }, function(){
123-
expect(bsLocal.getBinaryArgs().indexOf('-localIdentifier')).to.not.equal(-1);
162+
expect(bsLocal.getBinaryArgs().indexOf('--local-identifier')).to.not.equal(-1);
124163
expect(bsLocal.getBinaryArgs().indexOf('abcdef')).to.not.equal(-1);
125164
done();
126165
});
127166
});
128167

168+
it('should set parallelRuns', function (done) {
169+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'parallelRuns': '10' }, function(){
170+
expect(bsLocal.getBinaryArgs().indexOf('--parallel-runs')).to.not.equal(-1);
171+
expect(bsLocal.getBinaryArgs().indexOf('10')).to.not.equal(-1);
172+
done();
173+
});
174+
});
175+
176+
it('should set parallelRuns with integer value', function (done) {
177+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'parallelRuns': 10 }, function(){
178+
expect(bsLocal.getBinaryArgs().indexOf('--parallel-runs')).to.not.equal(-1);
179+
expect(bsLocal.getBinaryArgs().indexOf('10')).to.not.equal(-1);
180+
done();
181+
});
182+
});
183+
129184
it('should set proxy', function (done) {
130185
bsLocal.start({
131186
'key': process.env.BROWSERSTACK_ACCESS_KEY,
@@ -135,20 +190,21 @@ describe('Local', function () {
135190
'proxyUser': 'user',
136191
'proxyPass': 'pass'
137192
}, function(){
138-
expect(bsLocal.getBinaryArgs().indexOf('-proxyHost')).to.not.equal(-1);
193+
expect(bsLocal.getBinaryArgs().indexOf('--proxy-host')).to.not.equal(-1);
139194
expect(bsLocal.getBinaryArgs().indexOf('localhost')).to.not.equal(-1);
140-
expect(bsLocal.getBinaryArgs().indexOf('-proxyPort')).to.not.equal(-1);
195+
expect(bsLocal.getBinaryArgs().indexOf('--proxy-port')).to.not.equal(-1);
141196
expect(bsLocal.getBinaryArgs().indexOf(8080)).to.not.equal(-1);
142-
expect(bsLocal.getBinaryArgs().indexOf('-proxyUser')).to.not.equal(-1);
197+
expect(bsLocal.getBinaryArgs().indexOf('--proxy-user')).to.not.equal(-1);
143198
expect(bsLocal.getBinaryArgs().indexOf('user')).to.not.equal(-1);
144-
expect(bsLocal.getBinaryArgs().indexOf('-proxyPass')).to.not.equal(-1);
199+
expect(bsLocal.getBinaryArgs().indexOf('--proxy-pass')).to.not.equal(-1);
145200
expect(bsLocal.getBinaryArgs().indexOf('pass')).to.not.equal(-1);
146201
done();
147202
});
148203
});
149204

150205
it('should set hosts', function (done) {
151-
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'hosts': 'localhost,8000,0' }, function(){
206+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, onlyCommand: true, 'only': 'localhost,8000,0'}, function(){
207+
expect(bsLocal.getBinaryArgs().indexOf('--only')).to.not.equal(-1);
152208
expect(bsLocal.getBinaryArgs().indexOf('localhost,8000,0')).to.not.equal(-1);
153209
done();
154210
});

0 commit comments

Comments
 (0)