@wdio/browser-runner 8.13.12 → 8.14.0
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/browser/mock.d.ts +9 -0
- package/build/browser/mock.d.ts.map +1 -1
- package/build/browser/mock.js +9 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -2
- package/build/vite/frameworks/index.d.ts +2 -1
- package/build/vite/frameworks/index.d.ts.map +1 -1
- package/build/vite/frameworks/index.js +10 -2
- package/build/vite/frameworks/nuxt.d.ts +2 -1
- package/build/vite/frameworks/nuxt.d.ts.map +1 -1
- package/build/vite/frameworks/nuxt.js +33 -29
- package/build/vite/frameworks/tailwindcss.d.ts +11 -0
- package/build/vite/frameworks/tailwindcss.d.ts.map +1 -0
- package/build/vite/frameworks/tailwindcss.js +28 -0
- package/build/vite/plugins/mockHoisting.d.ts.map +1 -1
- package/build/vite/plugins/mockHoisting.js +5 -2
- package/build/vite/plugins/testrunner.d.ts.map +1 -1
- package/build/vite/plugins/testrunner.js +6 -3
- package/build/vite/server.d.ts +1 -1
- package/build/vite/server.d.ts.map +1 -1
- package/build/vite/server.js +2 -2
- package/build/vite/utils.d.ts +2 -0
- package/build/vite/utils.d.ts.map +1 -1
- package/build/vite/utils.js +31 -1
- package/package.json +10 -10
- package/build/vite/frameworks/utils.d.ts +0 -2
- package/build/vite/frameworks/utils.d.ts.map +0 -1
- package/build/vite/frameworks/utils.js +0 -4
package/build/browser/mock.d.ts
CHANGED
|
@@ -20,6 +20,15 @@ export declare const fileURLToPath: () => string;
|
|
|
20
20
|
export declare const dirname: () => string;
|
|
21
21
|
export declare const resolve: () => string;
|
|
22
22
|
export declare const sep = "/";
|
|
23
|
+
export declare const start: () => void;
|
|
24
|
+
export declare const install: () => void;
|
|
25
|
+
export declare const computeExecutablePath: () => void;
|
|
26
|
+
export declare const Browser: () => void;
|
|
27
|
+
export declare const getInstalledBrowsers: () => void;
|
|
28
|
+
export declare const canDownload: () => void;
|
|
29
|
+
export declare const resolveBuildId: () => void;
|
|
30
|
+
export declare const ChromeReleaseChannel: () => void;
|
|
31
|
+
export declare const detectBrowserPlatform: () => void;
|
|
23
32
|
export declare const type = "browser";
|
|
24
33
|
export declare const sync: () => void;
|
|
25
34
|
declare const _default: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/browser/mock.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa;;;CAIzB,CAAA;AAED,eAAO,MAAM,iBAAiB,SAAK,CAAA;AACnC,eAAO,MAAM,eAAe,IAAK,CAAA;AACjC,qBAAa,YAAY;CAAG;AAC5B,eAAO,MAAM,GAAG;;;;;CAAa,CAAA;AAC7B,eAAO,MAAM,aAAa,cAAW,CAAA;AACrC,eAAO,MAAM,aAAa,cAAW,CAAA;AACrC,eAAO,MAAM,OAAO,cAAW,CAAA;AAC/B,eAAO,MAAM,OAAO,cAAW,CAAA;AAC/B,eAAO,MAAM,GAAG,MAAM,CAAA;AACtB,eAAO,MAAM,IAAI,YAAY,CAAA;AAC7B,eAAO,MAAM,IAAI,YAAW,CAAA;;AAC5B,wBAAuB"}
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/browser/mock.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa;;;CAIzB,CAAA;AAED,eAAO,MAAM,iBAAiB,SAAK,CAAA;AACnC,eAAO,MAAM,eAAe,IAAK,CAAA;AACjC,qBAAa,YAAY;CAAG;AAC5B,eAAO,MAAM,GAAG;;;;;CAAa,CAAA;AAC7B,eAAO,MAAM,aAAa,cAAW,CAAA;AACrC,eAAO,MAAM,aAAa,cAAW,CAAA;AACrC,eAAO,MAAM,OAAO,cAAW,CAAA;AAC/B,eAAO,MAAM,OAAO,cAAW,CAAA;AAC/B,eAAO,MAAM,GAAG,MAAM,CAAA;AACtB,eAAO,MAAM,KAAK,YAAW,CAAA;AAC7B,eAAO,MAAM,OAAO,YAAW,CAAA;AAC/B,eAAO,MAAM,qBAAqB,YAAW,CAAA;AAC7C,eAAO,MAAM,OAAO,YAAW,CAAA;AAC/B,eAAO,MAAM,oBAAoB,YAAW,CAAA;AAC5C,eAAO,MAAM,WAAW,YAAW,CAAA;AACnC,eAAO,MAAM,cAAc,YAAW,CAAA;AACtC,eAAO,MAAM,oBAAoB,YAAW,CAAA;AAC5C,eAAO,MAAM,qBAAqB,YAAW,CAAA;AAC7C,eAAO,MAAM,IAAI,YAAY,CAAA;AAC7B,eAAO,MAAM,IAAI,YAAW,CAAA;;AAC5B,wBAAuB"}
|
package/build/browser/mock.js
CHANGED
|
@@ -16,6 +16,15 @@ export const fileURLToPath = () => '';
|
|
|
16
16
|
export const dirname = () => '';
|
|
17
17
|
export const resolve = () => '';
|
|
18
18
|
export const sep = '/';
|
|
19
|
+
export const start = () => { };
|
|
20
|
+
export const install = () => { };
|
|
21
|
+
export const computeExecutablePath = () => { };
|
|
22
|
+
export const Browser = () => { };
|
|
23
|
+
export const getInstalledBrowsers = () => { };
|
|
24
|
+
export const canDownload = () => { };
|
|
25
|
+
export const resolveBuildId = () => { };
|
|
26
|
+
export const ChromeReleaseChannel = () => { };
|
|
27
|
+
export const detectBrowserPlatform = () => { };
|
|
19
28
|
export const type = 'browser';
|
|
20
29
|
export const sync = () => { };
|
|
21
30
|
export default () => { };
|
package/build/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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;AAW/G,OAAO,KAAK,EAAE,oBAAoB,IAAI,0BAA0B,EAAmB,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAK5H,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;;IAY9C,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;IAsBV,GAAG,CAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC;IAkCrD;;;;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,CAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,QAAI;AAEvE;;;;GAIG;AAEH,wBAAgB,MAAM,CAAC,UAAU,EAAE,MAAM,QAAI;AAE7C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC,CAAA;AACnE,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,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
|
@@ -21,6 +21,7 @@ export default class BrowserRunner extends LocalRunner {
|
|
|
21
21
|
#servers = new Set();
|
|
22
22
|
#coverageOptions;
|
|
23
23
|
#reportsDirectory;
|
|
24
|
+
#viteOptimizations = {};
|
|
24
25
|
#mapStore = libSourceMap.createSourceMapStore();
|
|
25
26
|
_coverageMaps = [];
|
|
26
27
|
constructor(options, _config) {
|
|
@@ -59,7 +60,7 @@ export default class BrowserRunner extends LocalRunner {
|
|
|
59
60
|
* make adjustments based on detected frontend frameworks
|
|
60
61
|
*/
|
|
61
62
|
try {
|
|
62
|
-
await updateViteConfig(this.#options, this.#config);
|
|
63
|
+
this.#viteOptimizations = await updateViteConfig(this.#options, this.#config);
|
|
63
64
|
}
|
|
64
65
|
catch (err) {
|
|
65
66
|
log.error(`Failed to optimize Vite config: ${err.stack}`);
|
|
@@ -69,7 +70,7 @@ export default class BrowserRunner extends LocalRunner {
|
|
|
69
70
|
async run(runArgs) {
|
|
70
71
|
runArgs.caps = makeHeadless(this.options, runArgs.caps);
|
|
71
72
|
runArgs.caps = adjustWindowInWatchMode(this.#config, runArgs.caps);
|
|
72
|
-
const server = new ViteServer(this.#options, this.#config);
|
|
73
|
+
const server = new ViteServer(this.#options, this.#config, this.#viteOptimizations);
|
|
73
74
|
try {
|
|
74
75
|
await server.start();
|
|
75
76
|
runArgs.args.baseUrl = `http://localhost:${server.config.server?.port}`;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Options } from '@wdio/types';
|
|
2
|
-
|
|
2
|
+
import type { InlineConfig } from 'vite';
|
|
3
|
+
export default function updateViteConfig(options: WebdriverIO.BrowserRunnerOptions, config: Options.Testrunner): Promise<InlineConfig>;
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/frameworks/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/frameworks/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAKxC,wBAA8B,gBAAgB,CAAE,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU,yBAepH"}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { isNuxtFramework, optimizeForNuxt } from './nuxt.js';
|
|
2
|
+
import { isUsingTailwindCSS, optimizeForTailwindCSS } from './tailwindcss.js';
|
|
2
3
|
export default async function updateViteConfig(options, config) {
|
|
3
|
-
const
|
|
4
|
+
const optimizations = {};
|
|
5
|
+
const rootDir = options.rootDir || config.rootDir || process.cwd();
|
|
6
|
+
const isNuxt = await isNuxtFramework(rootDir);
|
|
4
7
|
if (isNuxt) {
|
|
5
|
-
await optimizeForNuxt(options, config);
|
|
8
|
+
Object.assign(optimizations, await optimizeForNuxt(options, config));
|
|
6
9
|
}
|
|
10
|
+
const isTailwind = await isUsingTailwindCSS(rootDir);
|
|
11
|
+
if (isTailwind) {
|
|
12
|
+
Object.assign(optimizations, await optimizeForTailwindCSS(rootDir));
|
|
13
|
+
}
|
|
14
|
+
return optimizations;
|
|
7
15
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Options } from '@wdio/types';
|
|
2
|
+
import type { InlineConfig } from 'vite';
|
|
2
3
|
declare global {
|
|
3
4
|
var defineNuxtConfig: Function;
|
|
4
5
|
}
|
|
5
6
|
export declare function isNuxtFramework(rootDir: string): Promise<boolean>;
|
|
6
|
-
export declare function optimizeForNuxt(options: WebdriverIO.BrowserRunnerOptions, config: Options.Testrunner): Promise<
|
|
7
|
+
export declare function optimizeForNuxt(options: WebdriverIO.BrowserRunnerOptions, config: Options.Testrunner): Promise<InlineConfig>;
|
|
7
8
|
//# sourceMappingURL=nuxt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt.d.ts","sourceRoot":"","sources":["../../../src/vite/frameworks/nuxt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nuxt.d.ts","sourceRoot":"","sources":["../../../src/vite/frameworks/nuxt.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAIxC,OAAO,CAAC,MAAM,CAAC;IAEX,IAAI,gBAAgB,EAAE,QAAQ,CAAA;CACjC;AAID,wBAAsB,eAAe,CAAE,OAAO,EAAE,MAAM,oBAOrD;AAED,wBAAsB,eAAe,CAAE,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAoDnI"}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
+
import url from 'node:url';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import logger from '@wdio/logger';
|
|
3
|
-
import {
|
|
4
|
+
import { resolve } from 'import-meta-resolve';
|
|
5
|
+
import { hasFileByExtensions, hasDir } from '../utils.js';
|
|
4
6
|
const log = logger('@wdio/browser-runner:NuxtOptimization');
|
|
5
7
|
export async function isNuxtFramework(rootDir) {
|
|
6
8
|
return (await Promise.all([
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
hasFileByExtensions(path.join(rootDir, 'nuxt.config')),
|
|
10
|
+
hasDir(path.join(rootDir, '.nuxt'))
|
|
9
11
|
])).filter(Boolean).length > 0;
|
|
10
12
|
}
|
|
11
13
|
export async function optimizeForNuxt(options, config) {
|
|
12
14
|
const Unimport = (await import('unimport/unplugin')).default;
|
|
13
|
-
const { scanDirExports } = await import('unimport');
|
|
15
|
+
const { scanDirExports, scanExports } = await import('unimport');
|
|
14
16
|
const { loadNuxtConfig } = await import('@nuxt/kit');
|
|
15
17
|
const rootDir = config.rootDir || process.cwd();
|
|
16
18
|
const nuxtOptions = await loadNuxtConfig({ rootDir });
|
|
17
19
|
if (nuxtOptions.imports?.autoImport === false) {
|
|
18
|
-
return;
|
|
20
|
+
return {};
|
|
19
21
|
}
|
|
22
|
+
const nuxtDepPath = await resolve('nuxt', import.meta.url);
|
|
20
23
|
const composablesDirs = [];
|
|
21
24
|
for (const layer of nuxtOptions._layers) {
|
|
22
25
|
composablesDirs.push(path.resolve(layer.config.srcDir, 'composables'));
|
|
@@ -28,30 +31,31 @@ export async function optimizeForNuxt(options, config) {
|
|
|
28
31
|
composablesDirs.push(path.resolve(layer.config.srcDir, dir));
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
|
-
const composableImports = await
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
const composableImports = await Promise.all([
|
|
35
|
+
scanDirExports([
|
|
36
|
+
...composablesDirs,
|
|
37
|
+
path.resolve(path.dirname(url.fileURLToPath(nuxtDepPath)), 'app', 'components')
|
|
38
|
+
]),
|
|
39
|
+
scanExports(path.resolve(path.dirname(url.fileURLToPath(nuxtDepPath)), 'app', 'composables', 'index.js'))
|
|
40
|
+
]).then((scannedExports) => scannedExports.flat().map((ci) => {
|
|
41
|
+
/**
|
|
42
|
+
* auto mock nuxt composables as they can't be loaded within the browser
|
|
43
|
+
*/
|
|
44
|
+
if (ci.from.includes('/nuxt/dist/app/composables')) {
|
|
45
|
+
ci.from = 'virtual:wdio';
|
|
46
|
+
ci.name = 'wrappedFn';
|
|
47
|
+
}
|
|
48
|
+
return ci;
|
|
46
49
|
}));
|
|
50
|
+
const viteConfig = {
|
|
51
|
+
resolve: {
|
|
52
|
+
alias: nuxtOptions.alias || {}
|
|
53
|
+
},
|
|
54
|
+
plugins: [Unimport.vite({
|
|
55
|
+
presets: ['vue'],
|
|
56
|
+
imports: composableImports
|
|
57
|
+
})]
|
|
58
|
+
};
|
|
47
59
|
log.info(`Optimized Vite config for Nuxt project at ${rootDir}`);
|
|
48
|
-
|
|
49
|
-
async function getNuxtConfig(rootDir) {
|
|
50
|
-
const pathOptions = [
|
|
51
|
-
path.join(rootDir, 'nuxt.config.js'),
|
|
52
|
-
path.join(rootDir, 'nuxt.config.ts'),
|
|
53
|
-
path.join(rootDir, 'nuxt.config.mjs'),
|
|
54
|
-
path.join(rootDir, 'nuxt.config.mts')
|
|
55
|
-
];
|
|
56
|
-
return (await Promise.all(pathOptions.map(async (o) => (await hasFile(o)) && o)).then((res) => res.filter(Boolean)))[0];
|
|
60
|
+
return viteConfig;
|
|
57
61
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { InlineConfig } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* returns `true` if TailwindCSS config exist but no postcss.config
|
|
4
|
+
* (if a `postcss.config` exists it will be automatically picked up by Vite)
|
|
5
|
+
*/
|
|
6
|
+
export declare function isUsingTailwindCSS(rootDir: string): Promise<boolean | "" | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* add tailwind plugin if installed as dependency
|
|
9
|
+
*/
|
|
10
|
+
export declare function optimizeForTailwindCSS(rootDir: string): Promise<InlineConfig>;
|
|
11
|
+
//# sourceMappingURL=tailwindcss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwindcss.d.ts","sourceRoot":"","sources":["../../../src/vite/frameworks/tailwindcss.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAIxC;;;GAGG;AACH,wBAAgB,kBAAkB,CAAE,OAAO,EAAE,MAAM,qCAOlD;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAE,OAAO,EAAE,MAAM,yBAQ5D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import url from 'node:url';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { resolve } from 'import-meta-resolve';
|
|
4
|
+
import { hasFileByExtensions } from '../utils.js';
|
|
5
|
+
/**
|
|
6
|
+
* returns `true` if TailwindCSS config exist but no postcss.config
|
|
7
|
+
* (if a `postcss.config` exists it will be automatically picked up by Vite)
|
|
8
|
+
*/
|
|
9
|
+
export function isUsingTailwindCSS(rootDir) {
|
|
10
|
+
return Promise.all([
|
|
11
|
+
hasFileByExtensions(path.join(rootDir, 'tailwind.config')),
|
|
12
|
+
hasFileByExtensions(path.join(rootDir, 'postcss.config'))
|
|
13
|
+
]).then(([hasTailwindConfig, hasPostCSSConfig]) => {
|
|
14
|
+
return hasTailwindConfig && !hasPostCSSConfig;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* add tailwind plugin if installed as dependency
|
|
19
|
+
*/
|
|
20
|
+
export async function optimizeForTailwindCSS(rootDir) {
|
|
21
|
+
const viteConfig = {};
|
|
22
|
+
const tailwindcssPath = await resolve('tailwindcss', url.pathToFileURL(path.resolve(rootDir, 'index.js')).href);
|
|
23
|
+
const tailwindcss = (await import(tailwindcssPath)).default;
|
|
24
|
+
viteConfig.css = {
|
|
25
|
+
postcss: { plugins: [tailwindcss] }
|
|
26
|
+
};
|
|
27
|
+
return viteConfig;
|
|
28
|
+
}
|
|
@@ -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,
|
|
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,CA4U/D"}
|
|
@@ -46,7 +46,10 @@ export function mockHoisting(mockHandler) {
|
|
|
46
46
|
*/
|
|
47
47
|
if (
|
|
48
48
|
// where loading was inititated through the test file
|
|
49
|
-
!isTestDependency
|
|
49
|
+
(!isTestDependency && (
|
|
50
|
+
// however when files are inlined they will be loaded when parsing file under test
|
|
51
|
+
// in this case we want to transform them, but make sure we exclude these paths
|
|
52
|
+
id.includes('/node_modules/') || id.includes('/?cid=') || id.startsWith('virtual:'))) ||
|
|
50
53
|
// are not Vite or WebdriverIO internals
|
|
51
54
|
INTERNALS_TO_IGNORE.find((f) => id.includes(f)) ||
|
|
52
55
|
// when the spec file is actually mocking any dependencies
|
|
@@ -187,7 +190,7 @@ export function mockHoisting(mockHandler) {
|
|
|
187
190
|
const newNode = b.importDeclaration([b.importNamespaceSpecifier(b.identifier(newImportIdentifier))], b.literal(source));
|
|
188
191
|
nodePath.insertBefore(newNode);
|
|
189
192
|
}
|
|
190
|
-
const wdioImportModuleIdentifier = source.startsWith('.')
|
|
193
|
+
const wdioImportModuleIdentifier = source.startsWith('.') || source.startsWith('/')
|
|
191
194
|
? url.pathToFileURL(path.resolve(path.dirname(id), source).slice(0, path.extname(source).length * -1)).pathname
|
|
192
195
|
: source;
|
|
193
196
|
const isNamespaceImport = dec.specifiers.length === 1 && dec.specifiers[0].type === types.namedTypes.ImportNamespaceSpecifier.toString();
|
|
@@ -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,
|
|
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,CAyH9E"}
|
|
@@ -22,12 +22,13 @@ const resolvedVirtualModuleId = '\0' + virtualModuleId;
|
|
|
22
22
|
* functionality
|
|
23
23
|
*/
|
|
24
24
|
const MODULES_TO_MOCK = [
|
|
25
|
-
'import-meta-resolve', 'puppeteer-core', 'archiver', 'glob', 'devtools', 'ws', 'decamelize'
|
|
25
|
+
'import-meta-resolve', 'puppeteer-core', 'archiver', 'glob', 'devtools', 'ws', 'decamelize',
|
|
26
|
+
'geckodriver', 'safaridriver', 'edgedriver', '@puppeteer/browsers'
|
|
26
27
|
];
|
|
27
28
|
const POLYFILLS = [
|
|
28
29
|
...builtinModules,
|
|
29
30
|
...builtinModules.map((m) => `node:${m}`)
|
|
30
|
-
]
|
|
31
|
+
];
|
|
31
32
|
export function testrunner(options) {
|
|
32
33
|
const automationProtocolPath = `/@fs${url.pathToFileURL(path.resolve(__dirname, '..', '..', 'browser', 'driver.js')).pathname}`;
|
|
33
34
|
const mockModulePath = path.resolve(__dirname, '..', '..', 'browser', 'mock.js');
|
|
@@ -41,7 +42,7 @@ export function testrunner(options) {
|
|
|
41
42
|
return resolvedVirtualModuleId;
|
|
42
43
|
}
|
|
43
44
|
if (POLYFILLS.includes(id)) {
|
|
44
|
-
return polyfillPath(normalizeId(id));
|
|
45
|
+
return polyfillPath(normalizeId(id.replace('/promises', '')));
|
|
45
46
|
}
|
|
46
47
|
if (id === '@wdio/browser-runner') {
|
|
47
48
|
return spyModulePath;
|
|
@@ -68,8 +69,10 @@ export function testrunner(options) {
|
|
|
68
69
|
*/
|
|
69
70
|
if (id === resolvedVirtualModuleId) {
|
|
70
71
|
return /*js*/ `
|
|
72
|
+
import { fn } from '@wdio/browser-runner'
|
|
71
73
|
export const commands = ${JSON.stringify(protocolCommandList)}
|
|
72
74
|
export const automationProtocolPath = ${JSON.stringify(automationProtocolPath)}
|
|
75
|
+
export const wrappedFn = (...args) => fn()(...args)
|
|
73
76
|
`;
|
|
74
77
|
}
|
|
75
78
|
},
|
package/build/vite/server.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare class ViteServer extends EventEmitter {
|
|
|
8
8
|
#private;
|
|
9
9
|
get socketServer(): WebSocketServer | undefined;
|
|
10
10
|
get config(): Partial<InlineConfig>;
|
|
11
|
-
constructor(options: WebdriverIO.BrowserRunnerOptions, config: Options.Testrunner);
|
|
11
|
+
constructor(options: WebdriverIO.BrowserRunnerOptions, config: Options.Testrunner, optimizations: InlineConfig);
|
|
12
12
|
start(): Promise<void>;
|
|
13
13
|
close(): Promise<void>;
|
|
14
14
|
private runWorkerHooks;
|
|
@@ -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;
|
|
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,EAAE,aAAa,EAAE,YAAY;IA2BzG,KAAK;IAuDL,KAAK;IA2IX,OAAO,CAAC,cAAc;IAetB,WAAW,CAAE,MAAM,EAAE,gBAAgB;CAUxC"}
|
package/build/vite/server.js
CHANGED
|
@@ -36,13 +36,13 @@ export class ViteServer extends EventEmitter {
|
|
|
36
36
|
get config() {
|
|
37
37
|
return this.#viteConfig;
|
|
38
38
|
}
|
|
39
|
-
constructor(options, config) {
|
|
39
|
+
constructor(options, config, optimizations) {
|
|
40
40
|
super();
|
|
41
41
|
this.#options = options;
|
|
42
42
|
this.#config = config;
|
|
43
43
|
this.#mockHandler = new MockHandler(options, config);
|
|
44
44
|
const root = options.rootDir || config.rootDir || process.cwd();
|
|
45
|
-
this.#viteConfig = deepmerge(DEFAULT_VITE_CONFIG, {
|
|
45
|
+
this.#viteConfig = deepmerge(DEFAULT_VITE_CONFIG, optimizations, {
|
|
46
46
|
root,
|
|
47
47
|
plugins: [
|
|
48
48
|
testrunner(options),
|
package/build/vite/utils.d.ts
CHANGED
|
@@ -4,5 +4,7 @@ export declare function userfriendlyImport(preset: FrameworkPreset, pkg?: string
|
|
|
4
4
|
export declare function normalizeId(id: string, base?: string): string;
|
|
5
5
|
export declare function getFilesFromDirectory(dir: string): Promise<string[]>;
|
|
6
6
|
export declare function getManualMocks(automockDir: string): Promise<[string, string][]>;
|
|
7
|
+
export declare function hasFileByExtensions(p: string, extensions?: string[]): Promise<string | undefined>;
|
|
8
|
+
export declare function hasDir(p: string): Promise<boolean>;
|
|
7
9
|
export declare function getErrorTemplate(filename: string, error: Error): string;
|
|
8
10
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/vite/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/vite/utils.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAI/D,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,iBAAU,mBA6HvH;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;AAGD,wBAAsB,mBAAmB,CAAE,CAAC,EAAE,MAAM,EAAE,UAAU,WAAY,+BAK3E;AAED,wBAAgB,MAAM,CAAE,CAAC,EAAE,MAAM,oBAEhC;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,UAU9D"}
|
package/build/vite/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable quotes */
|
|
1
2
|
import fs from 'node:fs/promises';
|
|
2
3
|
import url from 'node:url';
|
|
3
4
|
import path from 'node:path';
|
|
@@ -9,6 +10,8 @@ export async function getTemplate(options, env, spec, p = process) {
|
|
|
9
10
|
const root = options.rootDir || process.cwd();
|
|
10
11
|
const rootFileUrl = url.pathToFileURL(root).href;
|
|
11
12
|
const isHeadless = options.headless || Boolean(process.env.CI);
|
|
13
|
+
const alias = options.viteConfig?.resolve?.alias || {};
|
|
14
|
+
const usesTailwindCSS = await hasFileByExtensions(path.join(root, 'tailwind.config'));
|
|
12
15
|
let vueDeps = '';
|
|
13
16
|
if (options.preset === 'vue') {
|
|
14
17
|
try {
|
|
@@ -49,9 +52,26 @@ export async function getTemplate(options, env, spec, p = process) {
|
|
|
49
52
|
<head>
|
|
50
53
|
<title>WebdriverIO Browser Test</title>
|
|
51
54
|
<link rel="icon" type="image/x-icon" href="https://webdriver.io/img/favicon.png">
|
|
55
|
+
${usesTailwindCSS ? /*html*/ `<link rel="stylesheet" href="/node_modules/tailwindcss/tailwind.css">` : ''}
|
|
52
56
|
<script type="module">
|
|
57
|
+
const alias = ${JSON.stringify(alias)}
|
|
53
58
|
window.__wdioMockCache__ = new Map()
|
|
54
59
|
window.wdioImport = function (modName, mod) {
|
|
60
|
+
/**
|
|
61
|
+
* attempt to resolve direct import
|
|
62
|
+
*/
|
|
63
|
+
if (window.__wdioMockCache__.get(modName)) {
|
|
64
|
+
return window.__wdioMockCache__.get(modName)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* if above fails, check if we have an alias for it
|
|
69
|
+
*/
|
|
70
|
+
for (const [aliasName, aliasPath] of Object.entries(alias)) {
|
|
71
|
+
if (modName.slice(0, aliasName.length) === aliasName) {
|
|
72
|
+
modName = modName.replace(aliasName, aliasPath)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
55
75
|
if (window.__wdioMockCache__.get(modName)) {
|
|
56
76
|
return window.__wdioMockCache__.get(modName)
|
|
57
77
|
}
|
|
@@ -86,7 +106,7 @@ export async function getTemplate(options, env, spec, p = process) {
|
|
|
86
106
|
env: ${JSON.stringify(p.env)},
|
|
87
107
|
stdout: {},
|
|
88
108
|
stderr: {},
|
|
89
|
-
cwd: () =>
|
|
109
|
+
cwd: () => ${JSON.stringify(p.cwd())},
|
|
90
110
|
}
|
|
91
111
|
</script>
|
|
92
112
|
<script type="module" src="@wdio/browser-runner/setup"></script>
|
|
@@ -171,6 +191,16 @@ export async function getManualMocks(automockDir) {
|
|
|
171
191
|
}
|
|
172
192
|
return mockedModulesList;
|
|
173
193
|
}
|
|
194
|
+
const EXTENSION = ['.js', '.ts', '.mjs', '.cjs', '.mts'];
|
|
195
|
+
export async function hasFileByExtensions(p, extensions = EXTENSION) {
|
|
196
|
+
return (await Promise.all([
|
|
197
|
+
fs.access(p).then(() => p, () => undefined),
|
|
198
|
+
...extensions.map((ext) => fs.access(p + ext).then(() => p + ext, () => undefined))
|
|
199
|
+
])).filter(Boolean)[0];
|
|
200
|
+
}
|
|
201
|
+
export function hasDir(p) {
|
|
202
|
+
return fs.stat(p).then((s) => s.isDirectory(), () => false);
|
|
203
|
+
}
|
|
174
204
|
export function getErrorTemplate(filename, error) {
|
|
175
205
|
return /*html*/ `
|
|
176
206
|
<pre>${error.stack}</pre>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/browser-runner",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.14.0",
|
|
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,13 +35,13 @@
|
|
|
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.
|
|
39
|
-
"@wdio/local-runner": "8.
|
|
38
|
+
"@wdio/globals": "8.14.0",
|
|
39
|
+
"@wdio/local-runner": "8.14.0",
|
|
40
40
|
"@wdio/logger": "8.11.0",
|
|
41
|
-
"@wdio/mocha-framework": "8.
|
|
41
|
+
"@wdio/mocha-framework": "8.14.0",
|
|
42
42
|
"@wdio/protocols": "8.11.0",
|
|
43
|
-
"@wdio/types": "8.
|
|
44
|
-
"@wdio/utils": "8.
|
|
43
|
+
"@wdio/types": "8.14.0",
|
|
44
|
+
"@wdio/utils": "8.14.0",
|
|
45
45
|
"ast-types": "^0.14.2",
|
|
46
46
|
"deepmerge-ts": "^5.0.0",
|
|
47
47
|
"expect-webdriverio": "^4.2.5",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"vite": "~4.4.6",
|
|
60
60
|
"vite-plugin-istanbul": "^5.0.0",
|
|
61
61
|
"vite-plugin-top-level-await": "^1.3.0",
|
|
62
|
-
"webdriver": "8.
|
|
63
|
-
"webdriverio": "8.
|
|
62
|
+
"webdriver": "8.14.0",
|
|
63
|
+
"webdriverio": "8.14.0",
|
|
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.
|
|
74
|
+
"@wdio/runner": "8.14.0"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "cb2092b007e6d2ac23a49aa30dae67d70e45906d"
|
|
77
77
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/vite/frameworks/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,OAAO,CAAE,CAAC,EAAE,MAAM,oBAEjC"}
|