@wdio/browser-runner 8.29.6 → 8.29.7

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.
@@ -3,7 +3,7 @@ import { webdriverMonad, sessionEnvironmentDetector } from '@wdio/utils';
3
3
  import { getEnvironmentVars } from 'webdriver';
4
4
  import { MESSAGE_TYPES } from '@wdio/types';
5
5
  import { browser } from '@wdio/globals';
6
- import { getCID } from './utils.js';
6
+ import { getCID, sanitizeConsoleArgs } from './utils.js';
7
7
  import { WDIO_EVENT_NAME } from '../constants.js';
8
8
  const COMMAND_TIMEOUT = 30 * 1000; // 30s
9
9
  const CONSOLE_METHODS = ['log', 'info', 'warn', 'error', 'debug'];
@@ -147,7 +147,7 @@ export default class ProxyDriver {
147
147
  import.meta.hot?.send(WDIO_EVENT_NAME, this.#consoleMessage({
148
148
  name: 'consoleEvent',
149
149
  type: method,
150
- args,
150
+ args: sanitizeConsoleArgs(args),
151
151
  cid
152
152
  }));
153
153
  origCommand(...args);
@@ -6,6 +6,10 @@ import type { NewSpecPageOptions } from '@stencil/core/internal';
6
6
  * @returns the created spec page
7
7
  */
8
8
  export declare function render(opts: NewSpecPageOptions): StencilEnvironment;
9
+ /**
10
+ * Helper method to wait until all Stencil components are rendered
11
+ */
12
+ export declare function waitForChanges(documentElement?: HTMLElement): Promise<void>;
9
13
  /**
10
14
  * A set of flags used for bitwise calculations against {@link ComponentRuntimeMeta#$flags$}.
11
15
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stencil.d.ts","sourceRoot":"","sources":["../../../src/browser/integrations/stencil.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAgBrE,OAAO,KAAK,EAMR,kBAAkB,EACrB,MAAM,wBAAwB,CAAA;AAe/B;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,kBAAkB,GAAG,kBAAkB,CAwInE;AAsGD;;GAEG;AACH,wBAAgB,cAAc,CAAE,eAAe,cAA2B,iBA4BzE;AAED;;;;;GAKG;AACH,0BAAkB,SAAS;IACvB;;;OAGG;IACH,sBAAsB,IAAS;IAC/B;;;OAGG;IACH,sBAAsB,IAAS;IAC/B;;OAEG;IACH,iBAAiB,IAAS;IAM1B;;;;;OAKG;IACH,kBAAkB,IAAS;IAC3B;;;OAGG;IACH,oBAAoB,KAAS;IAC7B;;OAEG;IACH,OAAO,KAAS;IAEhB;;;;;OAKG;IACH,wBAAwB,KAA8C;CACzE;AASD;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,iBACrB,GAAG,kBACD,OAAO,KACxB,GAyBF,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { h } from '@stencil/core';
2
+ import { $ } from '@wdio/globals';
2
3
  /**
3
4
  * Emulate Node.js `nextTick` function in browser.
4
5
  * This is used by Stencil.js internally.
@@ -109,6 +110,9 @@ export function render(opts) {
109
110
  };
110
111
  renderVdom(ref, opts.template());
111
112
  }
113
+ else if (typeof opts.html === 'string') {
114
+ container.innerHTML = opts.html;
115
+ }
112
116
  let rootComponent = null;
113
117
  Object.defineProperty(page, 'root', {
114
118
  get() {
@@ -121,6 +125,16 @@ export function render(opts) {
121
125
  return container.firstElementChild;
122
126
  },
123
127
  });
128
+ Object.defineProperty(page, '$root', {
129
+ get() {
130
+ return $(page.root);
131
+ }
132
+ });
133
+ Object.defineProperty(page, '$container', {
134
+ get() {
135
+ return $(container);
136
+ }
137
+ });
124
138
  if (opts.hydrateServerSide) {
125
139
  insertVdomAnnotations(document, []);
126
140
  }
@@ -225,6 +239,35 @@ function findRootComponent(cmpTags, node) {
225
239
  }
226
240
  return null;
227
241
  }
242
+ /**
243
+ * Helper method to wait until all Stencil components are rendered
244
+ */
245
+ export function waitForChanges(documentElement = document.documentElement) {
246
+ return new Promise((resolve) => {
247
+ requestAnimationFrame(() => {
248
+ const promiseChain = [];
249
+ const waitComponentOnReady = (elm, promises) => {
250
+ if ('shadowRoot' in elm && elm.shadowRoot instanceof ShadowRoot) {
251
+ waitComponentOnReady(elm.shadowRoot, promises);
252
+ }
253
+ const children = elm.children;
254
+ const len = children.length;
255
+ for (let i = 0; i < len; i++) {
256
+ const childElm = children[i];
257
+ const childStencilElm = childElm;
258
+ if (childElm.tagName.includes('-') && typeof childStencilElm.componentOnReady === 'function') {
259
+ promises.push(childStencilElm.componentOnReady().then(() => { }));
260
+ }
261
+ waitComponentOnReady(childElm, promises);
262
+ }
263
+ };
264
+ waitComponentOnReady(documentElement, promiseChain);
265
+ Promise.all(promiseChain)
266
+ .then(() => resolve())
267
+ .catch(() => resolve());
268
+ });
269
+ });
270
+ }
228
271
  const formatLazyBundleRuntimeMeta = (bundleId, cmps) => {
229
272
  return [bundleId, cmps.map((cmp) => formatComponentRuntimeMeta(cmp, true))];
230
273
  };
@@ -1,3 +1,4 @@
1
1
  export declare function getCID(): string | undefined;
2
2
  export declare const showPopupWarning: <T>(name: string, value: T, defaultValue?: T | undefined) => (...params: any[]) => T;
3
+ export declare function sanitizeConsoleArgs(args: unknown[]): any[];
3
4
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/browser/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,uBAYrB;AAED,eAAO,MAAM,gBAAgB,YAAa,MAAM,yDAA6C,GAAG,EAAE,MAYjG,CAAA"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/browser/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,uBAYrB;AAED,eAAO,MAAM,gBAAgB,YAAa,MAAM,yDAA6C,GAAG,EAAE,MAYjG,CAAA;AAED,wBAAgB,mBAAmB,CAAE,IAAI,EAAE,OAAO,EAAE,SAyBnD"}
@@ -22,3 +22,27 @@ export const showPopupWarning = (name, value, defaultValue) => (...params) => {
22
22
  \`\`\``);
23
23
  return value;
24
24
  };
25
+ export function sanitizeConsoleArgs(args) {
26
+ return args.map((arg) => {
27
+ try {
28
+ if (arg && typeof arg.elementId === 'string') {
29
+ return `WebdriverIO.Element<${arg.elementId}>`;
30
+ }
31
+ if (arg && typeof arg.sessionId === 'string') {
32
+ return `WebdriverIO.Browser<${arg.sessionId}>`;
33
+ }
34
+ }
35
+ catch (err) {
36
+ // ignore
37
+ }
38
+ if (arg instanceof HTMLElement ||
39
+ (arg && typeof arg === 'object' && 'then' in arg && typeof arg.then === 'function') ||
40
+ typeof arg === 'function') {
41
+ return arg.toString();
42
+ }
43
+ if (arg instanceof Error) {
44
+ return arg.stack;
45
+ }
46
+ return arg;
47
+ });
48
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"stencil.d.ts","sourceRoot":"","sources":["../../../src/vite/frameworks/stencil.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAU,MAAM,MAAM,CAAA;AAahD,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,oBAAoB,oBAEhG;AAED,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,yBAwBvD;AAwID;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,gBAaxD"}
1
+ {"version":3,"file":"stencil.d.ts","sourceRoot":"","sources":["../../../src/vite/frameworks/stencil.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAU,MAAM,MAAM,CAAA;AAahD,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,oBAAoB,oBAEhG;AAED,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,yBAwBvD;AA2ID;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,gBAaxD"}
@@ -30,7 +30,7 @@ export async function optimizeForStencil(rootDir) {
30
30
  }
31
31
  async function stencilVitePlugin(rootDir) {
32
32
  const { transpileSync, ts } = await import('@stencil/core/compiler/stencil.js');
33
- const stencilHelperPath = path.resolve(__dirname, '..', '..', 'browser', 'fixtures', 'stencil.js');
33
+ const stencilHelperPath = path.resolve(__dirname, '..', '..', 'browser', 'integrations', 'stencil.js');
34
34
  return {
35
35
  name: 'wdio-stencil',
36
36
  enforce: 'pre',
@@ -56,15 +56,8 @@ async function stencilVitePlugin(rootDir) {
56
56
  const stencilHelperImport = staticImports.find((imp) => imp.specifier === '@wdio/browser-runner/stencil');
57
57
  if (stencilHelperImport) {
58
58
  const imports = parseStaticImport(stencilHelperImport);
59
- const hasHImport = stencilImports.find((imp) => 'h' in (imp.namedImports || {}));
60
- const hasFragmentImport = stencilImports.find((imp) => 'Fragment' in (imp.namedImports || {}));
61
59
  if ('render' in (imports.namedImports || {})) {
62
- if (!hasHImport) {
63
- code = `import { h } from '@stencil/core';\n${code}`;
64
- }
65
- if (!hasFragmentImport) {
66
- code = `import { Fragment } from '@stencil/core';\n${code}`;
67
- }
60
+ code = injectStencilImports(code, stencilImports);
68
61
  }
69
62
  }
70
63
  return { code };
@@ -97,14 +90,7 @@ async function stencilVitePlugin(rootDir) {
97
90
  * StencilJS does not import the `h` or `Fragment` function by default. We need to add it so the user
98
91
  * doesn't need to.
99
92
  */
100
- const hasRenderFunctionImport = stencilImports.some((imp) => 'h' in (imp.namedImports || {}));
101
- if (!hasRenderFunctionImport) {
102
- transformedCode = `import { h } from '@stencil/core';\n${transformedCode}`;
103
- }
104
- const hasFragmentImport = stencilImports.some((imp) => 'Fragment' in (imp.namedImports || {}));
105
- if (!hasFragmentImport) {
106
- transformedCode = `import { Fragment } from '@stencil/core';\n${transformedCode}`;
107
- }
93
+ transformedCode = injectStencilImports(transformedCode, stencilImports);
108
94
  return {
109
95
  ...transpiledCode,
110
96
  code: transformedCode,
@@ -113,6 +99,21 @@ async function stencilVitePlugin(rootDir) {
113
99
  }
114
100
  };
115
101
  }
102
+ /**
103
+ * StencilJS does not import the `h` or `Fragment` function by default. We need to add it so the user
104
+ * doesn't need to.
105
+ */
106
+ function injectStencilImports(code, imports) {
107
+ const hasRenderFunctionImport = imports.some((imp) => 'h' in (imp.namedImports || {}));
108
+ if (!hasRenderFunctionImport) {
109
+ code = `import { h } from '@stencil/core/internal/client';\n${code}`;
110
+ }
111
+ const hasFragmentImport = imports.some((imp) => 'Fragment' in (imp.namedImports || {}));
112
+ if (!hasFragmentImport) {
113
+ code = `import { Fragment } from '@stencil/core/internal/client';\n${code}`;
114
+ }
115
+ return code;
116
+ }
116
117
  let _tsCompilerOptions = null;
117
118
  /**
118
119
  * Read the TypeScript compiler configuration file from disk
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/browser-runner",
3
- "version": "8.29.6",
3
+ "version": "8.29.7",
4
4
  "description": "A WebdriverIO runner to run unit tests tests in the browser.",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-browser-runner",
@@ -37,12 +37,12 @@
37
37
  "@originjs/vite-plugin-commonjs": "^1.0.3",
38
38
  "@types/istanbul-lib-source-maps": "^4.0.1",
39
39
  "@vitest/spy": "^1.0.1",
40
- "@wdio/globals": "8.29.3",
41
- "@wdio/local-runner": "8.29.5",
40
+ "@wdio/globals": "8.29.7",
41
+ "@wdio/local-runner": "8.29.7",
42
42
  "@wdio/logger": "8.28.0",
43
43
  "@wdio/mocha-framework": "8.29.3",
44
- "@wdio/protocols": "^8.24.12",
45
- "@wdio/runner": "8.29.5",
44
+ "@wdio/protocols": "8.29.7",
45
+ "@wdio/runner": "8.29.7",
46
46
  "@wdio/types": "8.29.1",
47
47
  "@wdio/utils": "8.29.3",
48
48
  "deepmerge-ts": "^5.0.0",
@@ -62,8 +62,8 @@
62
62
  "vite": "~4.5.0",
63
63
  "vite-plugin-istanbul": "^5.0.0",
64
64
  "vite-plugin-top-level-await": "^1.3.0",
65
- "webdriver": "8.29.3",
66
- "webdriverio": "8.29.3"
65
+ "webdriver": "8.29.7",
66
+ "webdriverio": "8.29.7"
67
67
  },
68
68
  "scripts": {
69
69
  "prepare": "rimraf node_modules/@wdio/config node_modules/@wdio/repl node_modules/@wdio/utils"
@@ -71,5 +71,5 @@
71
71
  "publishConfig": {
72
72
  "access": "public"
73
73
  },
74
- "gitHead": "45ff936ee5c76137bf96c15a2fc36c362a0ff693"
74
+ "gitHead": "1c7195268663df56856494c69d7bd655c834a368"
75
75
  }
@@ -17,6 +17,10 @@ export interface RenderOptions {
17
17
  * It will render the specified template (JSX) into `document.body`.
18
18
  */
19
19
  template?: () => any;
20
+ /**
21
+ * The initial HTML used to generate the test. This can be useful to construct a collection of components working together, and assign HTML attributes.
22
+ */
23
+ html?: string;
20
24
  /**
21
25
  * Sets the mocked `lang` attribute on `<html>`.
22
26
  */
@@ -24,25 +28,17 @@ export interface RenderOptions {
24
28
  /**
25
29
  * Useful for debugging hydrating components client-side. Sets that the `html` option already includes annotated prerender attributes and comments.
26
30
  */
27
- hydrateClientSide?: boolean;
31
+ // hydrateClientSide?: boolean;
28
32
  /**
29
33
  * Useful for debugging hydrating components server-side. The output HTML will also include prerender annotations.
30
34
  */
31
- hydrateServerSide?: boolean;
32
- /**
33
- * Sets the mocked `document.referrer`.
34
- */
35
- referrer?: string;
36
- /**
37
- * Manually set if the mocked document supports Shadow DOM or not. Default is `true`.
38
- */
39
- supportsShadowDom?: boolean;
35
+ // hydrateServerSide?: boolean;
40
36
  /**
41
37
  * When a component is pre-rendered it includes HTML annotations, such as `s-id` attributes and `<!-t.0->` comments. This information is used by clientside hydrating. Default is `false`.
42
38
  */
43
- includeAnnotations?: boolean;
39
+ // includeAnnotations?: boolean;
44
40
  /**
45
- * By default, any changes to component properties and attributes must `page.waitForChanges()` in order to test the updates. As an option, `autoAppluChanges` continuously flushes the queue on the background. Default is `false`.
41
+ * By default, any changes to component properties and attributes must `page.waitForChanges()` in order to test the updates. As an option, `autoApplyChanges` continuously flushes the queue on the background. Default is `false`.
46
42
  */
47
43
  autoApplyChanges?: boolean;
48
44
  /**
@@ -55,7 +51,7 @@ export interface RenderOptions {
55
51
  * When `true` all `BuildConditionals` will be assigned to the global testing `BUILD` object, regardless of their
56
52
  * value. When `false`, only `BuildConditionals` with a value of `true` will be assigned to the `BUILD` object.
57
53
  */
58
- strictBuild?: boolean;
54
+ // strictBuild?: boolean;
59
55
  }
60
56
 
61
57
  export interface StencilEnvironment {
@@ -73,14 +69,33 @@ export interface StencilEnvironment {
73
69
  * Container element in which the template is being rendered into.
74
70
  */
75
71
  container: HTMLElement
72
+ /**
73
+ * The container element as WebdriverIO element.
74
+ */
75
+ $container: WebdriverIO.Element
76
76
  /**
77
77
  * The root component of the template.
78
78
  */
79
79
  root: HTMLElement
80
+ /**
81
+ * The root component as WebdriverIO element.
82
+ */
83
+ $root: WebdriverIO.Element
80
84
  /**
81
85
  * Removes the container element from the DOM.
82
86
  */
83
87
  unmount: () => void
84
88
  }
85
89
 
90
+ /**
91
+ * Renders a Stencil component for testing into the page.
92
+ * @param opts options for the test page
93
+ * @returns a testing environment for the rendered component
94
+ */
86
95
  export function render(opts: RenderOptions): StencilEnvironment
96
+
97
+ /**
98
+ * Waits for the next update cycle to complete.
99
+ * @returns a promise that resolves when the update cycle completes
100
+ */
101
+ export function waitForChanges(): Promise<void>
@@ -1 +0,0 @@
1
- {"version":3,"file":"stencil.d.ts","sourceRoot":"","sources":["../../../src/browser/fixtures/stencil.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAgBrE,OAAO,KAAK,EAKR,kBAAkB,EACrB,MAAM,wBAAwB,CAAA;AAe/B;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,kBAAkB,GAAG,kBAAkB,CA2HnE;AAsGD;;;;;GAKG;AACH,0BAAkB,SAAS;IACvB;;;OAGG;IACH,sBAAsB,IAAS;IAC/B;;;OAGG;IACH,sBAAsB,IAAS;IAC/B;;OAEG;IACH,iBAAiB,IAAS;IAM1B;;;;;OAKG;IACH,kBAAkB,IAAS;IAC3B;;;OAGG;IACH,oBAAoB,KAAS;IAC7B;;OAEG;IACH,OAAO,KAAS;IAEhB;;;;;OAKG;IACH,wBAAwB,KAA8C;CACzE;AASD;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,iBACrB,GAAG,kBACD,OAAO,KACxB,GAyBF,CAAA"}