-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18d9089
commit 289e6ce
Showing
5 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import url from 'node:url'; | ||
import path from 'node:path'; | ||
import fs from 'node:fs'; | ||
|
||
import { startSession } from 'wdio-electron-service'; | ||
import { expect } from '@wdio/globals'; | ||
import type { PackageJson } from 'read-package-up'; | ||
|
||
const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); | ||
const packageJson = JSON.parse( | ||
fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), { encoding: 'utf-8' }), | ||
) as PackageJson; | ||
|
||
const browser = await startSession({ | ||
appBinaryPath: './out/wdio-electron-service-example-darwin-arm64/wdio-electron-service-example.app', | ||
appArgs: ['foo', 'bar=baz'], | ||
}); | ||
|
||
const appName = await browser.electron.execute((electron) => electron.app.getName()); | ||
expect(appName).toStrictEqual(packageJson.name); | ||
const appVersion = await browser.electron.execute((electron) => electron.app.getVersion()); | ||
expect(appVersion).toStrictEqual(packageJson.version); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { remote } from 'webdriverio'; | ||
|
||
import ElectronWorkerService from './service.js'; | ||
import ElectronLaunchService from './launcher.js'; | ||
import { CUSTOM_CAPABILITY_NAME } from './constants.js'; | ||
import { ElectronServiceOptions } from './types.js'; | ||
import { Options } from '@wdio/types'; | ||
|
||
export async function init(opts: ElectronServiceOptions) { | ||
const testRunnerOpts = { ...opts } as Options.Testrunner; | ||
let capabilities = { | ||
browserName: 'electron', | ||
[CUSTOM_CAPABILITY_NAME]: { | ||
...opts, | ||
}, | ||
}; | ||
|
||
const launcher = new ElectronLaunchService(opts, capabilities, testRunnerOpts); | ||
const service = new ElectronWorkerService(opts); | ||
|
||
await launcher.onPrepare(testRunnerOpts, [capabilities]); | ||
|
||
console.log('setting caps', capabilities); | ||
|
||
// initialise session | ||
const browser = await remote({ | ||
capabilities, | ||
}); | ||
|
||
await service.before(capabilities, [], browser); | ||
|
||
return browser; | ||
} |