Skip to content

Commit 97315f3

Browse files
committed
fix: fixes issues with older browsers / caps
1 parent 53b1218 commit 97315f3

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/process-config.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import {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'] ? {...args['sauce:options'], ...capabilitiesFromConfig} : 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

src/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ export async function waitUntil({condition, retries = 0, maxRetries = 50, interv
1111

1212
return waitUntil({condition, retries: retries++, maxRetries, interval})
1313
}
14+
15+
export function isW3C(capabilities){
16+
// Only browserVersion is mandatory, platformName is optional
17+
return Boolean(capabilities.browserVersion)
18+
}

0 commit comments

Comments
 (0)