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_<UPPERCASE_KEY>
27+ const envVar = process . env [ `BROWSERSTACK_LOCAL_OPTION_${ key . toUpperCase ( ) } ` ] ;
28+ if ( envVar !== undefined ) {
29+ browserstackLocalOptions [ key ] = envVar ;
30+ }
31+ }
32+
133export class Config {
234 constructor (
335 public readonly browserstackUsername : string ,
436 public readonly browserstackAccessKey : string ,
537 public readonly DEV_MODE : boolean ,
38+ public readonly browserstackLocalOptions : Record < string , any > ,
639 ) { }
740}
841
942const config = new Config (
1043 process . env . BROWSERSTACK_USERNAME ! ,
1144 process . env . BROWSERSTACK_ACCESS_KEY ! ,
1245 process . env . DEV_MODE === "true" ,
46+ browserstackLocalOptions ,
1347) ;
1448
1549export default config ;
Original file line number Diff line number Diff line change @@ -83,21 +83,19 @@ export async function ensureLocalBinarySetup(
8383 const localBinary = new Local ( ) ;
8484 await killExistingBrowserStackLocalProcesses ( ) ;
8585
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 || { } ) ,
9189 key : config . browserstackAccessKey ,
9290 username : config . browserstackUsername ,
9391 } ;
9492
9593 if ( localIdentifier ) {
96- requestBody . localIdentifier = localIdentifier ;
94+ bsLocalArgs . localIdentifier = localIdentifier ;
9795 }
9896
9997 return await new Promise ( ( resolve , reject ) => {
100- localBinary . start ( requestBody , ( error ?: Error ) => {
98+ localBinary . start ( bsLocalArgs , ( error ?: Error ) => {
10199 if ( error ) {
102100 logger . error (
103101 `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