@wdio/runner 8.27.2 → 8.28.0

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.
@@ -1,4 +1,4 @@
1
- import type { Capabilities, Options } from '@wdio/types';
1
+ import { type Capabilities, type Options } from '@wdio/types';
2
2
  import type BaseReporter from './reporter.js';
3
3
  import type { TestFramework } from './types.js';
4
4
  type WDIOErrorEvent = Partial<Pick<ErrorEvent, 'filename' | 'message' | 'error'>> & {
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAW,OAAO,EAAY,MAAM,aAAa,CAAA;AAE3E,OAAO,KAAK,YAAY,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAA6C,MAAM,YAAY,CAAA;AAM1F,KAAK,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC,GAAG;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAO9G,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,cAAc,EAAE,cAAc,EAAE,CAAA;QAChC,cAAc,EAAE,GAAG,EAAE,CAAA;QACrB,gBAAgB,EAAE,MAAM,CAAA;QACxB,YAAY,CAAC,EAAE,OAAO,CAAA;KACzB;CACJ;AAID,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;;IAKpE,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS;gBAJT,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,CAAC,UAAU,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,EACpD,MAAM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AE,MAAM,EAAE,EAChB,aAAa,EAAE,YAAY,CAAC,gBAAgB,EAC5C,SAAS,EAAE,YAAY;IASnC;;OAEG;IACH,QAAQ;IAIR,IAAI;IAIE,GAAG;IAuVT,MAAM,CAAC,IAAI,CAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,YAAY,CAAC,gBAAgB,EAAE,QAAQ,EAAE,YAAY;CAItH"}
package/build/browser.js CHANGED
@@ -3,6 +3,9 @@ import path from 'node:path';
3
3
  import logger from '@wdio/logger';
4
4
  import { browser } from '@wdio/globals';
5
5
  import { executeHooksWithArgs } from '@wdio/utils';
6
+ import { matchers } from 'expect-webdriverio';
7
+ import { MESSAGE_TYPES } from '@wdio/types';
8
+ import { transformExpectArgs } from './utils.js';
6
9
  const log = logger('@wdio/runner');
7
10
  const sep = '\n - ';
8
11
  const DEFAULT_TIMEOUT = 60 * 1000;
@@ -22,7 +25,7 @@ export default class BrowserFramework {
22
25
  this._capabilities = _capabilities;
23
26
  this._reporter = _reporter;
24
27
  // listen on testrunner events
25
- process.on('message', this.#handleProcessMessage.bind(this));
28
+ process.on('message', this.#processMessage.bind(this));
26
29
  const [, runnerOptions] = Array.isArray(_config.runner) ? _config.runner : [];
27
30
  this.#runnerOptions = runnerOptions || {};
28
31
  }
@@ -68,7 +71,7 @@ export default class BrowserFramework {
68
71
  log.info(`Run spec file ${spec} for cid ${this._cid}`);
69
72
  /**
70
73
  * if a `sessionId` is part of `this._config` it means we are in watch mode and are
71
- * re-using a previous session. Since Vite has already a hotreload feature, there
74
+ * re-using a previous session. Since Vite has already a hot-reload feature, there
72
75
  * is no need to call the url command again
73
76
  */
74
77
  if (!this._config.sessionId) {
@@ -107,9 +110,9 @@ export default class BrowserFramework {
107
110
  let viteError;
108
111
  const viteErrorElem = document.querySelector('vite-error-overlay');
109
112
  if (viteErrorElem && viteErrorElem.shadowRoot) {
110
- const errorElems = Array.from(viteErrorElem.shadowRoot.querySelectorAll('pre'));
111
- if (errorElems.length) {
112
- viteError = [{ message: errorElems.map((elem) => elem.innerText).join('\n') }];
113
+ const errorElements = Array.from(viteErrorElem.shadowRoot.querySelectorAll('pre'));
114
+ if (errorElements.length) {
115
+ viteError = [{ message: errorElements.map((elem) => elem.innerText).join('\n') }];
113
116
  }
114
117
  }
115
118
  const loadError = (typeof window.__wdioErrors__ === 'undefined' &&
@@ -131,11 +134,15 @@ export default class BrowserFramework {
131
134
  */
132
135
  if (this.#runnerOptions.coverage?.enabled && process.send) {
133
136
  const coverageMap = await browser.execute(() => (window.__coverage__ || {}));
134
- process.send({
137
+ const workerEvent = {
135
138
  origin: 'worker',
136
- name: 'coverageMap',
137
- content: { coverageMap }
138
- });
139
+ name: 'workerEvent',
140
+ args: {
141
+ type: MESSAGE_TYPES.coverageMap,
142
+ value: coverageMap
143
+ }
144
+ };
145
+ process.send(workerEvent);
139
146
  }
140
147
  if (state.errors?.length) {
141
148
  const errors = state.errors.map((ev) => state.hasViteError
@@ -178,21 +185,155 @@ export default class BrowserFramework {
178
185
  });
179
186
  }
180
187
  }
181
- async #handleProcessMessage(cmd) {
182
- if (cmd.command === 'switchDebugState') {
183
- this.#inDebugMode = cmd.args;
188
+ async #processMessage(cmd) {
189
+ if (cmd.command !== 'workerRequest' || !process.send) {
184
190
  return;
185
191
  }
186
- if (cmd.command === 'workerHookExecution') {
187
- const args = cmd.args;
188
- await executeHooksWithArgs(args.name, this._config[args.name], args.args)
189
- .catch((err) => log.warn(`Failed running "${args.name}" hook for cid ${args.cid}: ${err.message}`));
190
- return process.send({
191
- origin: 'worker',
192
- name: 'workerHookResult',
193
- args
194
- });
192
+ const { message, id } = cmd.args;
193
+ if (message.type === MESSAGE_TYPES.switchDebugState) {
194
+ this.#inDebugMode = message.value;
195
+ return;
196
+ }
197
+ if (message.type === MESSAGE_TYPES.hookTriggerMessage) {
198
+ return this.#handleHook(id, message.value);
199
+ }
200
+ if (message.type === MESSAGE_TYPES.consoleMessage) {
201
+ return this.#handleConsole(message.value);
202
+ }
203
+ if (message.type === MESSAGE_TYPES.commandRequestMessage) {
204
+ return this.#handleCommand(id, message.value);
205
+ }
206
+ if (message.type === MESSAGE_TYPES.expectRequestMessage) {
207
+ return this.#handleExpectation(id, message.value);
208
+ }
209
+ }
210
+ async #handleHook(id, payload) {
211
+ const error = await executeHooksWithArgs(payload.name, this._config[payload.name], payload.args).then(() => undefined, (err) => err);
212
+ if (error) {
213
+ log.warn(`Failed running "${payload.name}" hook for cid ${payload.cid}: ${error.message}`);
214
+ }
215
+ return this.#sendWorkerResponse(id, this.#hookResponse({ id: payload.id, error }));
216
+ }
217
+ #hookResponse(value) {
218
+ return {
219
+ type: MESSAGE_TYPES.hookResultMessage,
220
+ value
221
+ };
222
+ }
223
+ #sendWorkerResponse(id, message) {
224
+ if (!process.send) {
225
+ return;
226
+ }
227
+ const response = {
228
+ origin: 'worker',
229
+ name: 'workerResponse',
230
+ args: { id, message }
231
+ };
232
+ process.send(response);
233
+ }
234
+ /**
235
+ * Print console message executed in browser to the terminal
236
+ * @param message console.log message args
237
+ * @returns void
238
+ */
239
+ #handleConsole(message) {
240
+ const isWDIOLog = Boolean(typeof message.args[0] === 'string' && message.args[0].startsWith('[WDIO]') && message.type !== 'error');
241
+ if (message.name !== 'consoleEvent' || isWDIOLog) {
242
+ return;
243
+ }
244
+ console[message.type](...(message.args || []));
245
+ }
246
+ async #handleCommand(id, payload) {
247
+ log.debug(`Received browser message: ${JSON.stringify(payload)}`);
248
+ const cid = payload.cid;
249
+ if (typeof cid !== 'string') {
250
+ const { message, stack } = new Error(`No "cid" property passed into command message with id "${payload.id}"`);
251
+ const error = { message, stack, name: 'Error' };
252
+ return this.#sendWorkerResponse(id, this.#commandResponse({ id: payload.id, error }));
253
+ }
254
+ /**
255
+ * emit debug state to be enabled to runner so it can be propagated to the worker
256
+ */
257
+ if (payload.commandName === 'debug') {
258
+ this.#inDebugMode = true;
195
259
  }
260
+ try {
261
+ /**
262
+ * double check if function is registered
263
+ */
264
+ if (typeof browser[payload.commandName] !== 'function') {
265
+ throw new Error(`browser.${payload.commandName} is not a function`);
266
+ }
267
+ const result = await browser[payload.commandName](...payload.args);
268
+ const resultMsg = this.#commandResponse({ id: payload.id, result });
269
+ /**
270
+ * emit debug state to be disabled to runner so it can be propagated to the worker
271
+ */
272
+ if (payload.commandName === 'debug') {
273
+ this.#inDebugMode = false;
274
+ }
275
+ log.debug(`Return command result: ${resultMsg}`);
276
+ return this.#sendWorkerResponse(id, resultMsg);
277
+ }
278
+ catch (error) {
279
+ const { message, stack, name } = error;
280
+ return this.#sendWorkerResponse(id, this.#commandResponse({ id: payload.id, error: { message, stack, name } }));
281
+ }
282
+ }
283
+ #commandResponse(value) {
284
+ return {
285
+ type: MESSAGE_TYPES.commandResponseMessage,
286
+ value
287
+ };
288
+ }
289
+ /**
290
+ * handle expectation assertions within the worker process
291
+ * @param id message id from communicator
292
+ * @param payload information about the expectation to run
293
+ * @returns void
294
+ */
295
+ async #handleExpectation(id, payload) {
296
+ log.debug(`Received expectation message: ${JSON.stringify(payload)}`);
297
+ const cid = payload.cid;
298
+ /**
299
+ * check if payload contains `cid` needed to get a browser instance from the pool
300
+ */
301
+ if (typeof cid !== 'string') {
302
+ const message = `No "cid" property passed into expect request message with id "${payload.id}"`;
303
+ return this.#sendWorkerResponse(id, this.#expectResponse({ id: payload.id, pass: false, message }));
304
+ }
305
+ /**
306
+ * find matcher, e.g. `toBeDisplayed` or `toHaveTitle`
307
+ */
308
+ const matcher = matchers[payload.matcherName];
309
+ if (!matcher) {
310
+ const message = `Couldn't find matcher with name "${payload.matcherName}"`;
311
+ return this.#sendWorkerResponse(id, this.#expectResponse({ id: payload.id, pass: false, message }));
312
+ }
313
+ try {
314
+ const context = payload.element
315
+ ? Array.isArray(payload.element)
316
+ ? await browser.$$(payload.element)
317
+ : await browser.$(payload.element)
318
+ : browser;
319
+ const result = await matcher.apply(payload.scope, [context, ...payload.args.map(transformExpectArgs)]);
320
+ return this.#sendWorkerResponse(id, this.#expectResponse({
321
+ id: payload.id,
322
+ pass: result.pass,
323
+ message: result.message()
324
+ }));
325
+ }
326
+ catch (err) {
327
+ const errorMessage = err instanceof Error ? err.stack : err;
328
+ const message = `Failed to execute expect command "${payload.matcherName}": ${errorMessage}`;
329
+ return this.#sendWorkerResponse(id, this.#expectResponse({ id: payload.id, pass: false, message }));
330
+ }
331
+ }
332
+ #expectResponse(value) {
333
+ return {
334
+ type: MESSAGE_TYPES.expectResponseMessage,
335
+ value
336
+ };
196
337
  }
197
338
  static init(cid, config, specs, caps, reporter) {
198
339
  const framework = new BrowserFramework(cid, config, specs, caps, reporter);
package/build/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Options, Capabilities, Services } from '@wdio/types';
1
+ import type { Options, Capabilities, Services, Workers } from '@wdio/types';
2
2
  import type BaseReporter from './reporter.js';
3
3
  export type BeforeArgs = Parameters<Required<Services.HookFunctions>['before']>;
4
4
  export type AfterArgs = Parameters<Required<Services.HookFunctions>['after']>;
@@ -51,27 +51,13 @@ export interface SessionEndedMessage {
51
51
  name: 'sessionEnded';
52
52
  cid: string;
53
53
  }
54
- export interface WorkerHookResultMessage {
54
+ export interface WorkerResponseMessage {
55
55
  origin: 'worker';
56
- name: 'workerHookResult';
57
- args: HookTriggerEvent;
58
- }
59
- export interface WorkerCoverageMapMessage {
60
- origin: 'worker';
61
- name: 'coverageMap';
62
- content: {
63
- coverageMap: unknown;
56
+ name: 'workerResponse';
57
+ args: {
58
+ id: number;
59
+ message: Workers.SocketMessage;
64
60
  };
65
61
  }
66
- /**
67
- * Duplicate of @wdio/browser-runner type, refactoring needed
68
- * see https://github.com/webdriverio/webdriverio/issues/9299
69
- */
70
- export interface HookTriggerEvent {
71
- id: string;
72
- cid: string;
73
- name: string;
74
- args: unknown[];
75
- }
76
62
  export {};
77
63
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.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AAA;CACf;AAED,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,QAAQ,CAAA;IAChB,IAAI,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,qBAAqB;IAClC,MAAM,EAAE,QAAQ,CAAA;IAChB,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE;QACF,EAAE,EAAE,MAAM,CAAA;QACV,OAAO,EAAE,OAAO,CAAC,aAAa,CAAA;KACjC,CAAA;CACJ"}
package/build/utils.d.ts CHANGED
@@ -40,5 +40,11 @@ type BrowserData = {
40
40
  * @return {object}
41
41
  */
42
42
  export declare function getInstancesData(browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser, isMultiremote: boolean): Record<string, Partial<BrowserData>> | undefined;
43
+ /**
44
+ * utility function to transform assertion parameters into asymmetric matchers if necessary
45
+ * @param arg raw value or a stringified asymmetric matcher
46
+ * @returns raw value or an actual asymmetric matcher
47
+ */
48
+ export declare function transformExpectArgs(arg: any): any;
43
49
  export {};
44
50
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAIxD,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,CAAC;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC,gBAAgB,CAAA;CAC9C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CACxB,IAAI,EAAE,YAAY,CAAC,gBAAgB,EACnC,SAAS,CAAC,EAAE,OAAO,GACpB,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAoBjD;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACpC,MAAM,EAAE,mB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AAY,CAAC,gBAAgB,EAC3C,aAAa,CAAC,EAAE,OAAO,GACxB,OAAO,CAAC,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAiE/D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC1B,iBAAiB,EAAE,MAAM,EAAE,EAC3B,cAAc,EAAE,MAAM,EAAE,YAa3B;AAED,KAAK,WAAW,GAAG;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,OAAO,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACtC,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC5B,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,EAC7D,aAAa,EAAE,OAAO,oDAgBzB;AAYD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAE,GAAG,EAAE,GAAG,OAa5C"}
package/build/utils.js CHANGED
@@ -125,3 +125,28 @@ export function getInstancesData(browser, isMultiremote) {
125
125
  });
126
126
  return instances;
127
127
  }
128
+ const SUPPORTED_ASYMMETRIC_MATCHER = {
129
+ Any: 'any',
130
+ Anything: 'anything',
131
+ ArrayContaining: 'arrayContaining',
132
+ ObjectContaining: 'objectContaining',
133
+ StringContaining: 'stringContaining',
134
+ StringMatching: 'stringMatching',
135
+ CloseTo: 'closeTo'
136
+ };
137
+ /**
138
+ * utility function to transform assertion parameters into asymmetric matchers if necessary
139
+ * @param arg raw value or a stringified asymmetric matcher
140
+ * @returns raw value or an actual asymmetric matcher
141
+ */
142
+ export function transformExpectArgs(arg) {
143
+ if (typeof arg === 'object' && '$$typeof' in arg && Object.keys(SUPPORTED_ASYMMETRIC_MATCHER).includes(arg.$$typeof)) {
144
+ const matcherKey = SUPPORTED_ASYMMETRIC_MATCHER[arg.$$typeof];
145
+ const matcher = arg.inverse ? expect.not[matcherKey] : expect[matcherKey];
146
+ if (!matcher) {
147
+ throw new Error(`Matcher "${matcherKey}" is not supported by expect-webdriverio`);
148
+ }
149
+ return matcher(arg.sample);
150
+ }
151
+ return arg;
152
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/runner",
3
- "version": "8.27.2",
3
+ "version": "8.28.0",
4
4
  "description": "A WebdriverIO service that runs tests in arbitrary environments",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-runner",
@@ -30,19 +30,19 @@
30
30
  "typeScriptVersion": "3.8.3",
31
31
  "dependencies": {
32
32
  "@types/node": "^20.1.0",
33
- "@wdio/config": "8.27.2",
34
- "@wdio/globals": "8.27.2",
35
- "@wdio/logger": "8.24.12",
36
- "@wdio/types": "8.27.2",
37
- "@wdio/utils": "8.27.2",
33
+ "@wdio/config": "8.28.0",
34
+ "@wdio/globals": "8.28.0",
35
+ "@wdio/logger": "8.28.0",
36
+ "@wdio/types": "8.28.0",
37
+ "@wdio/utils": "8.28.0",
38
38
  "deepmerge-ts": "^5.0.0",
39
39
  "expect-webdriverio": "^4.8.0",
40
40
  "gaze": "^1.1.2",
41
- "webdriver": "8.27.2",
42
- "webdriverio": "8.27.2"
41
+ "webdriver": "8.28.0",
42
+ "webdriverio": "8.28.0"
43
43
  },
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "gitHead": "dab64ff6cbd378b295af3a65d6346692f0653d23"
47
+ "gitHead": "15f6ac509df48b23477cd4c793206a4f707e3df0"
48
48
  }