@wdio/browser-runner 8.13.6 → 8.13.7
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 +53 -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 +5 -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,iBAqC9I"}
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
try {
|
|
19
|
+
const nuxtConfig = (await import(nuxtConfigPath)).default;
|
|
20
|
+
const Unimport = (await import('unimport/unplugin')).default;
|
|
21
|
+
const { scanDirExports } = await import('unimport');
|
|
22
|
+
const { loadNuxt } = await import('nuxt');
|
|
23
|
+
const nuxt = await loadNuxt(nuxtConfig);
|
|
24
|
+
const composablesDirs = [];
|
|
25
|
+
for (const layer of nuxt._layers) {
|
|
26
|
+
composablesDirs.push(path.resolve(layer.config.srcDir, 'composables'));
|
|
27
|
+
composablesDirs.push(path.resolve(layer.config.srcDir, 'utils'));
|
|
28
|
+
for (const dir of (layer.config.imports?.dirs ?? [])) {
|
|
29
|
+
if (!dir) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
composablesDirs.push(path.resolve(layer.config.srcDir, dir));
|
|
33
|
+
}
|
|
34
|
+
const composableImports = await scanDirExports(composablesDirs);
|
|
35
|
+
viteConfig.plugins?.push(Unimport.vite({
|
|
36
|
+
presets: ['vue'],
|
|
37
|
+
imports: composableImports
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
log.error(`Failed to optimize Vite config for Nuxt: ${err.stack}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async function getNuxtConfig(rootDir) {
|
|
46
|
+
const pathOptions = [
|
|
47
|
+
path.join(rootDir, 'nuxt.config.js'),
|
|
48
|
+
path.join(rootDir, 'nuxt.config.ts'),
|
|
49
|
+
path.join(rootDir, 'nuxt.config.mjs'),
|
|
50
|
+
path.join(rootDir, 'nuxt.config.mts')
|
|
51
|
+
];
|
|
52
|
+
return (await Promise.all(pathOptions.map(async (o) => (await hasFile(o)) && o)).then((res) => res.filter(Boolean)))[0];
|
|
53
|
+
}
|
|
@@ -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;IA2DL,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,10 @@ 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
|
+
updateViteConfig(this.#viteConfig, this.#options, this.#config);
|
|
103
108
|
/**
|
|
104
109
|
* initialize Vite
|
|
105
110
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/browser-runner",
|
|
3
|
-
"version": "8.13.
|
|
3
|
+
"version": "8.13.7",
|
|
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": "6e70ae48022986df9adc4eb33c04c6b1c55a87df"
|
|
77
77
|
}
|