@wdio/runner 8.0.4 → 8.0.6

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,7 +1,9 @@
1
- import type { Capabilities } from '@wdio/types';
1
+ import type { Capabilities, Options } from '@wdio/types';
2
2
  import type BaseReporter from './reporter';
3
3
  import type { TestFramework } from './types';
4
- type WDIOErrorEvent = Pick<ErrorEvent, 'filename' | 'message'>;
4
+ type WDIOErrorEvent = Partial<Pick<ErrorEvent, 'filename' | 'message'>> & {
5
+ hasViteError?: boolean;
6
+ };
5
7
  declare global {
6
8
  interface Window {
7
9
  __wdioErrors__: WDIOErrorEvent[];
@@ -16,7 +18,7 @@ export default class BrowserFramework implements Omit<TestFramework, 'init'> {
16
18
  private _specs;
17
19
  private _capabilities;
18
20
  private _reporter;
19
- constructor(_cid: string, _config: {
21
+ constructor(_cid: string, _config: Options.Testrunner & {
20
22
  sessionId?: string;
21
23
  }, _specs: string[], _capabilities: Capabilities.RemoteCapability, _reporter: BaseReporter);
22
24
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAW,MAAM,aAAa,CAAA;AAExD,OAAO,KAAK,YAAY,MAAM,YAAY,CAAA;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAK5C,KAAK,cAAc,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC,CAAA;AAE9D,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,cAAc,EAAE,cAAc,EAAE,CAAA;QAChC,cAAc,EAAE,GAAG,EAAE,CAAA;QACrB,gBAAgB,EAAE,MAAM,CAAA;KAC3B;CACJ;AAID,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;;IAIpE,OAAO,CA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ACrB,OAAO,CAAC,SAAS;gBAJT,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,CAAC,UAAU,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,EACpD,MAAM,EAAE,MAAM,EAAE,EAChB,aAAa,EAAE,YAAY,CAAC,gBAAgB,EAC5C,SAAS,EAAE,YAAY;IAMnC;;OAEG;IACH,QAAQ;IAIR,IAAI;IAIE,GAAG;IA0IT,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
@@ -2,6 +2,7 @@ import url from 'node:url';
2
2
  import path from 'node:path';
3
3
  import logger from '@wdio/logger';
4
4
  import { browser } from '@wdio/globals';
5
+ import { executeHooksWithArgs } from '@wdio/utils';
5
6
  const log = logger('@wdio/runner');
6
7
  const sep = '\n - ';
7
8
  const sleep = (ms = 100) => new Promise((resolve) => setTimeout(resolve, ms));
@@ -18,8 +19,8 @@ export default class BrowserFramework {
18
19
  this._specs = _specs;
19
20
  this._capabilities = _capabilities;
20
21
  this._reporter = _reporter;
21
- // listen on debug state switches
22
- process.on('message', this.#switchDebugState.bind(this));
22
+ // listen on testrunner events
23
+ process.on('message', this.#handleProcessMessage.bind(this));
23
24
  }
24
25
  /**
25
26
  * always return true as it is unrelevant for component testing
@@ -36,7 +37,15 @@ export default class BrowserFramework {
36
37
  return failures;
37
38
  }
38
39
  catch (err) {
40
+ if (err.message.includes('net::ERR_CONNECTION_REFUSE')) {
41
+ err.message = `Failed to load test page to run tests, make sure your browser can access "${browser.options.baseUrl}"`;
42
+ }
39
43
  log.error(`Failed to run browser tests with cid ${this._cid}: ${err.stack}`);
44
+ process.send({
45
+ origin: 'worker',
46
+ name: 'error',
47
+ content: { name: err.name, message: err.message, stack: err.stack }
48
+ });
40
49
  return 1;
41
50
  }
42
51
  }
@@ -58,15 +67,49 @@ export default class BrowserFramework {
58
67
  }
59
68
  // await browser.debug()
60
69
  /**
61
- * fetch page errors that are thrown during rendering and let spec file fail
70
+ * wait for test results or page errors
62
71
  */
63
- const jsErrors = (await browser.execute(() => window.__wdioErrors__ || [{
64
- // if `__wdioErrors__` is not defined we ended up in on an error page
65
- message: 'Failed to load test page'
66
- }]));
67
- if (jsErrors.length) {
68
- const errors = jsErrors.map((ev) => `${path.basename(ev.filename || spec)}: ${ev.message}`);
69
- const { name, message, stack } = new Error(`Test failed due to following error(s):${sep}${errors.join(sep)}`);
72
+ let state = {};
73
+ await browser.waitUntil(async () => {
74
+ while (typeof state.failures !== 'number' && (!state.errors || state.errors.length === 0)) {
75
+ await sleep();
76
+ /**
77
+ * don't fetch events if user has called debug command
78
+ */
79
+ if (this.#inDebugMode) {
80
+ continue;
81
+ }
82
+ state = await browser?.execute(function fetchExecutionState() {
83
+ const failures = window.__wdioEvents__ && window.__wdioEvents__.length > 0
84
+ ? window.__wdioFailures__
85
+ : null;
86
+ let viteError;
87
+ const viteErrorElem = document.querySelector('vite-error-overlay');
88
+ if (viteErrorElem && viteErrorElem.shadowRoot) {
89
+ const errorElems = Array.from(viteErrorElem.shadowRoot.querySelectorAll('pre'));
90
+ if (errorElems.length) {
91
+ viteError = errorElems.map((elem) => ({ message: elem.innerText }));
92
+ }
93
+ }
94
+ const loadError = typeof window.__wdioErrors__ === 'undefined'
95
+ ? [{ message: 'Failed to load test page' }]
96
+ : null;
97
+ const errors = viteError || window.__wdioErrors__ || loadError;
98
+ return { failures, errors, hasViteError: Boolean(viteError) };
99
+ }).catch((err) => ({ errors: [{ message: err.message }] }));
100
+ }
101
+ return true;
102
+ }, {
103
+ timeoutMsg: 'browser test timed out',
104
+ timeout: 15 * 1000
105
+ });
106
+ if (state.errors?.length) {
107
+ const errors = state.errors.map((ev) => state.hasViteError
108
+ ? ev.message
109
+ : `${path.basename(ev.filename || spec)}: ${ev.message}`);
110
+ const { name, message, stack } = new Error(state.hasViteError
111
+ ? `Test failed due to the following error: ${errors.join('\n')}`
112
+ : `Test failed due to following error(s):${sep}${errors.join(sep)}`);
70
113
  process.send({
71
114
  origin: 'worker',
72
115
  name: 'error',
@@ -75,33 +118,12 @@ export default class BrowserFramework {
75
118
  failures += 1;
76
119
  continue;
77
120
  }
78
- failures += await this.#fetchEvents(browser, spec, ++uid);
121
+ await this.#fetchEvents(browser, spec, ++uid);
122
+ failures += state.failures || 0;
79
123
  }
80
124
  return failures;
81
125
  }
82
126
  async #fetchEvents(browser, spec, uid) {
83
- /**
84
- * wait until tests have finished and results are emitted to the window scope
85
- */
86
- let failures = null;
87
- await browser.waitUntil(async () => {
88
- while (typeof failures !== 'number') {
89
- await sleep();
90
- /**
91
- * don't fetch events if user has called debug command
92
- */
93
- if (this.#inDebugMode) {
94
- continue;
95
- }
96
- failures = await browser?.execute(() => (window.__wdioEvents__.length > 0
97
- ? window.__wdioFailures__
98
- : null));
99
- }
100
- return true;
101
- }, {
102
- timeoutMsg: 'browser test timed out',
103
- timeout: 15 * 1000
104
- });
105
127
  /**
106
128
  * populate events to the reporter
107
129
  */
@@ -117,10 +139,22 @@ export default class BrowserFramework {
117
139
  cid: this._cid
118
140
  });
119
141
  }
120
- return failures;
121
142
  }
122
- #switchDebugState(cmd) {
123
- this.#inDebugMode = cmd.args;
143
+ async #handleProcessMessage(cmd) {
144
+ if (cmd.command === 'switchDebugState') {
145
+ this.#inDebugMode = cmd.args;
146
+ return;
147
+ }
148
+ if (cmd.command === 'workerHookExecution') {
149
+ const args = cmd.args;
150
+ await executeHooksWithArgs(args.name, this._config[args.name], args.args)
151
+ .catch((err) => log.warn(`Failed running "${args.name}" hook for cid ${args.cid}: ${err.message}`));
152
+ return process.send({
153
+ origin: 'worker',
154
+ name: 'workerHookResult',
155
+ args
156
+ });
157
+ }
124
158
  }
125
159
  static init(cid, config, specs, caps, reporter) {
126
160
  const framework = new BrowserFramework(cid, config, specs, caps, reporter);
package/build/types.d.ts CHANGED
@@ -50,5 +50,20 @@ export interface SessionEndedMessage {
50
50
  name: 'sessionEnded';
51
51
  cid: string;
52
52
  }
53
+ export interface WorkerHookResultMessage {
54
+ origin: 'worker';
55
+ name: 'workerHookResult';
56
+ args: HookTriggerEvent;
57
+ }
58
+ /**
59
+ * Duplicate of @wdio/browser-runner type, refactoring needed
60
+ * see https://github.com/webdriverio/webdriverio/issues/9299
61
+ */
62
+ export interface HookTriggerEvent {
63
+ id: string;
64
+ cid: string;
65
+ name: string;
66
+ args: unknown[];
67
+ }
53
68
  export {};
54
69
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,YAAY,MAAM,eAAe,CAAA;AAExC,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAA;AAC/E,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;AAC7E,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,eAAe,CAAC,CAAC,CAAA;AAC7F,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,cAAc,CAAC,CAAC,CAAA;AAE3F,UAAU,IAAK,SAAQ,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;IAC9C,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAA;IAChC,KAAK,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,MAAM,SAAS,GAAG;IAC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pC,MAAM,EAAE,QAAQ,CAAA;IAChB,IAAI,EAAE,kBAAkB,CAAC;IACzB,IAAI,EAAE,gBAAgB,CAAA;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,EAAE,CAAA;CAClB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/runner",
3
- "version": "8.0.4",
3
+ "version": "8.0.6",
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",
@@ -26,19 +26,19 @@
26
26
  "types": "./build/index.d.ts",
27
27
  "typeScriptVersion": "3.8.3",
28
28
  "dependencies": {
29
- "@wdio/config": "8.0.2",
30
- "@wdio/globals": "8.0.4",
29
+ "@wdio/config": "8.0.6",
30
+ "@wdio/globals": "8.0.6",
31
31
  "@wdio/logger": "8.0.0",
32
- "@wdio/types": "8.0.0",
33
- "@wdio/utils": "8.0.2",
32
+ "@wdio/types": "8.0.6",
33
+ "@wdio/utils": "8.0.6",
34
34
  "deepmerge-ts": "^4.2.2",
35
35
  "expect-webdriverio": "^4.0.1",
36
36
  "gaze": "^1.1.2",
37
- "webdriver": "8.0.2",
38
- "webdriverio": "8.0.4"
37
+ "webdriver": "8.0.6",
38
+ "webdriverio": "8.0.6"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "3e59b46e07fe878dd9ff57d746f698edcb13d94f"
43
+ "gitHead": "4f63a94a3af029401d652ff1d0fa36e9057f553c"
44
44
  }