File tree Expand file tree Collapse file tree 2 files changed +39
-7
lines changed Expand file tree Collapse file tree 2 files changed +39
-7
lines changed Original file line number Diff line number Diff line change
1
+ // List of supported BrowserStack Local option names (as per SDK)
2
+ const BROWSERSTACK_LOCAL_OPTION_KEYS = [
3
+ "proxyHost" ,
4
+ "proxyPort" ,
5
+ "proxyUser" ,
6
+ "proxyPass" ,
7
+ "useCaCertificate" ,
8
+ "localProxyHost" ,
9
+ "localProxyPort" ,
10
+ "localProxyUser" ,
11
+ "localProxyPass" ,
12
+ "pacFile" ,
13
+ "force" ,
14
+ "forceLocal" ,
15
+ "onlyAutomate" ,
16
+ "verbose" ,
17
+ "logFile" ,
18
+ "binarypath" ,
19
+ "f" ,
20
+ "excludeHosts" ,
21
+ ] ;
22
+
23
+ // Build browserstackLocalOptions from individual env vars
24
+ const browserstackLocalOptions : Record < string , any > = { } ;
25
+ for ( const key of BROWSERSTACK_LOCAL_OPTION_KEYS ) {
26
+ // Env var name: BROWSERSTACK_LOCAL_OPTION_
27
+ const envVar = process . env [ `BROWSERSTACK_LOCAL_OPTION_${ key . toUpperCase ( ) } ` ] ;
28
+ if ( envVar !== undefined ) {
29
+ browserstackLocalOptions [ key ] = envVar ;
30
+ }
31
+ }
32
+
1
33
export class Config {
2
34
constructor (
3
35
public readonly browserstackUsername : string ,
4
36
public readonly browserstackAccessKey : string ,
5
37
public readonly DEV_MODE : boolean ,
38
+ public readonly browserstackLocalOptions : Record < string , any > ,
6
39
) { }
7
40
}
8
41
9
42
const config = new Config (
10
43
process . env . BROWSERSTACK_USERNAME ! ,
11
44
process . env . BROWSERSTACK_ACCESS_KEY ! ,
12
45
process . env . DEV_MODE === "true" ,
46
+ browserstackLocalOptions ,
13
47
) ;
14
48
15
49
export default config ;
Original file line number Diff line number Diff line change @@ -83,21 +83,19 @@ export async function ensureLocalBinarySetup(
83
83
const localBinary = new Local ( ) ;
84
84
await killExistingBrowserStackLocalProcesses ( ) ;
85
85
86
- const requestBody : {
87
- key : string ;
88
- username : string ;
89
- localIdentifier ?: string ;
90
- } = {
86
+ // Use a single options object from config and extend with required fields
87
+ const bsLocalArgs : Record < string , any > = {
88
+ ...( config . browserstackLocalOptions || { } ) ,
91
89
key : config . browserstackAccessKey ,
92
90
username : config . browserstackUsername ,
93
91
} ;
94
92
95
93
if ( localIdentifier ) {
96
- requestBody . localIdentifier = localIdentifier ;
94
+ bsLocalArgs . localIdentifier = localIdentifier ;
97
95
}
98
96
99
97
return await new Promise ( ( resolve , reject ) => {
100
- localBinary . start ( requestBody , ( error ?: Error ) => {
98
+ localBinary . start ( bsLocalArgs , ( error ?: Error ) => {
101
99
if ( error ) {
102
100
logger . error (
103
101
`Unable to start BrowserStack Local... please check your credentials and try again. Error: ${ error } ` ,
You can’t perform that action at this time.
0 commit comments