@wdio/browser-runner 8.5.0 → 8.5.2

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.
@@ -21,7 +21,7 @@ export async function mock(path, factory) {
21
21
  if (!factory) {
22
22
  return;
23
23
  }
24
- const mockLocalFile = path.startsWith('/') || path.startsWith('./');
24
+ const mockLocalFile = path.startsWith('/') || path.startsWith('./') || path.startsWith('../');
25
25
  const mockPath = mockLocalFile
26
26
  ? (new URL(resolveUrl(window.__wdioSpec__.split('/').slice(0, -1).join('/') + '/' + path))).pathname
27
27
  : path;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/vite/constants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAgB1F,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,YAAY,CAsBrD,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/vite/constants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAgB1F,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,YAAY,CAiCrD,CAAA"}
@@ -23,10 +23,21 @@ export const DEFAULT_VITE_CONFIG = {
23
23
  logLevel: 'silent',
24
24
  plugins: [topLevelAwait()],
25
25
  build: {
26
- sourcemap: 'inline'
26
+ sourcemap: 'inline',
27
+ commonjsOptions: {
28
+ include: [/node_modules/],
29
+ }
27
30
  },
28
31
  optimizeDeps: {
29
- include: ['expect', 'jest-matcher-utils'],
32
+ /**
33
+ * the following deps are CJS packages and need to be optimized (compiled to ESM) by Vite
34
+ */
35
+ include: [
36
+ 'expect', 'jest-matcher-utils', 'serialize-error', 'minimatch', 'css-shorthand-properties',
37
+ 'lodash.merge', 'lodash.zip', 'lodash.clonedeep', 'lodash.pickby', 'lodash.flattendeep',
38
+ 'aria-query', 'grapheme-splitter', 'css-value', 'rgb2hex', 'p-iteration', 'fast-safe-stringify',
39
+ 'deepmerge-ts'
40
+ ],
30
41
  esbuildOptions: {
31
42
  logLevel: 'silent',
32
43
  // Node.js global to browser globalThis
@@ -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;AAM7C,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,EAAE,CA2M/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;AAM7C,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,EAAE,CAmN/D"}
@@ -25,6 +25,7 @@ export function mockHoisting(mockHandler) {
25
25
  return '';
26
26
  }
27
27
  }
28
+ const mocks = [...mockHandler.mocks.values()];
28
29
  const preBundledDepName = path.basename(id).split('?')[0];
29
30
  const mockedMod = (
30
31
  // mocked file
@@ -32,7 +33,14 @@ export function mockHoisting(mockHandler) {
32
33
  // mocked dependency
33
34
  mockHandler.mocks.get(path.basename(id, path.extname(id))) ||
34
35
  // pre-bundled deps e.g. /node_modules/.vite/deps/algoliasearch_lite.js?v=e31c24e
35
- [...mockHandler.mocks.values()].find((mock) => `${mock.path.replace('/', '_')}.js` === preBundledDepName));
36
+ mocks.find((mock) => `${mock.path.replace('/', '_')}.js` === preBundledDepName) ||
37
+ // relative file imports ignoring file extension, e.g. `mock('../../constants.ts', () => { ... })`
38
+ mocks.find((mock) => {
39
+ const mockFileExtLength = path.extname(mock.path).length;
40
+ const toCompare = mockFileExtLength > 0 ? mock.path.slice(0, -mockFileExtLength) : mock.path;
41
+ // compare without file extension as we don't know if users use them or not
42
+ return toCompare === id.slice(0, -path.extname(id).length);
43
+ }));
36
44
  if (mockedMod) {
37
45
  const newCode = mockedMod.namedExports.map((ne) => {
38
46
  if (ne === 'default') {
@@ -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,CAgI9E"}
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"}
@@ -15,6 +15,12 @@ const protocolCommandList = Object.values(commands).map((endpoint) => Object.val
15
15
  const WDIO_PACKAGES = ['webdriverio', 'expect-webdriverio'];
16
16
  const virtualModuleId = 'virtual:wdio';
17
17
  const resolvedVirtualModuleId = '\0' + virtualModuleId;
18
+ /**
19
+ * these modules are used in Node.js environments only and
20
+ * don't need to be compiled, we just have them point to a
21
+ * mocked module that returns a matching interface without
22
+ * functionality
23
+ */
18
24
  const MODULES_TO_MOCK = [
19
25
  'import-meta-resolve', 'puppeteer-core', 'archiver', 'glob', 'devtools', 'ws'
20
26
  ];
@@ -22,11 +28,6 @@ const POLYFILLS = [
22
28
  ...builtinModules,
23
29
  ...builtinModules.map((m) => `node:${m}`)
24
30
  ].map((m) => m.replace('/promises', ''));
25
- const FETCH_FROM_ESM = [
26
- 'serialize-error', 'minimatch', 'css-shorthand-properties', 'lodash.merge', 'lodash.zip',
27
- 'lodash.clonedeep', 'lodash.pickby', 'lodash.flattendeep', 'aria-query', 'grapheme-splitter',
28
- 'css-value', 'rgb2hex', 'p-iteration', 'fast-safe-stringify', 'deepmerge-ts'
29
- ];
30
31
  export function testrunner(options) {
31
32
  const automationProtocolPath = `/@fs${url.pathToFileURL(path.resolve(__dirname, '..', '..', 'browser', 'driver.js')).pathname}`;
32
33
  const mockModulePath = path.resolve(__dirname, '..', '..', 'browser', 'mock.js');
@@ -60,13 +61,6 @@ export function testrunner(options) {
60
61
  if (MODULES_TO_MOCK.includes(id)) {
61
62
  return mockModulePath;
62
63
  }
63
- /**
64
- * some dependencies used by WebdriverIO packages are still using CJS
65
- * so we need to pull them from esm.sh to have them run in the browser
66
- */
67
- if (FETCH_FROM_ESM.includes(id)) {
68
- return `https://esm.sh/${id}`;
69
- }
70
64
  },
71
65
  load(id) {
72
66
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/vite/utils.ts"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE/D,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,oBAAc,mBAsFpI;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,MAAM,gBAa7E;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAY7D;AAED,wBAAsB,qBAAqB,CAAE,GAAG,EAAE,MAAM,qBAavD;AAGD,wBAAsB,cAAc,CAAC,WAAW,EAAE,MAAM,+BAgBvD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,UAU9D"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/vite/utils.ts"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE/D,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,oBAAc,mBAuFpI;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,MAAM,gBAa7E;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAY7D;AAED,wBAAsB,qBAAqB,CAAE,GAAG,EAAE,MAAM,qBAqBvD;AAGD,wBAAsB,cAAc,CAAC,WAAW,EAAE,MAAM,+BAgBvD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,UAU9D"}
@@ -38,7 +38,8 @@ export async function getTemplate(options, env, spec, processEnv = process.env)
38
38
  <head>
39
39
  <title>WebdriverIO Browser Test</title>
40
40
  <link rel="icon" type="image/x-icon" href="https://webdriver.io/img/favicon.png">
41
- <link rel="stylesheet" href="${mochaCSSHref}"><script type="module" src="${mochaJSSrc}"></script>
41
+ <link rel="stylesheet" href="${mochaCSSHref}">
42
+ <script type="module" src="${mochaJSSrc}"></script>
42
43
  <script src="/@fs/${sourceMapSupportDir}/browser-source-map-support.js"></script>
43
44
  <script type="module">
44
45
  sourceMapSupport.install()
@@ -102,6 +103,13 @@ export function normalizeId(id, base) {
102
103
  .replace(/\?$/, ''); // remove end query mark
103
104
  }
104
105
  export async function getFilesFromDirectory(dir) {
106
+ /**
107
+ * check if dir exists
108
+ */
109
+ const isExisting = await fs.access(dir).then(() => true, () => false);
110
+ if (!isExisting) {
111
+ return [];
112
+ }
105
113
  let files = await fs.readdir(dir);
106
114
  files = (await Promise.all(files.map(async (file) => {
107
115
  const filePath = path.join(dir, file);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/browser-runner",
3
- "version": "8.5.0",
3
+ "version": "8.5.2",
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",
@@ -32,8 +32,8 @@
32
32
  "@types/istanbul-lib-source-maps": "^4.0.1",
33
33
  "@types/node": "^18.14.0",
34
34
  "@vitest/spy": "^0.29.1",
35
- "@wdio/globals": "8.4.0",
36
- "@wdio/local-runner": "8.4.0",
35
+ "@wdio/globals": "8.5.1",
36
+ "@wdio/local-runner": "8.5.1",
37
37
  "@wdio/logger": "8.1.0",
38
38
  "@wdio/mocha-framework": "8.4.0",
39
39
  "@wdio/protocols": "8.3.11",
@@ -56,8 +56,8 @@
56
56
  "vite": "^4.1.3",
57
57
  "vite-plugin-istanbul": "^4.0.0",
58
58
  "vite-plugin-top-level-await": "^1.2.4",
59
- "webdriver": "8.4.0",
60
- "webdriverio": "8.4.0",
59
+ "webdriver": "8.5.1",
60
+ "webdriverio": "8.5.1",
61
61
  "ws": "^8.12.1"
62
62
  },
63
63
  "scripts": {
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/ws": "^8.5.4",
71
- "@wdio/runner": "8.4.0"
71
+ "@wdio/runner": "8.5.1"
72
72
  },
73
- "gitHead": "7f6a6146ad7c9ec1d310e675b5e767cccd4fc3d9"
73
+ "gitHead": "810842bb22e18872edeacefaad713fb8fa876bf8"
74
74
  }