@wdio/browser-runner 8.13.3 → 8.13.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 +1 @@
1
- {"version":3,"file":"mocha.d.ts","sourceRoot":"","sources":["../../../src/browser/frameworks/mocha.ts"],"names":[],"mappings":"AA8BA,qBAAa,cAAe,SAAQ,WAAW;;;IA0B3C,MAAM,KAAK,kBAAkB,aAE5B;IAED,IAAI,IAAI,WAEP;IAED,iBAAiB;IAWjB,wBAAwB,CAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO;IAatE,GAAG,CAAE,MAAM,EAAE,SAAS;CA4H/B"}
1
+ {"version":3,"file":"mocha.d.ts","sourceRoot":"","sources":["../../../src/browser/frameworks/mocha.ts"],"names":[],"mappings":"AA8BA,qBAAa,cAAe,SAAQ,WAAW;;;IA0B3C,MAAM,KAAK,kBAAkB,aAE5B;IAED,IAAI,IAAI,WAEP;IAED,iBAAiB;IAWjB,wBAAwB,CAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO;IAatE,GAAG,CAAE,MAAM,EAAE,SAAS;CAoI/B"}
@@ -119,6 +119,13 @@ export class MochaFramework extends HTMLElement {
119
119
  duration: Date.now() - startTime
120
120
  });
121
121
  });
122
+ /**
123
+ * remove loader animation
124
+ */
125
+ const spinner = this.#root.querySelector('.lds-ring');
126
+ if (spinner) {
127
+ spinner.remove();
128
+ }
122
129
  const runner = mocha.run(async (failures) => {
123
130
  await this.#onFinish(failures);
124
131
  for (const teardownScript of globalTeardownScripts) {
@@ -200,6 +207,43 @@ template.innerHTML = /*html*/ `
200
207
  background-size: 30px;
201
208
  background-position: 15px 20px;
202
209
  }
210
+ .lds-ring {
211
+ display: inline-block;
212
+ position: absolute;
213
+ top: calc(50% - 40px);
214
+ left: calc(50% - 40px);
215
+ width: 80px;
216
+ height: 80px;
217
+ }
218
+ .lds-ring div {
219
+ box-sizing: border-box;
220
+ display: block;
221
+ position: absolute;
222
+ width: 64px;
223
+ height: 64px;
224
+ margin: 8px;
225
+ border: 4px solid #EA5907;
226
+ border-radius: 50%;
227
+ animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
228
+ border-color: #EA5907 transparent transparent transparent;
229
+ }
230
+ .lds-ring div:nth-child(1) {
231
+ animation-delay: -0.45s;
232
+ }
233
+ .lds-ring div:nth-child(2) {
234
+ animation-delay: -0.3s;
235
+ }
236
+ .lds-ring div:nth-child(3) {
237
+ animation-delay: -0.15s;
238
+ }
239
+ @keyframes lds-ring {
240
+ 0% {
241
+ transform: rotate(0deg);
242
+ }
243
+ 100% {
244
+ transform: rotate(360deg);
245
+ }
246
+ }
203
247
  .reporter.minified {
204
248
  width: 65px;
205
249
  }
@@ -255,6 +299,7 @@ template.innerHTML = /*html*/ `
255
299
  </style>
256
300
  <div class="reporter">
257
301
  <div id="mocha"></div>
302
+ <div class="lds-ring"><div></div><div></div><div></div><div></div></div>
258
303
  <button class="btnCollapseExpand">
259
304
  <svg width="50" height="40" viewBox="2 0 32 32" xmlns="http://www.w3.org/2000/svg">
260
305
  <path fill="#fff" d="M13.11 29.113c7.243 0 13.113-5.871 13.113-13.113S20.353 2.887 13.11 2.887C5.868 2.887-.003 8.758-.003 16S5.868 29.113 13.11 29.113zm0-25.177c6.652 0 12.064 5.412 12.064 12.064S19.762 28.064 13.11 28.064C6.457 28.064 1.046 22.652 1.046 16S6.457 3.936 13.11 3.936z"/>
@@ -4,7 +4,7 @@ import type { MockFactoryWithHelper } from '../types';
4
4
  * re-export mock module
5
5
  */
6
6
  export * from '@vitest/spy';
7
- export declare function mock(path: string, factory?: MockFactoryWithHelper): Promise<unknown>;
7
+ export declare function mock(path: string, factory?: MockFactoryWithHelper): Promise<void>;
8
8
  export declare function unmock(moduleName: string): void;
9
9
  /**
10
10
  * utility helper for type conversions
@@ -1 +1 @@
1
- {"version":3,"file":"spy.d.ts","sourceRoot":"","sources":["../../src/browser/spy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAGrD;;GAEG;AACH,cAAc,aAAa,CAAA;AAY3B,wBAAsB,IAAI,CAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,oBA6BxE;AAGD,wBAAgB,MAAM,CAAC,UAAU,EAAE,MAAM,QAExC;AAeD;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,kBAA0C"}
1
+ {"version":3,"file":"spy.d.ts","sourceRoot":"","sources":["../../src/browser/spy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAErD;;GAEG;AACH,cAAc,aAAa,CAAA;AAS3B,wBAAsB,IAAI,CAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,iBA2BxE;AAGD,wBAAgB,MAAM,CAAC,UAAU,EAAE,MAAM,QAExC;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,kBAA0C"}
@@ -1,4 +1,3 @@
1
- import { MESSAGE_TYPES } from '../constants.js';
2
1
  /**
3
2
  * re-export mock module
4
3
  */
@@ -9,29 +8,26 @@ function resolveUrl(path) {
9
8
  return a.href;
10
9
  }
11
10
  const ERROR_MESSAGE = '[wdio] There was an error, when mocking a module. If you are using the "mock" factory, make sure there are no top level variables inside, since this call is hoisted to top of the file. Read more: https://webdriver.io/docs/component-testing/mocking';
12
- const socket = window.__wdioSocket__;
13
- const mockResolver = new Map();
14
- const origin = window.__wdioSpec__.split('/').slice(0, -1).join('/');
15
11
  export async function mock(path, factory) {
16
12
  /**
17
13
  * mock calls without factory parameter should get removed from the source code
18
14
  * by the mock hoisting plugin
19
15
  */
20
- if (!factory) {
16
+ if (!factory || typeof factory !== 'function') {
21
17
  return;
22
18
  }
19
+ /**
20
+ * parameter is added by hoisting plugin if factory comes with a parameter
21
+ */
22
+ const actualImport = arguments[2];
23
23
  const mockLocalFile = path.startsWith('/') || path.startsWith('./') || path.startsWith('../');
24
24
  const mockPath = mockLocalFile
25
- ? (new URL(resolveUrl(window.__wdioSpec__.split('/').slice(0, -1).join('/') + '/' + path))).pathname
25
+ // use absolute path for local files without extension
26
+ ? (new URL(resolveUrl(window.__wdioSpec__.split('/').slice(0, -1).join('/') + '/' + path))).pathname.replace(/\.[^/.]+$/, '')
26
27
  : path;
27
28
  try {
28
- const resolvedMock = await factory(() => (import(mockLocalFile ? `/@mock${mockPath}` : `/node_modules/.vite/deps/${mockPath.replace('/', '_')}.js`)));
29
- socket.send(JSON.stringify({
30
- type: MESSAGE_TYPES.mockRequest,
31
- value: { path: mockPath, origin, namedExports: Object.keys(resolvedMock) }
32
- }));
29
+ const resolvedMock = await factory(actualImport);
33
30
  window.__wdioMockCache__.set(mockPath, resolvedMock);
34
- return new Promise((resolve) => mockResolver.set(mockPath, resolve));
35
31
  }
36
32
  catch (err) {
37
33
  const error = err;
@@ -42,19 +38,6 @@ export async function mock(path, factory) {
42
38
  export function unmock(moduleName) {
43
39
  // NO-OP: call gets removed by recast
44
40
  }
45
- socket.addEventListener('message', (ev) => {
46
- try {
47
- const { type, value } = JSON.parse(ev.data);
48
- const resolver = mockResolver.get(value.path);
49
- if (type !== MESSAGE_TYPES.mockResponse || !resolver) {
50
- return;
51
- }
52
- return resolver(null);
53
- }
54
- catch {
55
- // ignore
56
- }
57
- });
58
41
  /**
59
42
  * utility helper for type conversions
60
43
  */
@@ -20,9 +20,7 @@ export declare enum MESSAGE_TYPES {
20
20
  commandRequestMessage = 1,
21
21
  commandResponseMessage = 2,
22
22
  hookTriggerMessage = 3,
23
- hookResultMessage = 4,
24
- mockRequest = 5,
25
- mockResponse = 6
23
+ hookResultMessage = 4
26
24
  }
27
25
  export declare const DEFAULT_INCLUDE: string[];
28
26
  export declare const DEFAULT_FILE_EXTENSIONS: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,eAAO,MAAM,QAAQ,0BAAiC,CAAA;AACtD,eAAO,MAAM,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAa,CAAA;AAEvE,eAAO,MAAM,MAAM;;;;;;;;;;;CAWT,CAAA;AAEV,eAAO,MAAM,uBAAuB,wFAAsF,CAAA;AAE1H,oBAAY,aAAa;IACrB,cAAc,IAAI;IAClB,qBAAqB,IAAA;IACrB,sBAAsB,IAAA;IACtB,kBAAkB,IAAA;IAClB,iBAAiB,IAAA;IACjB,WAAW,IAAA;IACX,YAAY,IAAA;CACf;AAED,eAAO,MAAM,eAAe,UAAS,CAAA;AACrC,eAAO,MAAM,uBAAuB,UAAoF,CAAA;AACxH,eAAO,MAAM,yBAAyB,aAAa,CAAA;AACnD,eAAO,MAAM,gBAAgB,OAAO,CAAA;AACpC,eAAO,MAAM,sBAAsB,cAAc,CAAA;AACjD,eAAO,MAAM,gBAAgB,iBAAiB,CAAA;AAC9C,eAAO,MAAM,gBAAgB,2DAA4D,CAAA;AACzF,eAAO,MAAM,wBAAwB,EAAE,CAAC,MAAM,aAAa,CAAC,EAAiD,CAAA;AAC7G,eAAO,MAAM,yBAAyB,sEAAsE,CAAA;AAC5G,eAAO,MAAM,uBAAuB,sEAAsE,CAAA;AAE1G,eAAO,MAAM,eAAe,irEA+D3B,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,eAAO,MAAM,QAAQ,0BAAiC,CAAA;AACtD,eAAO,MAAM,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAa,CAAA;AAEvE,eAAO,MAAM,MAAM;;;;;;;;;;;CAWT,CAAA;AAEV,eAAO,MAAM,uBAAuB,wFAAsF,CAAA;AAE1H,oBAAY,aAAa;IACrB,cAAc,IAAI;IAClB,qBAAqB,IAAA;IACrB,sBAAsB,IAAA;IACtB,kBAAkB,IAAA;IAClB,iBAAiB,IAAA;CACpB;AAED,eAAO,MAAM,eAAe,UAAS,CAAA;AACrC,eAAO,MAAM,uBAAuB,UAAoF,CAAA;AACxH,eAAO,MAAM,yBAAyB,aAAa,CAAA;AACnD,eAAO,MAAM,gBAAgB,OAAO,CAAA;AACpC,eAAO,MAAM,sBAAsB,cAAc,CAAA;AACjD,eAAO,MAAM,gBAAgB,iBAAiB,CAAA;AAC9C,eAAO,MAAM,gBAAgB,2DAA4D,CAAA;AACzF,eAAO,MAAM,wBAAwB,EAAE,CAAC,MAAM,aAAa,CAAC,EAAiD,CAAA;AAC7G,eAAO,MAAM,yBAAyB,sEAAsE,CAAA;AAC5G,eAAO,MAAM,uBAAuB,sEAAsE,CAAA;AAE1G,eAAO,MAAM,eAAe,irEA+D3B,CAAA"}
@@ -20,8 +20,6 @@ export var MESSAGE_TYPES;
20
20
  MESSAGE_TYPES[MESSAGE_TYPES["commandResponseMessage"] = 2] = "commandResponseMessage";
21
21
  MESSAGE_TYPES[MESSAGE_TYPES["hookTriggerMessage"] = 3] = "hookTriggerMessage";
22
22
  MESSAGE_TYPES[MESSAGE_TYPES["hookResultMessage"] = 4] = "hookResultMessage";
23
- MESSAGE_TYPES[MESSAGE_TYPES["mockRequest"] = 5] = "mockRequest";
24
- MESSAGE_TYPES[MESSAGE_TYPES["mockResponse"] = 6] = "mockResponse";
25
23
  })(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
26
24
  export const DEFAULT_INCLUDE = ['**'];
27
25
  export const DEFAULT_FILE_EXTENSIONS = ['.js', '.cjs', '.mjs', '.ts', '.mts', '.cts', '.tsx', '.jsx', '.vue', '.svelte'];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAO5C,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAS/G,OAAO,KAAK,EAAE,oBAAoB,IAAI,0BAA0B,EAAmB,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAK5H,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;;IAW9C,OAAO,CAAC,OAAO;IACf,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU;IAJzC,OAAO,CAAC,aAAa,CAAoB;gBAG7B,OAAO,EAAE,0BAA0B,EACjC,OAAO,EAAE,OAAO,CAAC,UAAU;IAuBzC;;OAEG;IACG,UAAU;IAaV,GAAG,CAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC;IAgCrD;;;;OAIG;IACG,QAAQ;YAgDA,wBAAwB;CA2DzC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,WAAW,CAAC;QAClB,UAAU,oBAAqB,SAAQ,0BAA0B;SAAG;KACvE;CACJ;AAED;;GAEG;AACH,cAAc,aAAa,CAAA;AAE3B;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AAEH,wBAAgB,IAAI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C,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,eAAe,CAAC,CAAC,CAAC,CAAA;AACpE,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE;IACxC,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,IAAI,CAAC,EAAE,KAAK,CAAC;CAChB,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AACnB,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE;IACxC,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,IAAI,EAAE,IAAI,CAAC;CACd,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;AACvB,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE;IACxC,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,CAAC,EAAE,KAAK,CAAC;CAChB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;AAC5B,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE;IACxC,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,IAAI,CAAC;CACd,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAA"}
package/build/index.js CHANGED
@@ -10,7 +10,7 @@ import libSourceMap from 'istanbul-lib-source-maps';
10
10
  import reports from 'istanbul-reports';
11
11
  import { ViteServer } from './vite/server.js';
12
12
  import { FRAMEWORK_SUPPORT_ERROR, SESSIONS, BROWSER_POOL, DEFAULT_COVERAGE_REPORTS, SUMMARY_REPORTER, DEFAULT_REPORTS_DIRECTORY } from './constants.js';
13
- import { makeHeadless, getCoverageByFactor } from './utils.js';
13
+ import { makeHeadless, getCoverageByFactor, adjustWindowInWatchMode } from './utils.js';
14
14
  const log = logger('@wdio/browser-runner');
15
15
  export default class BrowserRunner extends LocalRunner {
16
16
  options;
@@ -58,6 +58,7 @@ export default class BrowserRunner extends LocalRunner {
58
58
  }
59
59
  async run(runArgs) {
60
60
  runArgs.caps = makeHeadless(this.options, runArgs.caps);
61
+ runArgs.caps = adjustWindowInWatchMode(this.#config, runArgs.caps);
61
62
  const server = new ViteServer(this.#options, this.#config);
62
63
  try {
63
64
  await server.start();
package/build/utils.d.ts CHANGED
@@ -1,7 +1,11 @@
1
- import type { Capabilities } from '@wdio/types';
1
+ import type { Capabilities, Options } from '@wdio/types';
2
2
  import type { CoverageSummary } from 'istanbul-lib-coverage';
3
3
  import { COVERAGE_FACTORS } from './constants.js';
4
4
  import type { BrowserRunnerOptions, CoverageOptions } from './types.js';
5
5
  export declare function makeHeadless(options: BrowserRunnerOptions, caps: Capabilities.RemoteCapability): Capabilities.RemoteCapability;
6
+ /**
7
+ * Open with devtools open when in watch mode
8
+ */
9
+ export declare function adjustWindowInWatchMode(config: Options.Testrunner, caps: Capabilities.RemoteCapability): Capabilities.RemoteCapability;
6
10
  export declare function getCoverageByFactor(options: Partial<CoverageOptions>, summary: Pick<CoverageSummary, (typeof COVERAGE_FACTORS)[number]>, fileName?: string): string[];
7
11
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,OAAO,EAAE,gBAAgB,EAAsD,MAAM,gBAAgB,CAAA;AACrG,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIvE,wBAAgB,YAAY,CAAE,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,YAAY,CAAC,gBAAgB,GAAG,YAAY,CAAC,gBAAgB,CA0C/H;AAED,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,EACjC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,EACjE,QAAQ,CAAC,EAAE,MAAM,YAepB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,OAAO,EAAE,gBAAgB,EAAsD,MAAM,gBAAgB,CAAA;AACrG,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIvE,wBAAgB,YAAY,CAAE,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,YAAY,CAAC,gBAAgB,GAAG,YAAY,CAAC,gBAAgB,CA0C/H;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAE,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE,IAAI,EAAE,YAAY,CAAC,gBAAgB,GAAG,YAAY,CAAC,gBAAgB,CA0BvI;AAED,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,EACjC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,EACjE,QAAQ,CAAC,EAAE,MAAM,YAepB"}
package/build/utils.js CHANGED
@@ -42,6 +42,34 @@ export function makeHeadless(options, caps) {
42
42
  log.error(`Headless mode not supported for browser "${capability.browserName}"`);
43
43
  return caps;
44
44
  }
45
+ /**
46
+ * Open with devtools open when in watch mode
47
+ */
48
+ export function adjustWindowInWatchMode(config, caps) {
49
+ if (!config.watch) {
50
+ return caps;
51
+ }
52
+ const capability = caps.alwaysMatch || caps;
53
+ if (config.watch && capability.browserName === 'chrome') {
54
+ return deepmerge(capability, {
55
+ 'goog:chromeOptions': {
56
+ args: ['auto-open-devtools-for-tabs', 'window-size=1600,1200'],
57
+ prefs: {
58
+ devtools: {
59
+ preferences: {
60
+ 'panel-selectedTab': '"console"'
61
+ }
62
+ }
63
+ }
64
+ }
65
+ });
66
+ }
67
+ /**
68
+ * TODO: add support for other browsers (if possible)
69
+ * } else if (...) { }
70
+ */
71
+ return caps;
72
+ }
45
73
  export function getCoverageByFactor(options, summary, fileName) {
46
74
  return COVERAGE_FACTORS.map((factor) => {
47
75
  const treshold = options[factor];
@@ -5,7 +5,6 @@ export declare class MockHandler {
5
5
  manualMocks: string[];
6
6
  constructor(options: WebdriverIO.BrowserRunnerOptions, config: Options.Testrunner);
7
7
  get mocks(): Map<string, MockRequestEvent>;
8
- addMock(mock: MockRequestEvent): void;
9
8
  unmock(moduleName: string): void;
10
9
  resolveId(id: string): Promise<string | undefined>;
11
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/vite/mock.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAI1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,qBAAa,WAAW;;IAOpB,WAAW,EAAE,MAAM,EAAE,CAAK;gBAEb,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU;IAMlF,IAAI,KAAK,kCAER;IAED,OAAO,CAAE,IAAI,EAAE,gBAAgB;IAI/B,MAAM,CAAE,UAAU,EAAE,MAAM;IAIpB,SAAS,CAAE,EAAE,EAAE,MAAM;IAwB3B;;OAEG;IACH,UAAU;CAIb"}
1
+ {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/vite/mock.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAI1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,qBAAa,WAAW;;IAOpB,WAAW,EAAE,MAAM,EAAE,CAAK;gBAEb,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU;IAMlF,IAAI,KAAK,kCAER;IAED,MAAM,CAAE,UAAU,EAAE,MAAM;IAIpB,SAAS,CAAE,EAAE,EAAE,MAAM;IAwB3B;;OAEG;IACH,UAAU;CAIb"}
@@ -17,9 +17,6 @@ export class MockHandler {
17
17
  get mocks() {
18
18
  return this.#mocks;
19
19
  }
20
- addMock(mock) {
21
- this.#mocks.set(mock.path, mock);
22
- }
23
20
  unmock(moduleName) {
24
21
  this.#unmocked.push(moduleName);
25
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mockHoisting.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/mockHoisting.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAU7C,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,EAAE,CA2T/D"}
1
+ {"version":3,"file":"mockHoisting.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/mockHoisting.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAU7C,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,EAAE,CAwU/D"}
@@ -16,6 +16,7 @@ export function mockHoisting(mockHandler) {
16
16
  let spec = null;
17
17
  let isTestDependency = false;
18
18
  const sessionMocks = new Set();
19
+ const importMap = new Map();
19
20
  return [{
20
21
  name: 'wdio:mockHoisting:pre',
21
22
  enforce: 'pre',
@@ -31,35 +32,6 @@ export function mockHoisting(mockHandler) {
31
32
  return '';
32
33
  }
33
34
  }
34
- const mocks = [...mockHandler.mocks.values()];
35
- const preBundledDepName = path.basename(id).split('?')[0];
36
- const mockedMod = (
37
- // mocked file
38
- mockHandler.mocks.get(os.platform() === 'win32' ? `/${id}` : id) ||
39
- // mocked dependency
40
- mockHandler.mocks.get(path.basename(id, path.extname(id))) ||
41
- // pre-bundled deps e.g. /node_modules/.vite/deps/algoliasearch_lite.js?v=e31c24e
42
- mocks.find((mock) => `${mock.path.replace('/', '_')}.js` === preBundledDepName) ||
43
- // relative file imports ignoring file extension, e.g. `mock('../../constants.ts', () => { ... })`
44
- mocks.find((mock) => {
45
- const mockFileExtLength = path.extname(mock.path).length;
46
- const toCompare = mockFileExtLength > 0 ? mock.path.slice(0, -mockFileExtLength) : mock.path;
47
- // compare without file extension as we don't know if users use them or not
48
- return toCompare === id.slice(0, -path.extname(id).length);
49
- }));
50
- if (mockedMod) {
51
- const newCode = mockedMod.namedExports.map((ne) => {
52
- if (ne === 'default') {
53
- return /*js*/ `export default window.__wdioMockCache__.get('${mockedMod.path}').default;`;
54
- }
55
- return /*js*/ `export const ${ne} = window.__wdioMockCache__.get('${mockedMod.path}')['${ne}'];`;
56
- });
57
- if (!mockedMod.namedExports.includes('default')) {
58
- newCode.push(/*js*/ `export default window.__wdioMockCache__.get('${mockedMod.path}');`);
59
- }
60
- log.debug(`Resolve mock for module "${mockedMod.path}"`);
61
- return newCode.join('\n');
62
- }
63
35
  }
64
36
  }, {
65
37
  name: 'wdio:mockHoisting',
@@ -70,69 +42,140 @@ export function mockHoisting(mockHandler) {
70
42
  isTestDependency = true;
71
43
  }
72
44
  /**
73
- * only transform files that are loaded as part of the test and are not
74
- * Vite or WebdriverIO internals
45
+ * only transform files:
75
46
  */
76
- if (!isTestDependency || INTERNALS_TO_IGNORE.find((f) => id.includes(f))) {
47
+ if (
48
+ // where loading was inititated through the test file
49
+ !isTestDependency ||
50
+ // are not Vite or WebdriverIO internals
51
+ INTERNALS_TO_IGNORE.find((f) => id.includes(f)) ||
52
+ // when the spec file is actually mocking any dependencies
53
+ (!isSpecFile && sessionMocks.size === 0)) {
77
54
  return { code };
78
55
  }
79
56
  let ast;
57
+ const start = Date.now();
80
58
  try {
81
59
  ast = parse(code, {
82
60
  parser: typescriptParser,
83
61
  sourceFileName: id,
84
62
  sourceRoot: path.dirname(id)
85
63
  });
64
+ log.trace(`Parsed file for mocking: ${id} in ${Date.now() - start}ms`);
86
65
  }
87
66
  catch (err) {
88
67
  return { code };
89
68
  }
90
- log.trace(`Transform file for mocking: ${id}`);
91
69
  let importIndex = 0;
92
70
  let mockFunctionName;
93
71
  let unmockFunctionName;
94
72
  const mockCalls = [];
95
- /**
96
- * rewrite import statements into variable declarations, e.g. from
97
- *
98
- * import React, { RC } from 'react'
99
- *
100
- * to
101
- *
102
- * var { default: React, RC: RC } = await import("react")
103
- *
104
- * so we can hoist the mock call
105
- */
106
73
  visit(ast, {
74
+ /**
75
+ * find function name for mock and unmock calls
76
+ */
107
77
  visitImportDeclaration: function (path) {
108
78
  const dec = path.value;
109
79
  const source = dec.source.value;
110
- if (!dec.specifiers || dec.specifiers.length === 0) {
80
+ if (!dec.specifiers || dec.specifiers.length === 0 || source !== '@wdio/browser-runner') {
111
81
  return this.traverse(path);
112
82
  }
113
83
  /**
114
84
  * get name of mock function variable
115
85
  */
116
- if (source === '@wdio/browser-runner') {
117
- const mockSpecifier = dec.specifiers
118
- .filter((s) => s.type === types.namedTypes.ImportSpecifier.toString())
119
- .find((s) => s.imported.name === 'mock');
120
- if (mockSpecifier && mockSpecifier.local) {
121
- mockFunctionName = mockSpecifier.local.name;
86
+ const mockSpecifier = dec.specifiers
87
+ .filter((s) => s.type === types.namedTypes.ImportSpecifier.toString())
88
+ .find((s) => s.imported.name === 'mock');
89
+ if (mockSpecifier && mockSpecifier.local) {
90
+ mockFunctionName = mockSpecifier.local.name;
91
+ }
92
+ const unmockSpecifier = dec.specifiers
93
+ .filter((s) => s.type === types.namedTypes.ImportSpecifier.toString())
94
+ .find((s) => s.imported.name === 'unmock');
95
+ if (unmockSpecifier && unmockSpecifier.local) {
96
+ unmockFunctionName = unmockSpecifier.local.name;
97
+ }
98
+ mockCalls.push(dec);
99
+ path.prune();
100
+ return this.traverse(path);
101
+ },
102
+ /**
103
+ * detect which modules are supposed to be mocked
104
+ */
105
+ ...(isSpecFile ? {
106
+ visitExpressionStatement: function (path) {
107
+ const exp = path.value;
108
+ if (exp.expression.type !== types.namedTypes.CallExpression.toString()) {
109
+ return this.traverse(path);
122
110
  }
123
- const unmockSpecifier = dec.specifiers
124
- .filter((s) => s.type === types.namedTypes.ImportSpecifier.toString())
125
- .find((s) => s.imported.name === 'unmock');
126
- if (unmockSpecifier && unmockSpecifier.local) {
127
- unmockFunctionName = unmockSpecifier.local.name;
111
+ const callExp = exp.expression;
112
+ const isUnmockCall = unmockFunctionName && callExp.callee.name === unmockFunctionName;
113
+ const isMockCall = mockFunctionName && callExp.callee.name === mockFunctionName;
114
+ if (!isMockCall && !isUnmockCall) {
115
+ return this.traverse(path);
116
+ }
117
+ /**
118
+ * hoist unmock calls
119
+ */
120
+ if (isUnmockCall && callExp.arguments[0] && typeof callExp.arguments[0].value === 'string') {
121
+ mockHandler.unmock(callExp.arguments[0].value);
122
+ }
123
+ else if (isMockCall) {
124
+ /**
125
+ * if only one mock argument is set, we take the fixture from the automock directory
126
+ */
127
+ const mockCall = exp.expression;
128
+ if (mockCall.arguments.length === 1) {
129
+ /**
130
+ * enable manual mock
131
+ */
132
+ mockHandler.manualMocks.push(mockCall.arguments[0].value);
133
+ }
134
+ else {
135
+ if (exp.expression.arguments.length) {
136
+ sessionMocks.add(exp.expression.arguments[0].value);
137
+ }
138
+ /**
139
+ * hoist mock calls
140
+ */
141
+ mockCalls.push(exp);
142
+ }
128
143
  }
129
- mockCalls.push(dec);
130
144
  path.prune();
131
- return this.traverse(path);
145
+ this.traverse(path);
146
+ }
147
+ } : {})
148
+ });
149
+ visit(ast, {
150
+ /**
151
+ * rewrite import statements
152
+ */
153
+ visitImportDeclaration: function (nodePath) {
154
+ const dec = nodePath.value;
155
+ const source = dec.source.value;
156
+ if (!dec.specifiers || dec.specifiers.length === 0) {
157
+ return this.traverse(nodePath);
132
158
  }
133
159
  const newImportIdentifier = `__wdio_import${importIndex++}`;
160
+ const isMockedModule = Boolean(
161
+ // matches if a dependency is mocked
162
+ sessionMocks.has(source) ||
163
+ // matches if a relative file is mocked
164
+ (source.startsWith('.') &&
165
+ [...sessionMocks.values()].find((m) => {
166
+ const fileImportPath = path.resolve(path.dirname(id), source);
167
+ const testMockPath = path.resolve(path.dirname(spec || '/'), m);
168
+ return fileImportPath.slice(0, path.extname(fileImportPath).length * -1) === testMockPath.slice(0, path.extname(testMockPath).length * -1);
169
+ })));
134
170
  /**
135
- * assign imports outside of spec files into custom import identifier, e.g.
171
+ * add to import map if module is mocked and imported in the test file
172
+ */
173
+ if (isMockedModule && isSpecFile) {
174
+ importMap.set(source, newImportIdentifier);
175
+ }
176
+ /**
177
+ * Assign imports outside of spec files or when module gets mocked
178
+ * into custom import identifier, e.g.
136
179
  *
137
180
  * from:
138
181
  * import { foo } from 'bar'
@@ -140,12 +183,15 @@ export function mockHoisting(mockHandler) {
140
183
  * to:
141
184
  * import * as __wdio_import0 from 'bar'
142
185
  */
143
- if (!isSpecFile) {
186
+ if (!isSpecFile || isMockedModule) {
144
187
  const newNode = b.importDeclaration([b.importNamespaceSpecifier(b.identifier(newImportIdentifier))], b.literal(source));
145
- path.insertBefore(newNode);
188
+ nodePath.insertBefore(newNode);
146
189
  }
190
+ const wdioImportModuleIdentifier = source.startsWith('.')
191
+ ? url.pathToFileURL(path.resolve(path.dirname(id), source).slice(0, path.extname(source).length * -1)).pathname
192
+ : source;
147
193
  const isNamespaceImport = dec.specifiers.length === 1 && dec.specifiers[0].type === types.namedTypes.ImportNamespaceSpecifier.toString();
148
- const mockImport = isSpecFile
194
+ const mockImport = isSpecFile && !isMockedModule
149
195
  /**
150
196
  * within spec files we transform import declarations into import expresssions, e.g.
151
197
  * from: import { foo } from 'bar'
@@ -171,15 +217,7 @@ export function mockHoisting(mockHandler) {
171
217
  return b.property('init', b.identifier('default'), b.identifier(s.local.name));
172
218
  }
173
219
  return b.property('init', b.identifier(s.imported.name), b.identifier(s.local.name));
174
- })), b.callExpression(
175
- /**
176
- * wrap imports into a custom function that allows us to replace the actual
177
- * module with the mocked module
178
- */
179
- b.identifier('wdioImport'), [
180
- b.literal(source),
181
- b.awaitExpression(b.importExpression(b.literal(source)))
182
- ]))
220
+ })), b.awaitExpression(b.importExpression(b.literal(source))))
183
221
  ])
184
222
  /**
185
223
  * outside of spec files we transform import declarations so that the imported module gets
@@ -201,74 +239,47 @@ export function mockHoisting(mockHandler) {
201
239
  }
202
240
  return b.property('init', b.identifier(s.imported.name), b.identifier(s.local.name));
203
241
  })), b.callExpression(b.identifier('wdioImport'), [
204
- b.literal(source),
242
+ b.literal(wdioImportModuleIdentifier),
205
243
  b.identifier(newImportIdentifier)
206
244
  ]))
207
245
  ]);
208
- path.replace(mockImport);
209
- this.traverse(path);
210
- },
211
- /**
212
- * only run the following visitor if we deal with a spec file
213
- */
214
- ...(isSpecFile ? {
215
- visitExpressionStatement: function (path) {
216
- const exp = path.value;
217
- if (exp.expression.type !== types.namedTypes.CallExpression.toString()) {
218
- return this.traverse(path);
219
- }
220
- const callExp = exp.expression;
221
- const isUnmockCall = unmockFunctionName && callExp.callee.name === unmockFunctionName;
222
- const isMockCall = mockFunctionName && callExp.callee.name === mockFunctionName;
223
- if (!isMockCall && !isUnmockCall) {
224
- return this.traverse(path);
225
- }
226
- /**
227
- * hoist unmock calls
228
- */
229
- if (isUnmockCall && callExp.arguments[0] && typeof callExp.arguments[0].value === 'string') {
230
- mockHandler.unmock(callExp.arguments[0].value);
231
- }
232
- else if (isMockCall) {
233
- /**
234
- * if only one mock argument is set, we take the fixture from the automock directory
235
- */
236
- const mockCall = exp.expression;
237
- if (mockCall.arguments.length === 1) {
238
- /**
239
- * enable manual mock
240
- */
241
- mockHandler.manualMocks.push(mockCall.arguments[0].value);
242
- }
243
- else {
244
- if (exp.expression.arguments.length) {
245
- sessionMocks.add(exp.expression.arguments[0].value);
246
- }
247
- /**
248
- * hoist mock calls
249
- */
250
- mockCalls.push(exp);
251
- }
252
- }
253
- path.prune();
254
- this.traverse(path);
255
- }
256
- } : {})
246
+ nodePath.replace(mockImport);
247
+ this.traverse(nodePath);
248
+ }
257
249
  });
258
250
  ast.program.body.unshift(...mockCalls.map((mc) => {
259
251
  const exp = mc;
260
252
  if (exp.expression && exp.expression.type === types.namedTypes.CallExpression.toString()) {
261
- return b.expressionStatement(b.awaitExpression(exp.expression));
253
+ const mockCallExpression = exp.expression;
254
+ const mockedModule = mockCallExpression.arguments[0].value;
255
+ const mockFactory = mockCallExpression.arguments[1];
256
+ /**
257
+ * add actual module as 3rd parameter to the mock call if imported in the same test file
258
+ */
259
+ if (importMap.has(mockedModule)) {
260
+ mockCallExpression.arguments.push(b.identifier(importMap.get(mockedModule)));
261
+ }
262
+ else if (mockFactory.params.length > 0) {
263
+ /**
264
+ * `importMap` only has an entry if the module is imported in the same test file.
265
+ * However if the user mocks a dependency of a different dependency we need to add
266
+ * the import manually if the users wants to access the original module.
267
+ */
268
+ const newImportIdentifier = `__wdio_import${importIndex++}`;
269
+ ast.program.body.unshift(b.importDeclaration([b.importNamespaceSpecifier(b.identifier(newImportIdentifier))], b.literal(mockedModule)));
270
+ mockCallExpression.arguments.push(b.identifier(newImportIdentifier));
271
+ }
272
+ return b.expressionStatement(b.awaitExpression(mockCallExpression));
262
273
  }
263
274
  return mc;
264
275
  }));
265
276
  try {
266
- const newCode = print(ast, {
267
- sourceMapName: id
268
- });
277
+ const newCode = print(ast, { sourceMapName: id });
278
+ log.trace(`Transformed file for mocking: ${id} in ${Date.now() - start}ms`);
269
279
  return newCode;
270
280
  }
271
281
  catch (err) {
282
+ log.trace(`Failed to transformed file (${id}) for mocking: ${err.stack}`);
272
283
  return { code };
273
284
  }
274
285
  },
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/vite/server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAM1C,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAGpC,OAAO,KAAK,EAAiB,YAAY,EAAa,MAAM,MAAM,CAAA;AAGlE,OAAO,KAAK,EAAY,OAAO,EAAE,MAAM,aAAa,CAAA;AAQpD,OAAO,KAAK,EACM,gBAAgB,EAEjC,MAAM,YAAY,CAAA;AAgBnB,qBAAa,UAAW,SAAQ,YAAY;;IAUxC,IAAI,YAAY,gCAEf;IAED,IAAI,MAAM,0BAET;gBAEY,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU;IAyB5E,KAAK;IAsDL,KAAK;IAkJX,OAAO,CAAC,cAAc;IAetB,WAAW,CAAE,MAAM,EAAE,gBAAgB;CAUxC"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/vite/server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAM1C,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAGpC,OAAO,KAAK,EAAiB,YAAY,EAAa,MAAM,MAAM,CAAA;AAGlE,OAAO,KAAK,EAAY,OAAO,EAAE,MAAM,aAAa,CAAA;AAQpD,OAAO,KAAK,EACM,gBAAgB,EAEjC,MAAM,YAAY,CAAA;AAgBnB,qBAAa,UAAW,SAAQ,YAAY;;IAUxC,IAAI,YAAY,gCAEf;IAED,IAAI,MAAM,0BAET;gBAEY,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU;IA2B5E,KAAK;IAsDL,KAAK;IA2IX,OAAO,CAAC,cAAc;IAetB,WAAW,CAAE,MAAM,EAAE,gBAAgB;CAUxC"}
@@ -41,8 +41,9 @@ export class ViteServer extends EventEmitter {
41
41
  this.#options = options;
42
42
  this.#config = config;
43
43
  this.#mockHandler = new MockHandler(options, config);
44
+ const root = options.rootDir || config.rootDir || process.cwd();
44
45
  this.#viteConfig = deepmerge(DEFAULT_VITE_CONFIG, {
45
- root: options.rootDir || process.cwd(),
46
+ root,
46
47
  plugins: [
47
48
  testrunner(options),
48
49
  mockHoisting(this.#mockHandler)
@@ -129,13 +130,6 @@ export class ViteServer extends EventEmitter {
129
130
  if (payload.type === MESSAGE_TYPES.commandRequestMessage) {
130
131
  return this.#handleCommand(ws, payload.value);
131
132
  }
132
- if (payload.type === MESSAGE_TYPES.mockRequest) {
133
- this.#mockHandler.addMock(payload.value);
134
- return ws.send(JSON.stringify({
135
- type: MESSAGE_TYPES.mockResponse,
136
- value: payload.value
137
- }));
138
- }
139
133
  throw new Error(`Unknown socket message ${JSON.stringify(payload)}`);
140
134
  }
141
135
  catch (err) {
@@ -10,8 +10,6 @@ export type SocketMessageValue = {
10
10
  [MESSAGE_TYPES.commandResponseMessage]: CommandResponseEvent;
11
11
  [MESSAGE_TYPES.hookTriggerMessage]: HookTriggerEvent;
12
12
  [MESSAGE_TYPES.hookResultMessage]: HookResultEvent;
13
- [MESSAGE_TYPES.mockRequest]: MockRequestEvent;
14
- [MESSAGE_TYPES.mockResponse]: MockResponseEvent;
15
13
  };
16
14
  export type SocketMessagePayload<T extends MESSAGE_TYPES> = T extends any ? SocketMessagePayloadType<T> : never;
17
15
  export type SocketMessage = SocketMessagePayload<MESSAGE_TYPES>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/vite/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,UAAU,wBAAwB,CAAC,CAAC,SAAS,aAAa;IACtD,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAA;CAC/B;AAED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AAc,CAAA;IACpB,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAA;IACjD,IAAI,EAAE,OAAO,EAAE,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;CACd;AAED,UAAU,2BAA2B;IACjC,EAAE,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,gBAAiB,SAAQ,2BAA2B;IACjE,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,EAAE,CAAA;CAClB;AAED,MAAM,WAAW,eAAgB,SAAQ,2BAA2B;IAChE,KAAK,CAAC,EAAE,WAAW,CAAA;CACtB;AAED,MAAM,WAAW,mBAAoB,SAAQ,2BAA2B;IACpE,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,OAAO,EAAE,CAAA;CAClB;AAED,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,WAAW,CAAA;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,EAAE,CAAA;CACzB;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAA;CACf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/browser-runner",
3
- "version": "8.13.3",
3
+ "version": "8.13.6",
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",
@@ -35,8 +35,8 @@
35
35
  "@types/istanbul-lib-source-maps": "^4.0.1",
36
36
  "@types/node": "^20.1.0",
37
37
  "@vitest/spy": "^0.33.0",
38
- "@wdio/globals": "8.13.3",
39
- "@wdio/local-runner": "8.13.3",
38
+ "@wdio/globals": "8.13.4",
39
+ "@wdio/local-runner": "8.13.4",
40
40
  "@wdio/logger": "8.11.0",
41
41
  "@wdio/mocha-framework": "8.12.1",
42
42
  "@wdio/protocols": "8.11.0",
@@ -60,7 +60,7 @@
60
60
  "vite-plugin-istanbul": "^4.0.1",
61
61
  "vite-plugin-top-level-await": "^1.3.0",
62
62
  "webdriver": "8.13.1",
63
- "webdriverio": "8.13.3",
63
+ "webdriverio": "8.13.4",
64
64
  "ws": "^8.13.0"
65
65
  },
66
66
  "scripts": {
@@ -71,7 +71,7 @@
71
71
  },
72
72
  "devDependencies": {
73
73
  "@types/ws": "^8.5.4",
74
- "@wdio/runner": "8.13.3"
74
+ "@wdio/runner": "8.13.4"
75
75
  },
76
- "gitHead": "8d1cdd7fed61921baaf71787fb46b6b33061d794"
76
+ "gitHead": "ecd9fe6ee8418bbdfb7eec2220578dfef06eb0dd"
77
77
  }