Skip to content

Commit

Permalink
(feat): allow wdio config to be in a sub directory
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Oct 9, 2023
1 parent 2ca09b3 commit 167c3f8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 47 deletions.
1 change: 1 addition & 0 deletions example-cjs/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions example/e2e/config/wdio.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { config as baseConfig } from '../../wdio.conf.js';

process.env.TEST = 'true';

export const config = {
...baseConfig,
specs: ['../*.spec.ts'],
}
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"ci": "pnpm i && pnpm build && pnpm test",
"clean": "pnpm clean:dist && rm -rf ./node_modules pnpm-lock.yaml ./all-logs",
"clean:dist": "pnpx rimraf ./dist && mkdir -p ./dist",
"test": "wdio run ./wdio.conf.ts"
"test": "wdio run ./wdio.conf.ts && wdio run ./e2e/config/wdio.conf.ts"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.4",
Expand Down
1 change: 1 addition & 0 deletions example/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
"debug": "^4.3.4",
"electron-to-chromium": "^1.4.532",
"find-versions": "^5.1.0",
"node-fetch": "^3.3.2"
"node-fetch": "^3.3.2",
"read-pkg-up": "^10.1.0"
},
"devDependencies": {
"@eslint/js": "^8.50.0",
Expand Down
44 changes: 3 additions & 41 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions src/launcher.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import fs from 'node:fs/promises';
import path from 'node:path';
import findVersions from 'find-versions';
import { readPackageUp, type NormalizedReadResult } from 'read-pkg-up'
import { SevereServiceError } from 'webdriverio';
import { Services, Options, Capabilities } from '@wdio/types';

Expand All @@ -24,8 +23,12 @@ export default class ElectronLaunchService implements Services.ServiceInstance {
: Object.values(capabilities).map((multiremoteOption) => multiremoteOption.capabilities);

const caps = capsList.flatMap((cap) => getElectronCapabilities(cap) as WebDriver.Capabilities[]);
const pkgJSON = JSON.parse((await fs.readFile(path.join(this.#projectRoot, 'package.json'), 'utf-8')).toString());
const { dependencies, devDependencies } = pkgJSON;
const pkg = (
await readPackageUp({ cwd: this.#projectRoot }) ||
{ packageJson: { dependencies: {}, devDependencies: {} } } as NormalizedReadResult
);

const { dependencies, devDependencies } = pkg.packageJson;
const pkgElectronVersion = dependencies?.electron || devDependencies?.electron;
const localElectronVersion = pkgElectronVersion ? findVersions(pkgElectronVersion, { loose: true })[0] : undefined;

Expand Down

0 comments on commit 167c3f8

Please sign in to comment.