@wdio/browser-runner 8.29.2 → 8.29.5

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stencil.d.ts","sourceRoot":"","sources":["../../../src/browser/fixtures/stencil.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAKR,kBAAkB,EACrB,MAAM,wBAAwB,CAAA;AAe/B,UAAU,kBAAkB;IACxB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAA;CACvB;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,kBAAkB,GAAG,kBAAkB,CA4HnE;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"}
@@ -8,7 +8,7 @@ process.nextTick = (cb) => setTimeout(cb, 0);
8
8
  window.React = {
9
9
  createElement: h,
10
10
  };
11
- import { bootstrapLazy, flushAll, insertVdomAnnotations, registerComponents, registerModule, renderVdom, setSupportsShadowDom, startAutoApplyChanges, styles, win, writeTask,
11
+ import { bootstrapLazy, flushAll, insertVdomAnnotations, registerComponents, registerModule, renderVdom, setSupportsShadowDom, startAutoApplyChanges, styles, writeTask,
12
12
  // @ts-expect-error
13
13
  } from '@stencil/core/internal/testing/index.js';
14
14
  /**
@@ -20,14 +20,15 @@ export function render(opts) {
20
20
  if (!opts) {
21
21
  throw new Error('NewSpecPageOptions required');
22
22
  }
23
+ const components = opts.components || [];
23
24
  const stencilStage = document.querySelector('stencil-stage');
24
25
  if (stencilStage) {
25
26
  stencilStage.remove();
26
27
  }
27
- const stage = document.createElement('stencil-stage');
28
- document.body.appendChild(stage);
29
- if (Array.isArray(opts.components)) {
30
- registerComponents(opts.components);
28
+ const container = document.createElement('stencil-stage');
29
+ document.body.appendChild(container);
30
+ if (Array.isArray(components)) {
31
+ registerComponents(components);
31
32
  }
32
33
  if (opts.hydrateClientSide) {
33
34
  opts.includeAnnotations = true;
@@ -46,14 +47,7 @@ export function render(opts) {
46
47
  }
47
48
  }
48
49
  const cmpTags = new Set();
49
- const doc = win.document;
50
- const page = {
51
- win: win,
52
- doc: doc,
53
- body: stage,
54
- styles
55
- };
56
- const lazyBundles = opts.components.map((Cstr) => {
50
+ const lazyBundles = components.map((Cstr) => {
57
51
  // eslint-disable-next-line eqeqeq
58
52
  if (Cstr.COMPILER_META == null) {
59
53
  throw new Error('Invalid component class: Missing static "COMPILER_META" property.');
@@ -83,11 +77,16 @@ export function render(opts) {
83
77
  const lazyBundleRuntimeMeta = formatLazyBundleRuntimeMeta(bundleId, [Cstr.COMPILER_META]);
84
78
  return lazyBundleRuntimeMeta;
85
79
  });
80
+ const page = {
81
+ container,
82
+ styles,
83
+ flushAll
84
+ };
86
85
  if (typeof opts.direction === 'string') {
87
- page.doc.documentElement.setAttribute('dir', opts.direction);
86
+ document.documentElement.setAttribute('dir', opts.direction);
88
87
  }
89
88
  if (typeof opts.language === 'string') {
90
- page.doc.documentElement.setAttribute('lang', opts.language);
89
+ document.documentElement.setAttribute('lang', opts.language);
91
90
  }
92
91
  bootstrapLazy(lazyBundles);
93
92
  if (typeof opts.template === 'function') {
@@ -100,7 +99,7 @@ export function render(opts) {
100
99
  $flags$: 0,
101
100
  $modeName$: undefined,
102
101
  $cmpMeta$: cmpMeta,
103
- $hostElement$: page.body,
102
+ $hostElement$: document.body,
104
103
  };
105
104
  renderVdom(ref, opts.template());
106
105
  }
@@ -108,12 +107,12 @@ export function render(opts) {
108
107
  Object.defineProperty(page, 'root', {
109
108
  get() {
110
109
  if (!rootComponent) {
111
- rootComponent = findRootComponent(cmpTags, page.body);
110
+ rootComponent = findRootComponent(cmpTags, document.body);
112
111
  }
113
112
  if (rootComponent) {
114
113
  return rootComponent;
115
114
  }
116
- const firstElementChild = page.body.firstElementChild;
115
+ const firstElementChild = document.body.firstElementChild;
117
116
  if (!firstElementChild) {
118
117
  return firstElementChild;
119
118
  }
@@ -121,13 +120,12 @@ export function render(opts) {
121
120
  },
122
121
  });
123
122
  if (opts.hydrateServerSide) {
124
- insertVdomAnnotations(doc, []);
123
+ insertVdomAnnotations(document, []);
125
124
  }
126
125
  if (opts.autoApplyChanges) {
127
126
  startAutoApplyChanges();
128
127
  }
129
- flushAll();
130
- return { flushAll };
128
+ return page;
131
129
  }
132
130
  /**
133
131
  * A helper method that proxies Stencil lifecycle methods by mutating the provided component class
@@ -1,4 +1,8 @@
1
1
  import type { InlineConfig } from 'vite';
2
2
  export declare function isUsingStencilJS(rootDir: string, options: WebdriverIO.BrowserRunnerOptions): Promise<boolean>;
3
3
  export declare function optimizeForStencil(rootDir: string): Promise<InlineConfig>;
4
+ /**
5
+ * helper method to import a Stencil config file
6
+ */
7
+ export declare function importStencilConfig(rootDir: string): Promise<any>;
4
8
  //# sourceMappingURL=stencil.d.ts.map
@@ -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"}
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"}
@@ -8,7 +8,7 @@ export async function isUsingStencilJS(rootDir, options) {
8
8
  return Boolean(options.preset === 'stencil' || await hasFileByExtensions(path.join(rootDir, 'stencil.config')));
9
9
  }
10
10
  export async function optimizeForStencil(rootDir) {
11
- const stencilConfig = await import(path.join(rootDir, 'stencil.config.ts')).catch(() => ({ config: {} }));
11
+ const stencilConfig = await importStencilConfig(rootDir);
12
12
  const stencilPlugins = stencilConfig.config.plugins;
13
13
  const stencilOptimizations = {
14
14
  plugins: [await stencilVitePlugin(rootDir)],
@@ -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, 'fixtures', 'stencil.js');
33
+ const stencilHelperPath = path.resolve(__dirname, '..', '..', 'browser', 'fixtures', 'stencil.js');
34
34
  return {
35
35
  name: 'wdio-stencil',
36
36
  enforce: 'pre',
@@ -45,7 +45,28 @@ async function stencilVitePlugin(rootDir) {
45
45
  .filter((imp) => imp.specifier === STENCIL_IMPORT)
46
46
  .map((imp) => parseStaticImport(imp));
47
47
  const isStencilComponent = stencilImports.some((imp) => 'Component' in (imp.namedImports || {}));
48
+ /**
49
+ * if file doesn't define a Stencil component
50
+ */
48
51
  if (!isStencilComponent) {
52
+ /**
53
+ * if a test imports the `@wdio/browser-runner/stencil` package we want to automatically
54
+ * import `h` and `Fragment` from the `@stencil/core` package
55
+ */
56
+ const stencilHelperImport = staticImports.find((imp) => imp.specifier === '@wdio/browser-runner/stencil');
57
+ if (stencilHelperImport) {
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
+ 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
+ }
68
+ }
69
+ }
49
70
  return { code };
50
71
  }
51
72
  const tsCompilerOptions = getCompilerOptions(ts, rootDir);
@@ -117,3 +138,18 @@ function getCompilerOptions(ts, rootDir) {
117
138
  _tsCompilerOptions = parseResult.options;
118
139
  return _tsCompilerOptions;
119
140
  }
141
+ /**
142
+ * helper method to import a Stencil config file
143
+ */
144
+ export async function importStencilConfig(rootDir) {
145
+ const configPath = path.join(rootDir, 'stencil.config.ts');
146
+ const config = await import(configPath).catch(() => ({ config: {} }));
147
+ /**
148
+ * if we import the config within a CJS environment we need to
149
+ * access the default property even though there is a named export
150
+ */
151
+ if ('default' in config) {
152
+ return config.default;
153
+ }
154
+ return config;
155
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/browser-runner",
3
- "version": "8.29.2",
3
+ "version": "8.29.5",
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,14 +37,14 @@
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.1",
41
- "@wdio/local-runner": "8.29.2",
40
+ "@wdio/globals": "8.29.3",
41
+ "@wdio/local-runner": "8.29.5",
42
42
  "@wdio/logger": "8.28.0",
43
- "@wdio/mocha-framework": "8.29.1",
43
+ "@wdio/mocha-framework": "8.29.3",
44
44
  "@wdio/protocols": "^8.24.12",
45
- "@wdio/runner": "8.29.2",
45
+ "@wdio/runner": "8.29.5",
46
46
  "@wdio/types": "8.29.1",
47
- "@wdio/utils": "8.29.1",
47
+ "@wdio/utils": "8.29.3",
48
48
  "deepmerge-ts": "^5.0.0",
49
49
  "expect": "^29.7.0",
50
50
  "expect-webdriverio": "^4.9.3",
@@ -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.1",
66
- "webdriverio": "8.29.1"
65
+ "webdriver": "8.29.3",
66
+ "webdriverio": "8.29.3"
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": "96b12554db896984d4c86f3ff1d85da36e04c4f3"
74
+ "gitHead": "35c91fce089a8aff2dc3ec1407d6b91bc5cf0c76"
75
75
  }
@@ -6,7 +6,7 @@ interface RenderOptions {
6
6
  /**
7
7
  * An array of components to test. Component classes can be imported into the spec file, then their reference should be added to the `component` array in order to be used throughout the test.
8
8
  */
9
- components: any[];
9
+ components?: any[];
10
10
  /**
11
11
  * If `false`, do not flush the render queue on initial test setup.
12
12
  */
@@ -65,6 +65,18 @@ interface StencilEnvironment {
65
65
  * wait for, and apply the update, call await `flushAll()`.
66
66
  */
67
67
  flushAll: () => void
68
+ /**
69
+ * All styles defined by components.
70
+ */
71
+ styles: Record<string, string>
72
+ /**
73
+ * Container element in which the template is being rendered.
74
+ */
75
+ container: HTMLElement
76
+ /**
77
+ * The root component of the template.
78
+ */
79
+ root: HTMLElement
68
80
  }
69
81
 
70
82
  export function render(opts: RenderOptions): StencilEnvironment
@@ -1 +0,0 @@
1
- {"version":3,"file":"stencil.d.ts","sourceRoot":"","sources":["../../../../src/vite/frameworks/fixtures/stencil.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAKR,kBAAkB,EACrB,MAAM,wBAAwB,CAAA;AAgB/B,UAAU,kBAAkB;IACxB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAA;CACvB;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,kBAAkB,GAAG,kBAAkB,CA+HnE;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"}