11import { bootstrap } from 'global-agent'
2+ import { isW3C } from "./utils" ;
23
3- export function processConfig ( config : any = { } , args : any = { } ) {
4+ export function processConfig ( config : any = { } , args : any = { } ) {
45 const username = config . username || process . env . SAUCE_USERNAME ;
56 const accessKey = config . accessKey || process . env . SAUCE_ACCESS_KEY ;
67 const startConnect = config . startConnect !== false ;
78
89 let tunnelIdentifier = args . tunnelIdentifier || config . tunnelIdentifier ;
910
10- // TODO: This option is very ambiguous because it technically only affects the reporter. Consider
11+ // TODO: This option is very ambiguous because it technically only affects the reporter. Consider
1112 // renaming in the future.
1213 const sauceApiProxy = args . proxy || config . proxy ;
1314 if ( sauceApiProxy ) {
@@ -20,9 +21,7 @@ export function processConfig (config: any = {}, args: any = {}) {
2021 }
2122
2223 // Browser name that will be printed out by Karma.
23- const browserName = args . browserName +
24- ( args . version ? ' ' + args . version : '' ) +
25- ( args . platform ? ' (' + args . platform + ')' : '' ) ;
24+ const browserName = `${ args . browserName } ${ args . browserVersion || args . version || '' } ${ args . platformName || args . platform || '' } ` ;
2625
2726 // In case "startConnect" is enabled, and no tunnel identifier has been specified, we just
2827 // generate one randomly. This makes it possible for developers to use "startConnect" with
@@ -53,20 +52,27 @@ export function processConfig (config: any = {}, args: any = {}) {
5352 } ;
5453
5554 // transform JWP capabilities into W3C capabilities for backward compatibility
56- args . browserVersion = args . browserVersion || args . version || 'latest'
57- args . platformName = args . platformName || args . platform || 'Windows 10'
58- // delete JWP capabilities
55+ if ( isW3C ( args ) ) {
56+ args . browserVersion = args . browserVersion || args . version || 'latest'
57+ args . platformName = args . platformName || args . platform || 'Windows 10'
58+ args [ 'sauce:options' ] = { ...( args [ 'sauce:options' ] || { } ) , ...capabilitiesFromConfig }
59+
60+ // delete JWP capabilities
61+ delete args . version
62+ delete args . platform
63+ } else {
64+ args = { ...args , ...capabilitiesFromConfig }
65+ }
66+ // Not needed
5967 delete args . base
60- delete args . version
61- delete args . platform
68+
6269 const seleniumCapabilities = {
6370 user : username ,
6471 key : accessKey ,
6572 region : config . region ,
6673 headless : config . headless ,
6774 logLevel : 'error' ,
6875 capabilities : {
69- 'sauce:options' : capabilitiesFromConfig ,
7076 ...args
7177 } ,
7278 ...config . options
0 commit comments