@wdio/sauce-service 7.16.8 → 7.16.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,9 +12,8 @@ export default class SauceService implements Services.ServiceInstance {
12
12
  private _isJobNameSet;
13
13
  private _options;
14
14
  private _api;
15
- private _isLegacyRDC;
16
15
  private _browser?;
17
- private _isUP?;
16
+ private _isRDC?;
18
17
  private _suiteTitle?;
19
18
  private _cid;
20
19
  constructor(options: SauceServiceConfig, _capabilities: Capabilities.RemoteCapability, _config: Options.Testrunner);
@@ -23,8 +22,8 @@ export default class SauceService implements Services.ServiceInstance {
23
22
  */
24
23
  beforeSession(_: never, __: never, ___: never, cid: string): void;
25
24
  before(caps: unknown, specs: string[], browser: Browser<'async'> | MultiRemoteBrowser<'async'>): void;
26
- beforeSuite(suite: Frameworks.Suite): void;
27
- beforeTest(test: Frameworks.Test): void;
25
+ beforeSuite(suite: Frameworks.Suite): Promise<void>;
26
+ beforeTest(test: Frameworks.Test): Promise<unknown>;
28
27
  afterSuite(suite: Frameworks.Suite): void;
29
28
  private _reportErrorLog;
30
29
  afterTest(test: Frameworks.Test, context: unknown, results: Frameworks.TestResult): void;
@@ -34,8 +33,9 @@ export default class SauceService implements Services.ServiceInstance {
34
33
  */
35
34
  beforeFeature(uri: unknown, feature: {
36
35
  name: string;
37
- }): void;
38
- beforeScenario(world: Frameworks.World): void;
36
+ }): Promise<unknown>;
37
+ beforeScenario(world: Frameworks.World): Promise<unknown> | undefined;
38
+ beforeStep(step: Frameworks.PickleStep): Promise<unknown>;
39
39
  /**
40
40
  *
41
41
  * Runs before a Cucumber Scenario.
@@ -63,10 +63,8 @@ export default class SauceService implements Services.ServiceInstance {
63
63
  */
64
64
  getBody(failures: number, calledOnReload?: boolean, browserName?: string): Partial<Job>;
65
65
  /**
66
- * Update the UP with the JS-executor
67
- * @param {number} failures
68
- * @returns {*}
66
+ * Update the running Sauce Labs Job with an annotation
69
67
  */
70
- updateUP(failures: number): Promise<unknown> | undefined;
68
+ setAnnotation(annotation: string): Promise<unknown>;
71
69
  }
72
70
  //# sourceMappingURL=service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAGA,OAAkB,EAAoB,GAAG,EAAE,MAAM,WAAW,CAAA;AAE5D,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAG9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAO5C,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,QAAQ,CAAC,eAAe;IAiB7D,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,OAAO;IAjBnB,OAAO,CAAC,QAAQ,CAAI;IACpB,OAAO,CAAC,oBAAoB,CAAI;IAChC,OAAO,CAAC,SAAS,CAAI;IACrB,OAAO,CAAC,iBAAiB,CAAO;IAChC,OAAO,CAAC,aAAa,CAAQ;IAE7B,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,IAAI,CAAW;IACvB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,CAAgD;IACjE,OAAO,CAAC,KAAK,CAAC,CAAS;IACvB,OAAO,CAAC,WAAW,CAAC,CAAQ;IAC5B,OAAO,CAAC,IAAI,CAAK;gBAGb,OAAO,EAAE,kBAAkB,EACnB,aAAa,EAAE,YAAY,CAAC,gBAAgB,EAC5C,OAAO,EAAE,OAAO,CAAC,UAAU;IAQvC;;OAEG;IACH,aAAa,CAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM;IAkB3D,MAAM,CAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EA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KAAK;IAMnC,OAAO,CAAC,eAAe;IAKvB,SAAS,CAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,UAAU;IAyClF,SAAS,CAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,UAAU;IAetE;;OAEG;IACG,aAAa,CAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAuB5D,cAAc,CAAE,KAAK,EAAE,UAAU,CAAC,KAAK;IAajC,UAAU,CAAE,IAAI,EAAE,UAAU,CAAC,UAAU;IAK7C;;;;;;;;OAQG;IACH,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,YAAY;IAOtE;;OAEG;IACG,KAAK,CAAE,MAAM,EAAE,MAAM;IAsC3B;;;;OAIG;YACW,WAAW;IAezB,QAAQ,CAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAmB9C,SAAS,CAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,UAAQ,EAAE,WAAW,CAAC,EAAE,MAAM;IAMlG;;OAEG;IACH,OAAO,CAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,UAAQ,EAAE,WAAW,CAAC,EAAE,MAAM;IAgDvE;;OAEG;IACG,aAAa,CAAE,UAAU,EAAE,MAAM;CAkB1C"}
package/build/service.js CHANGED
@@ -23,7 +23,6 @@ class SauceService {
23
23
  this._cid = '';
24
24
  this._options = { ...constants_1.DEFAULT_OPTIONS, ...options };
25
25
  this._api = new saucelabs_1.default(this._config);
26
- this._isLegacyRDC = 'testobject_api_key' in this._capabilities;
27
26
  this._maxErrorStackLength = this._options.maxErrorStackLength || this._maxErrorStackLength;
28
27
  }
29
28
  /**
@@ -34,13 +33,13 @@ class SauceService {
34
33
  /**
35
34
  * if no user and key is specified even though a sauce service was
36
35
  * provided set user and key with values so that the session request
37
- * will fail (not for RDC tho due to other auth mechansim)
36
+ * will fail
38
37
  */
39
- if (!this._isLegacyRDC && !this._config.user) {
38
+ if (!this._config.user) {
40
39
  this._isServiceEnabled = false;
41
40
  this._config.user = 'unknown_user';
42
41
  }
43
- if (!this._isLegacyRDC && !this._config.key) {
42
+ if (!this._config.key) {
44
43
  this._isServiceEnabled = false;
45
44
  this._config.key = 'unknown_key';
46
45
  }
@@ -54,20 +53,23 @@ class SauceService {
54
53
  // `this._browser.capabilities` returns the process data from Sauce which is without
55
54
  // the postfix
56
55
  const capabilities = this._browser.requestedCapabilities || {};
57
- this._isUP = (0, utils_1.isUnifiedPlatform)(capabilities);
56
+ this._isRDC = (0, utils_1.isRDC)(capabilities);
58
57
  }
59
- beforeSuite(suite) {
58
+ async beforeSuite(suite) {
60
59
  this._suiteTitle = suite.title;
61
60
  /**
62
61
  * Make sure we account for the cases where there is a long running `before` function for a
63
62
  * suite or one that can fail so we set the default job name at the suite level
63
+ * Don't do this for Jasmine because the `suiteTitle` is `Jasmine__TopLevel__Suite` and the
64
+ * `fullName` is `null`, so no alternative
64
65
  **/
65
- if (this._browser && !this._isUP && !this._isJobNameSet) {
66
- this._browser.execute('sauce:job-name=' + this._suiteTitle);
66
+ if (this._browser && !this._isRDC && !this._isJobNameSet && this._suiteTitle !== 'Jasmine__TopLevel__Suite') {
67
+ await this.setAnnotation('sauce:job-name=' + this._suiteTitle);
68
+ this._isJobNameSet = true;
67
69
  }
68
70
  }
69
- beforeTest(test) {
70
- if (!this._isServiceEnabled || this._isLegacyRDC || !this._browser) {
71
+ async beforeTest(test) {
72
+ if (!this._isServiceEnabled || !this._browser) {
71
73
  return;
72
74
  }
73
75
  /**
@@ -80,17 +82,22 @@ class SauceService {
80
82
  this._suiteTitle = test.fullName.slice(0, test.fullName.indexOf(test.description || '') - 1);
81
83
  }
82
84
  if (this._browser && !this._isJobNameSet) {
85
+ let jobName = this._suiteTitle;
83
86
  if (this._options.setJobName) {
84
- let jobName = this._options.setJobName(this._config, this._capabilities, this._suiteTitle);
85
- this._browser.execute(`sauce:job-name=${jobName}`);
87
+ jobName = this._options.setJobName(this._config, this._capabilities, this._suiteTitle);
88
+ await this.setAnnotation(`sauce:job-name=${jobName}`);
89
+ this._isJobNameSet = true;
90
+ }
91
+ if (!this._isJobNameSet) {
92
+ await this.setAnnotation(`sauce:job-name=${jobName}`);
93
+ this._isJobNameSet = true;
86
94
  }
87
- this._isJobNameSet = true;
88
95
  }
89
96
  /**
90
97
  * Date: 20200714
91
98
  * Remark: Sauce Unified Platform doesn't support updating the context yet.
92
99
  */
93
- if (this._isUP) {
100
+ if (this._isRDC) {
94
101
  return;
95
102
  }
96
103
  const fullTitle = (
@@ -102,7 +109,7 @@ class SauceService {
102
109
  * Mocha
103
110
  */
104
111
  `${test.parent} - ${test.title}`);
105
- this._browser.execute('sauce:context=' + fullTitle);
112
+ return this.setAnnotation(`sauce:context=${fullTitle}`);
106
113
  }
107
114
  afterSuite(suite) {
108
115
  if (Object.prototype.hasOwnProperty.call(suite, 'error')) {
@@ -111,7 +118,7 @@ class SauceService {
111
118
  }
112
119
  _reportErrorLog(error) {
113
120
  const lines = (error.stack || '').split(/\r?\n/).slice(0, this._maxErrorStackLength);
114
- lines.forEach((line) => this._browser.execute(`sauce:context=${line.replace((0, utils_1.ansiRegex)(), '')}`));
121
+ lines.forEach((line) => this.setAnnotation(`sauce:context=${line.replace((0, utils_1.ansiRegex)(), '')}`));
115
122
  }
116
123
  afterTest(test, context, results) {
117
124
  /**
@@ -119,7 +126,7 @@ class SauceService {
119
126
  * This should not be done for UP because it's not supported yet and
120
127
  * should be removed when UP supports `sauce:context`
121
128
  */
122
- if (results.error && results.error.stack && !this._isUP) {
129
+ if (results.error && results.error.stack && !this._isRDC) {
123
130
  this._reportErrorLog(results.error);
124
131
  }
125
132
  /**
@@ -152,7 +159,7 @@ class SauceService {
152
159
  * This should not be done for UP because it's not supported yet and
153
160
  * should be removed when UP supports `sauce:context`
154
161
  */
155
- if (results.error && !this._isUP) {
162
+ if (results.error && !this._isRDC) {
156
163
  this._reportErrorLog(results.error);
157
164
  }
158
165
  if (!results.passed) {
@@ -162,34 +169,38 @@ class SauceService {
162
169
  /**
163
170
  * For CucumberJS
164
171
  */
165
- beforeFeature(uri, feature) {
166
- if (!this._isServiceEnabled || this._isLegacyRDC || !this._browser) {
172
+ async beforeFeature(uri, feature) {
173
+ if (!this._isServiceEnabled || !this._browser) {
167
174
  return;
168
175
  }
169
176
  this._suiteTitle = feature.name;
170
177
  if (this._browser && !this._isJobNameSet) {
171
- this._browser.execute('sauce:job-name=' + this._suiteTitle);
178
+ await this.setAnnotation(`sauce:job-name=${this._suiteTitle}`);
172
179
  this._isJobNameSet = true;
173
180
  }
174
181
  /**
175
182
  * Date: 20200714
176
183
  * Remark: Sauce Unified Platform doesn't support updating the context yet.
177
184
  */
178
- if (this._isUP) {
185
+ if (this._isRDC) {
179
186
  return;
180
187
  }
181
- this._browser.execute('sauce:context=Feature: ' + this._suiteTitle);
188
+ return this.setAnnotation(`sauce:context=Feature: ${this._suiteTitle}`);
182
189
  }
183
190
  beforeScenario(world) {
184
191
  /**
185
192
  * Date: 20200714
186
193
  * Remark: Sauce Unified Platform doesn't support updating the context yet.
187
194
  */
188
- if (!this._isServiceEnabled || this._isLegacyRDC || this._isUP || !this._browser) {
195
+ if (!this._isServiceEnabled || this._isRDC || !this._browser) {
189
196
  return;
190
197
  }
191
198
  const scenarioName = world.pickle.name || 'unknown scenario';
192
- this._browser.execute('sauce:context=Scenario: ' + scenarioName);
199
+ return this.setAnnotation(`sauce:context=-Scenario: ${scenarioName}`);
200
+ }
201
+ async beforeStep(step) {
202
+ const { keyword, text } = step;
203
+ return this.setAnnotation(`sauce:context=--Step: ${keyword}${text}`);
193
204
  }
194
205
  /**
195
206
  *
@@ -210,7 +221,7 @@ class SauceService {
210
221
  * update Sauce Labs job
211
222
  */
212
223
  async after(result) {
213
- if (!this._browser || (!this._isServiceEnabled && !this._isLegacyRDC)) {
224
+ if (!this._browser || !this._isServiceEnabled) {
214
225
  return;
215
226
  }
216
227
  let failures = this._failures;
@@ -225,13 +236,21 @@ class SauceService {
225
236
  if (!this._browser.isMultiremote) {
226
237
  await this._uploadLogs(this._browser.sessionId);
227
238
  log.info(`Update job with sessionId ${this._browser.sessionId}, ${status}`);
228
- return this._isUP ? this.updateUP(failures) : this.updateJob(this._browser.sessionId, failures);
239
+ return this._isRDC ?
240
+ this.setAnnotation(`sauce:job-result=${failures === 0}`) :
241
+ this.updateJob(this._browser.sessionId, failures);
229
242
  }
230
- const mulitremoteBrowser = this._browser;
243
+ const multiRemoteBrowser = this._browser;
231
244
  return Promise.all(Object.keys(this._capabilities).map(async (browserName) => {
232
- await this._uploadLogs(mulitremoteBrowser[browserName].sessionId);
233
- log.info(`Update multiremote job for browser "${browserName}" and sessionId ${mulitremoteBrowser[browserName].sessionId}, ${status}`);
234
- return this._isUP ? this.updateUP(failures) : this.updateJob(mulitremoteBrowser[browserName].sessionId, failures, false, browserName);
245
+ const isMultiRemoteRDC = (0, utils_1.isRDC)(multiRemoteBrowser[browserName].capabilities);
246
+ log.info(`Update multiRemote job for browser "${browserName}" and sessionId ${multiRemoteBrowser[browserName].sessionId}, ${status}`);
247
+ // Sauce Unified Platform (RDC) can not be updated with an API.
248
+ // The logs can also not be uploaded
249
+ if (isMultiRemoteRDC) {
250
+ return this.setAnnotation(`sauce:job-result=${failures === 0}`);
251
+ }
252
+ await this._uploadLogs(multiRemoteBrowser[browserName].sessionId);
253
+ return this.updateJob(multiRemoteBrowser[browserName].sessionId, failures, false, browserName);
235
254
  }));
236
255
  }
237
256
  /**
@@ -249,7 +268,7 @@ class SauceService {
249
268
  return this._api.uploadJobAssets(jobId, { files: files.map((file) => path_1.default.join(this._config.outputDir, file)) }).catch((err) => log.error(`Couldn't upload log files to Sauce Labs: ${err.message}`));
250
269
  }
251
270
  onReload(oldSessionId, newSessionId) {
252
- if (!this._browser || (!this._isServiceEnabled && !this._isLegacyRDC)) {
271
+ if (!this._browser || !this._isServiceEnabled) {
253
272
  return;
254
273
  }
255
274
  const status = 'status: ' + (this._failures > 0 ? 'failing' : 'passing');
@@ -263,11 +282,6 @@ class SauceService {
263
282
  return this.updateJob(oldSessionId, this._failures, true, browserName);
264
283
  }
265
284
  async updateJob(sessionId, failures, calledOnReload = false, browserName) {
266
- if (this._isLegacyRDC) {
267
- await this._api.updateTest(sessionId, { passed: failures === 0 });
268
- this._failures = 0;
269
- return;
270
- }
271
285
  const body = this.getBody(failures, calledOnReload, browserName);
272
286
  await this._api.updateJob(this._config.user, sessionId, body);
273
287
  this._failures = 0;
@@ -309,15 +323,22 @@ class SauceService {
309
323
  return body;
310
324
  }
311
325
  /**
312
- * Update the UP with the JS-executor
313
- * @param {number} failures
314
- * @returns {*}
326
+ * Update the running Sauce Labs Job with an annotation
315
327
  */
316
- updateUP(failures) {
328
+ async setAnnotation(annotation) {
317
329
  if (!this._browser) {
318
330
  return;
319
331
  }
320
- return this._browser.execute(`sauce:job-result=${failures === 0}`);
332
+ if (this._browser.isMultiremote) {
333
+ const multiRemoteBrowser = this._browser;
334
+ return Promise.all(Object.keys(this._capabilities).map(async (browserName) => {
335
+ const isMultiRemoteRDC = (0, utils_1.isRDC)(multiRemoteBrowser[browserName].capabilities);
336
+ if ((isMultiRemoteRDC && !annotation.includes('sauce:context')) || !isMultiRemoteRDC) {
337
+ return this._browser.execute(annotation);
338
+ }
339
+ }));
340
+ }
341
+ return this._browser.execute(annotation);
321
342
  }
322
343
  }
323
344
  exports.default = SauceService;
package/build/utils.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { Capabilities } from '@wdio/types';
2
2
  /**
3
- * Determine if the current instance is a Unified Platform instance. UP tests are Real Device tests
3
+ * Determine if the current instance is a RDC instance. RDC tests are Real Device tests
4
4
  * that can be started with different sets of capabilities. A deviceName is not mandatory, the only mandatory cap for
5
- * UP is the platformName. Downside of the platformName is that is can also be EMUSIM. EMUSIM can be distinguished by
5
+ * RDC is the platformName. Downside of the platformName is that is can also be EMUSIM. EMUSIM can be distinguished by
6
6
  * the `Emulator|Simulator` postfix
7
7
  *
8
8
  * @param {object} caps
@@ -41,7 +41,7 @@ import type { Capabilities } from '@wdio/types';
41
41
  * deviceContextId: ''
42
42
  * }
43
43
  */
44
- export declare function isUnifiedPlatform(caps: Capabilities.DesiredCapabilities): boolean;
44
+ export declare function isRDC(caps: Capabilities.DesiredCapabilities): boolean;
45
45
  /**
46
46
  * Determine if this is an EMUSIM session
47
47
  * @param {object} caps
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,iBAAiB,CAAE,IAAI,EAAE,YAAY,CAAC,mBAAmB,WAMxE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAE,IAAI,EAAE,YAAY,CAAC,mBAAmB,WAM/D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,gBACpD,aAAa,mBAAmB,UA2BvD;AAED,wBAAgB,SAAS,WAOxB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,KAAK,CAAE,IAAI,EAAE,YAAY,CAAC,mBAAmB,WAM5D;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAE,IAAI,EAAE,YAAY,CAAC,mBAAmB,WAM/D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,gBACpD,aAAa,mBAAmB,UA2BvD;AAED,wBAAgB,SAAS,WAOxB"}
package/build/utils.js CHANGED
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ansiRegex = exports.makeCapabilityFactory = exports.isEmuSim = exports.isUnifiedPlatform = void 0;
4
- const utils_1 = require("@wdio/utils");
3
+ exports.ansiRegex = exports.makeCapabilityFactory = exports.isEmuSim = exports.isRDC = void 0;
5
4
  /**
6
- * Determine if the current instance is a Unified Platform instance. UP tests are Real Device tests
5
+ * Determine if the current instance is a RDC instance. RDC tests are Real Device tests
7
6
  * that can be started with different sets of capabilities. A deviceName is not mandatory, the only mandatory cap for
8
- * UP is the platformName. Downside of the platformName is that is can also be EMUSIM. EMUSIM can be distinguished by
7
+ * RDC is the platformName. Downside of the platformName is that is can also be EMUSIM. EMUSIM can be distinguished by
9
8
  * the `Emulator|Simulator` postfix
10
9
  *
11
10
  * @param {object} caps
@@ -44,13 +43,13 @@ const utils_1 = require("@wdio/utils");
44
43
  * deviceContextId: ''
45
44
  * }
46
45
  */
47
- function isUnifiedPlatform(caps) {
46
+ function isRDC(caps) {
48
47
  const { 'appium:deviceName': appiumDeviceName = '', deviceName = '', platformName = '' } = caps;
49
48
  const name = appiumDeviceName || deviceName;
50
49
  // If the string contains `simulator` or `emulator` it's an EMU/SIM session
51
50
  return !name.match(/(simulator)|(emulator)/gi) && !!platformName.match(/(ios)|(android)/gi);
52
51
  }
53
- exports.isUnifiedPlatform = isUnifiedPlatform;
52
+ exports.isRDC = isRDC;
54
53
  /**
55
54
  * Determine if this is an EMUSIM session
56
55
  * @param {object} caps
@@ -70,21 +69,21 @@ exports.isEmuSim = isEmuSim;
70
69
  */
71
70
  function makeCapabilityFactory(tunnelIdentifier, options) {
72
71
  return (capability) => {
73
- // If the capability appears to be using the legacy JSON Wire Protocol
74
- // we need to make sure the key 'sauce:options' is not present
75
- const isLegacy = Boolean((capability.platform || capability.version) &&
76
- !(0, utils_1.isW3C)(capability) &&
77
- !capability['sauce:options']);
78
- // Unified Platform and EMUSIM is currently not W3C ready, so the tunnel needs to be on the cap level
79
- if (!capability['sauce:options'] && !isLegacy && !isUnifiedPlatform(capability) && !isEmuSim(capability)) {
72
+ // Check if this is a 'valid' W3C request, this is done with a simple check
73
+ // where we assume that if only one cap has `:` it's W3C, even if the request
74
+ // is a mix of JWP and W3C. This is hard to check
75
+ const isW3CRequest = Boolean(Object.keys(capability).find((cap) => cap.includes(':')));
76
+ // If the `sauce:options` are not provided and it is a W3C session
77
+ // then add it
78
+ if (!capability['sauce:options'] && isW3CRequest) {
80
79
  capability['sauce:options'] = {};
81
80
  }
82
81
  Object.assign(capability, options);
83
- const sauceOptions = (!isLegacy && !isUnifiedPlatform(capability) && !isEmuSim(capability) ? capability['sauce:options'] : capability);
82
+ const sauceOptions = (isW3CRequest ? capability['sauce:options'] : capability);
84
83
  sauceOptions.tunnelIdentifier = (capability.tunnelIdentifier ||
85
84
  sauceOptions.tunnelIdentifier ||
86
85
  tunnelIdentifier);
87
- if (!isLegacy && !isUnifiedPlatform(capability) && !isEmuSim(capability)) {
86
+ if (isW3CRequest) {
88
87
  delete capability.tunnelIdentifier;
89
88
  }
90
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/sauce-service",
3
- "version": "7.16.8",
3
+ "version": "7.16.12",
4
4
  "description": "WebdriverIO service that provides a better integration into Sauce Labs",
5
5
  "author": "Christian Bromann <christian@saucelabs.com>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-sauce-service",
@@ -25,10 +25,10 @@
25
25
  "dependencies": {
26
26
  "@types/node": "^16.11.1",
27
27
  "@wdio/logger": "7.16.0",
28
- "@wdio/types": "7.16.3",
29
- "@wdio/utils": "7.16.3",
28
+ "@wdio/types": "7.16.11",
29
+ "@wdio/utils": "7.16.11",
30
30
  "saucelabs": "^7.0.0",
31
- "webdriverio": "7.16.8"
31
+ "webdriverio": "7.16.12"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@wdio/cli": "^7.0.0"
@@ -37,5 +37,5 @@
37
37
  "access": "public"
38
38
  },
39
39
  "types": "./build/index.d.ts",
40
- "gitHead": "f8584110532a33ad899ff66eefde427d2d0c7481"
40
+ "gitHead": "18b8916ea2bfed56f20f1926099286618b7f8ffc"
41
41
  }