Skip to content

Commit

Permalink
test: update e2e configurations using the rootDir option
Browse files Browse the repository at this point in the history
  • Loading branch information
mato533 committed Mar 7, 2025
1 parent 5b5bf5a commit 53f1a48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
12 changes: 3 additions & 9 deletions e2e/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,21 @@ import url from 'node:url';
import path from 'node:path';
import fs from 'node:fs';

import { getAppBuildInfo, getBinaryPath, getElectronVersion } from '@wdio/electron-utils';

const exampleDir = process.env.EXAMPLE_DIR || 'forge-esm';
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
const packageJsonPath = path.join(__dirname, '..', 'apps', exampleDir, 'package.json');
const appDir = path.join(__dirname, '..', 'apps', exampleDir);
const packageJsonPath = path.join(appDir, 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf-8' }));
const pkg = { packageJson, path: packageJsonPath };
const electronVersion = getElectronVersion(pkg);
const appBuildInfo = await getAppBuildInfo(pkg);
const appBinaryPath = await getBinaryPath(packageJsonPath, appBuildInfo, electronVersion);

globalThis.packageJson = packageJson;
process.env.TEST = 'true';

export const config = {
services: [['electron', { restoreMocks: true }]],
services: [['electron', { rootDir: appDir, restoreMocks: true }]],
capabilities: [
{
'browserName': 'electron',
'wdio:electronServiceOptions': {
appBinaryPath,
appArgs: ['foo', 'bar=baz'],
},
},
Expand Down
12 changes: 3 additions & 9 deletions e2e/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ import path from 'node:path';
import fs from 'node:fs';

import type { NormalizedPackageJson } from 'read-package-up';

import { getAppBuildInfo, getBinaryPath, getElectronVersion } from '@wdio/electron-utils';
import type { WdioElectronConfig } from '@wdio/electron-types';

const exampleDir = process.env.EXAMPLE_DIR || 'forge-esm';
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
const packageJsonPath = path.join(__dirname, '..', 'apps', exampleDir, 'package.json');
const appDir = path.join(__dirname, '..', 'apps', exampleDir);
const packageJsonPath = path.join(appDir, 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf-8' })) as NormalizedPackageJson;
const pkg = { packageJson, path: packageJsonPath };
const electronVersion = getElectronVersion(pkg);
const appBuildInfo = await getAppBuildInfo(pkg);
const appBinaryPath = await getBinaryPath(packageJsonPath, appBuildInfo, electronVersion);

globalThis.packageJson = packageJson;
process.env.TEST = 'true';
Expand All @@ -23,12 +18,11 @@ const isSplashEnabled = Boolean(process.env.ENABLE_SPLASH_WINDOW);
const specs = isSplashEnabled ? ['./test/window/window.spec.ts'] : ['./test/*.spec.ts'];

export const config: WdioElectronConfig = {
services: [['electron', { restoreMocks: true }]],
services: [['electron', { rootDir: appDir, restoreMocks: true }]],
capabilities: [
{
'browserName': 'electron',
'wdio:electronServiceOptions': {
appBinaryPath,
appArgs: ['foo', 'bar=baz'],
},
},
Expand Down

0 comments on commit 53f1a48

Please sign in to comment.