@wdio/browser-runner 8.5.3 → 8.5.4

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":"driver.d.ts","sourceRoot":"","sources":["../../src/browser/driver.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,OAAO,OAAO,WAAW;;IAG5B,MAAM,CAAC,UAAU,CACb,MAAM,EAAE,GAAG,EACX,QAAQ,EAAE,KAAK,EACf,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,EACjD,cAAc,EAAE,GAAG;CAmJ1B"}
1
+ {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/browser/driver.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,OAAO,OAAO,WAAW;;IAG5B,MAAM,CAAC,UAAU,CACb,MAAM,EAAE,GAAG,EACX,QAAQ,EAAE,KAAK,EACf,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,EACjD,cAAc,EAAE,GAAG;CAoJ1B"}
@@ -8,7 +8,8 @@ const CONSOLE_METHODS = ['log', 'info', 'warn', 'error', 'debug'];
8
8
  export default class ProxyDriver {
9
9
  static #commandMessages = new Map();
10
10
  static newSession(params, modifier, userPrototype, commandWrapper) {
11
- const [cid] = window.location.pathname.slice(1).split('/');
11
+ const urlParamString = new URLSearchParams(window.location.search);
12
+ const cid = urlParamString.get('cid');
12
13
  if (!cid) {
13
14
  throw new Error('"cid" query parameter is missing');
14
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mocha.d.ts","sourceRoot":"","sources":["../../../src/browser/frameworks/mocha.ts"],"names":[],"mappings":"AASA,qBAAa,cAAc;;gBAKV,MAAM,EAAE,SAAS;IA+B9B,GAAG;CA+DN"}
1
+ {"version":3,"file":"mocha.d.ts","sourceRoot":"","sources":["../../../src/browser/frameworks/mocha.ts"],"names":[],"mappings":"AASA,qBAAa,cAAc;;gBAKV,MAAM,EAAE,SAAS;IAgC9B,GAAG;CAgEN"}
@@ -9,7 +9,8 @@ export class MochaFramework {
9
9
  constructor(socket) {
10
10
  this.#socket = socket;
11
11
  socket.addEventListener('message', this.#handleSocketMessage.bind(this));
12
- const [cid] = window.location.pathname.slice(1).split('/');
12
+ const urlParamString = new URLSearchParams(window.location.search);
13
+ const cid = urlParamString.get('cid');
13
14
  if (!cid) {
14
15
  throw new Error('"cid" query parameter is missing');
15
16
  }
@@ -74,7 +75,8 @@ export class MochaFramework {
74
75
  #getHook(name) {
75
76
  return (...args) => new Promise((resolve, reject) => {
76
77
  const id = (this.#hookResolver.size + 1).toString();
77
- const [cid] = window.location.pathname.slice(1).split('/');
78
+ const urlParamString = new URLSearchParams(window.location.search);
79
+ const cid = urlParamString.get('cid');
78
80
  if (!cid) {
79
81
  return reject(new Error('"cid" query parameter is missing'));
80
82
  }
package/build/types.d.ts CHANGED
@@ -82,7 +82,7 @@ export interface BrowserRunnerOptions {
82
82
  /**
83
83
  * Vite configuration to overwrite the preset
84
84
  */
85
- viteConfig?: InlineConfig;
85
+ viteConfig?: string | InlineConfig;
86
86
  /**
87
87
  * Run tests in headless mode
88
88
  * @default false // true in CI environment
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAEjE,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,WAAW,EAAE,WAAW,CAAA;QACxB,iBAAiB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;KAC9C;CACJ;AAED,M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AAA;IACT,GAAG,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,SAAS,CAAA;IACf,MAAM,EAAE,OAAO,CAAC,UAAU,CAAA;IAC1B,YAAY,EAAE,YAAY,CAAC,gBAAgB,CAAA;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,OAAO,CAAA;CACzB;AAED,MAAM,MAAM,qBAAqB,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC,GAAG,OAAO,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC"}
@@ -185,10 +185,10 @@ export function mockHoisting(mockHandler) {
185
185
  configureServer(server) {
186
186
  return () => {
187
187
  server.middlewares.use('/', async (req, res, next) => {
188
- if (!req.url) {
188
+ if (!req.originalUrl) {
189
189
  return next();
190
190
  }
191
- const urlParsed = url.parse(req.url);
191
+ const urlParsed = url.parse(req.originalUrl);
192
192
  const urlParamString = new URLSearchParams(urlParsed.query || '');
193
193
  const specParam = urlParamString.get('spec');
194
194
  if (specParam) {
@@ -1 +1 @@
1
- {"version":3,"file":"testrunner.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/testrunner.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AA0ClC,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,oBAAoB,GAAG,MAAM,EAAE,CAwH9E"}
1
+ {"version":3,"file":"testrunner.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/testrunner.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AA0ClC,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,oBAAoB,GAAG,MAAM,EAAE,CAmH9E"}
@@ -83,18 +83,14 @@ export function testrunner(options) {
83
83
  },
84
84
  configureServer(server) {
85
85
  return () => {
86
- server.middlewares.use('/', async (req, res, next) => {
87
- log.info(`Received request for: ${req.url}`);
88
- if (!req.url) {
89
- return next();
90
- }
91
- const urlParsed = url.parse(req.url);
92
- // if request is not html , directly return next()
93
- if (!urlParsed.pathname || !urlParsed.path || !urlParsed.pathname.endsWith('test.html')) {
86
+ server.middlewares.use(async (req, res, next) => {
87
+ log.info(`Received request for: ${req.originalUrl}`);
88
+ if (!req.originalUrl) {
94
89
  return next();
95
90
  }
91
+ const urlParsed = url.parse(req.originalUrl);
96
92
  const urlParamString = new URLSearchParams(urlParsed.query || '');
97
- const [cid] = urlParsed.pathname.slice(1).split('/');
93
+ const cid = urlParamString.get('cid');
98
94
  const spec = urlParamString.get('spec');
99
95
  if (!cid || !SESSIONS.has(cid)) {
100
96
  log.error(`No environment found for ${cid || 'non determined environment'}`);
@@ -107,13 +103,13 @@ export function testrunner(options) {
107
103
  const env = SESSIONS.get(cid);
108
104
  try {
109
105
  const template = await getTemplate(options, env, spec);
110
- log.debug(`Render template for ${req.url}`);
111
- res.end(await server.transformIndexHtml(`${req.url}`, template));
106
+ log.debug(`Render template for ${req.originalUrl}`);
107
+ res.end(await server.transformIndexHtml(`${req.originalUrl}`, template));
112
108
  }
113
109
  catch (err) {
114
- const template = getErrorTemplate(req.url, err);
110
+ const template = getErrorTemplate(req.originalUrl, err);
115
111
  log.error(`Failed to render template: ${err.message}`);
116
- res.end(await server.transformIndexHtml(`${req.url}`, template));
112
+ res.end(await server.transformIndexHtml(`${req.originalUrl}`, template));
117
113
  }
118
114
  return next();
119
115
  });
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/vite/server.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAM1C,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAGpC,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,MAAM,CAAA;AAGvD,OAAO,KAAK,EAAY,OAAO,EAAE,MAAM,aAAa,CAAA;AAQpD,OAAO,KAAK,EACM,gBAAgB,EAEjC,MAAM,YAAY,CAAA;AAYnB,qBAAa,UAAW,SAAQ,YAAY;;IASxC,IAAI,YAAY,gCAEf;IAED,IAAI,MAAM,0BAET;gBAEY,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU;IAiC5E,KAAK;IAwCL,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,EAAE,MAAM,MAAM,CAAA;AAGvD,OAAO,KAAK,EAAY,OAAO,EAAE,MAAM,aAAa,CAAA;AAQpD,OAAO,KAAK,EACM,gBAAgB,EAEjC,MAAM,YAAY,CAAA;AAYnB,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;IAoDL,KAAK;IAkJX,OAAO,CAAC,cAAc;IAetB,WAAW,CAAE,MAAM,EAAE,gBAAgB;CAUxC"}
@@ -1,3 +1,4 @@
1
+ import path from 'node:path';
1
2
  import { EventEmitter } from 'node:events';
2
3
  import getPort from 'get-port';
3
4
  import logger from '@wdio/logger';
@@ -20,6 +21,7 @@ export class ViteServer extends EventEmitter {
20
21
  #pendingHooks = new Map();
21
22
  #connections = new Set();
22
23
  #options;
24
+ #config;
23
25
  #viteConfig;
24
26
  #wss;
25
27
  #server;
@@ -33,10 +35,8 @@ export class ViteServer extends EventEmitter {
33
35
  constructor(options, config) {
34
36
  super();
35
37
  this.#options = options;
38
+ this.#config = config;
36
39
  this.#mockHandler = new MockHandler(options, config);
37
- if (options.preset && options.viteConfig) {
38
- throw new Error('Invalid runner configuration: "preset" and "viteConfig" options are defined but only one of each can be used at the same time');
39
- }
40
40
  this.#viteConfig = deepmerge(DEFAULT_VITE_CONFIG, {
41
41
  root: options.rootDir || process.cwd(),
42
42
  plugins: [
@@ -54,12 +54,21 @@ export class ViteServer extends EventEmitter {
54
54
  ...options.coverage
55
55
  }));
56
56
  }
57
- if (options.viteConfig) {
58
- this.#viteConfig = deepmerge(this.#viteConfig, options.viteConfig);
59
- }
60
57
  }
61
58
  async start() {
62
59
  const [vitePort, wssPort] = await Promise.all([getPort(), getPort()]);
60
+ this.#viteConfig = deepmerge(this.#viteConfig, {
61
+ server: {
62
+ host: '0.0.0.0',
63
+ port: vitePort,
64
+ proxy: {
65
+ '/ws': {
66
+ target: `ws://localhost:${wssPort}`,
67
+ ws: true
68
+ }
69
+ }
70
+ }
71
+ });
63
72
  /**
64
73
  * load additional Vite plugins for framework
65
74
  */
@@ -70,23 +79,20 @@ export class ViteServer extends EventEmitter {
70
79
  this.#viteConfig.plugins.push(plugin(opts));
71
80
  }
72
81
  }
82
+ /**
83
+ * merge custom `viteConfig` last into the object
84
+ */
85
+ if (this.#options.viteConfig) {
86
+ const configToMerge = typeof this.#options.viteConfig === 'string'
87
+ ? (await import(path.resolve(this.#config.rootDir || process.cwd(), this.#options.viteConfig))).default
88
+ : this.#options.viteConfig;
89
+ this.#viteConfig = deepmerge(this.#viteConfig, configToMerge);
90
+ }
73
91
  /**
74
92
  * initialize Socket server on top of vite server
75
93
  */
76
94
  this.#wss = new WebSocketServer({ port: wssPort });
77
95
  this.#wss.on('connection', this.#onConnect.bind(this));
78
- this.#viteConfig = deepmerge(this.#viteConfig, {
79
- server: {
80
- host: '0.0.0.0',
81
- port: vitePort,
82
- proxy: {
83
- '/ws': {
84
- target: `ws://localhost:${wssPort}`,
85
- ws: true
86
- }
87
- }
88
- }
89
- });
90
96
  /**
91
97
  * initialize Vite
92
98
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/browser-runner",
3
- "version": "8.5.3",
3
+ "version": "8.5.4",
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",
@@ -33,7 +33,7 @@
33
33
  "@types/node": "^18.14.0",
34
34
  "@vitest/spy": "^0.29.1",
35
35
  "@wdio/globals": "8.5.1",
36
- "@wdio/local-runner": "8.5.1",
36
+ "@wdio/local-runner": "8.5.4",
37
37
  "@wdio/logger": "8.1.0",
38
38
  "@wdio/mocha-framework": "8.4.0",
39
39
  "@wdio/protocols": "8.3.11",
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/ws": "^8.5.4",
71
- "@wdio/runner": "8.5.1"
71
+ "@wdio/runner": "8.5.4"
72
72
  },
73
- "gitHead": "445f1c901e9bd08b2d17d35592ad7c3258937917"
73
+ "gitHead": "32e80c3543f24a346cc1b8dde7fcbe8b34724c56"
74
74
  }