@wdio/browser-runner 8.13.6 → 8.13.8
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.
- package/build/vite/frameworks/index.d.ts +4 -0
- package/build/vite/frameworks/index.d.ts.map +1 -0
- package/build/vite/frameworks/index.js +7 -0
- package/build/vite/frameworks/nuxt.d.ts +8 -0
- package/build/vite/frameworks/nuxt.d.ts.map +1 -0
- package/build/vite/frameworks/nuxt.js +52 -0
- package/build/vite/frameworks/utils.d.ts +2 -0
- package/build/vite/frameworks/utils.d.ts.map +1 -0
- package/build/vite/frameworks/utils.js +4 -0
- package/build/vite/server.d.ts.map +1 -1
- package/build/vite/server.js +10 -0
- package/package.json +2 -2
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { InlineConfig } from 'vite';
|
|
2
|
+
import type { Options } from '@wdio/types';
|
|
3
|
+
export default function updateViteConfig(viteConfig: Partial<InlineConfig>, options: WebdriverIO.BrowserRunnerOptions, config: Options.Testrunner): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/frameworks/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAI1C,wBAA8B,gBAAgB,CAAE,UAAU,EAAE,OAAO,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU,iBAKvJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { isNuxtFramework, optimizeForNuxt } from './nuxt.js';
|
|
2
|
+
export default async function updateViteConfig(viteConfig, options, config) {
|
|
3
|
+
const isNuxt = await isNuxtFramework(config.rootDir || process.cwd());
|
|
4
|
+
if (isNuxt) {
|
|
5
|
+
await optimizeForNuxt(viteConfig, options, config);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { InlineConfig } from 'vite';
|
|
2
|
+
import type { Options } from '@wdio/types';
|
|
3
|
+
declare global {
|
|
4
|
+
var defineNuxtConfig: Function;
|
|
5
|
+
}
|
|
6
|
+
export declare function isNuxtFramework(rootDir: string): Promise<boolean>;
|
|
7
|
+
export declare function optimizeForNuxt(viteConfig: Partial<InlineConfig>, options: WebdriverIO.BrowserRunnerOptions, config: Options.Testrunner): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=nuxt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nuxt.d.ts","sourceRoot":"","sources":["../../../src/vite/frameworks/nuxt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAGxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAI1C,OAAO,CAAC,MAAM,CAAC;IAEX,IAAI,gBAAgB,EAAE,QAAQ,CAAA;CACjC;AAID,wBAAsB,eAAe,CAAE,OAAO,EAAE,MAAM,oBAOrD;AAED,wBAAsB,eAAe,CAAE,UAAU,EAAE,OAAO,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU,iBAoC9I"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import logger from '@wdio/logger';
|
|
3
|
+
import { hasFile } from './utils.js';
|
|
4
|
+
const log = logger('@wdio/browser-runner:NuxtOptimization');
|
|
5
|
+
export async function isNuxtFramework(rootDir) {
|
|
6
|
+
return (await Promise.all([
|
|
7
|
+
getNuxtConfig(rootDir),
|
|
8
|
+
hasFile(path.join(rootDir, '.nuxt'))
|
|
9
|
+
])).filter(Boolean).length > 0;
|
|
10
|
+
}
|
|
11
|
+
export async function optimizeForNuxt(viteConfig, options, config) {
|
|
12
|
+
const rootDir = config.rootDir || process.cwd();
|
|
13
|
+
const nuxtConfigPath = await getNuxtConfig(rootDir);
|
|
14
|
+
if (!nuxtConfigPath) {
|
|
15
|
+
throw new Error('No Nuxt project found!');
|
|
16
|
+
}
|
|
17
|
+
globalThis.defineNuxtConfig = (opts) => opts;
|
|
18
|
+
const nuxtConfig = (await import(nuxtConfigPath)).default;
|
|
19
|
+
const Unimport = (await import('unimport/unplugin')).default;
|
|
20
|
+
const { scanDirExports } = await import('unimport');
|
|
21
|
+
const { loadNuxt } = await import('nuxt');
|
|
22
|
+
const nuxt = await loadNuxt(nuxtConfig);
|
|
23
|
+
if (nuxt.options.imports?.autoImport === false) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const composablesDirs = [];
|
|
27
|
+
for (const layer of nuxt.options._layers) {
|
|
28
|
+
composablesDirs.push(path.resolve(layer.config.srcDir, 'composables'));
|
|
29
|
+
composablesDirs.push(path.resolve(layer.config.srcDir, 'utils'));
|
|
30
|
+
for (const dir of (layer.config.imports?.dirs ?? [])) {
|
|
31
|
+
if (!dir) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
composablesDirs.push(path.resolve(layer.config.srcDir, dir));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const composableImports = await scanDirExports(composablesDirs);
|
|
38
|
+
viteConfig.plugins?.push(Unimport.vite({
|
|
39
|
+
presets: ['vue'],
|
|
40
|
+
imports: composableImports
|
|
41
|
+
}));
|
|
42
|
+
log.info(`Optimized Vite config for Nuxt project with config at ${nuxtConfigPath}`);
|
|
43
|
+
}
|
|
44
|
+
async function getNuxtConfig(rootDir) {
|
|
45
|
+
const pathOptions = [
|
|
46
|
+
path.join(rootDir, 'nuxt.config.js'),
|
|
47
|
+
path.join(rootDir, 'nuxt.config.ts'),
|
|
48
|
+
path.join(rootDir, 'nuxt.config.mjs'),
|
|
49
|
+
path.join(rootDir, 'nuxt.config.mts')
|
|
50
|
+
];
|
|
51
|
+
return (await Promise.all(pathOptions.map(async (o) => (await hasFile(o)) && o)).then((res) => res.filter(Boolean)))[0];
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/vite/frameworks/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,OAAO,CAAE,CAAC,EAAE,MAAM,oBAEjC"}
|
|
@@ -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;
|
|
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;AASpD,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;IA+DL,KAAK;IA2IX,OAAO,CAAC,cAAc;IAetB,WAAW,CAAE,MAAM,EAAE,gBAAgB;CAUxC"}
|
package/build/vite/server.js
CHANGED
|
@@ -8,6 +8,7 @@ import { serializeError } from 'serialize-error';
|
|
|
8
8
|
import { executeHooksWithArgs } from '@wdio/utils';
|
|
9
9
|
import { createServer } from 'vite';
|
|
10
10
|
import istanbulPlugin from 'vite-plugin-istanbul';
|
|
11
|
+
import updateViteConfig from './frameworks/index.js';
|
|
11
12
|
import { testrunner } from './plugins/testrunner.js';
|
|
12
13
|
import { mockHoisting } from './plugins/mockHoisting.js';
|
|
13
14
|
import { userfriendlyImport } from './utils.js';
|
|
@@ -100,6 +101,15 @@ export class ViteServer extends EventEmitter {
|
|
|
100
101
|
*/
|
|
101
102
|
this.#wss = new WebSocketServer({ port: wssPort });
|
|
102
103
|
this.#wss.on('connection', this.#onConnect.bind(this));
|
|
104
|
+
/**
|
|
105
|
+
* make adjustments based on detected frontend frameworks
|
|
106
|
+
*/
|
|
107
|
+
try {
|
|
108
|
+
await updateViteConfig(this.#viteConfig, this.#options, this.#config);
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
log.error(`Failed to optimize Vite config: ${err.stack}`);
|
|
112
|
+
}
|
|
103
113
|
/**
|
|
104
114
|
* initialize Vite
|
|
105
115
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/browser-runner",
|
|
3
|
-
"version": "8.13.
|
|
3
|
+
"version": "8.13.8",
|
|
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",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"@types/ws": "^8.5.4",
|
|
74
74
|
"@wdio/runner": "8.13.4"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "1650e8a7a0f52140919ae9b6efb9ed05ff860276"
|
|
77
77
|
}
|