diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-12-17 12:25:51 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2023-01-03 14:36:11 +0100 |
| commit | 3b2df603c01729812647ed47f6aba19ee638650d (patch) | |
| tree | 7d9c8a5365a38866040fc369403b115898856d51 | |
| parent | 13679cd2b3ace0a7fb3ef4b8a5ec82cdc86a61e0 (diff) | |
| download | mullvadvpn-3b2df603c01729812647ed47f6aba19ee638650d.tar.xz mullvadvpn-3b2df603c01729812647ed47f6aba19ee638650d.zip | |
Split startApp up into multiple functions
| -rw-r--r-- | gui/test/e2e/utils.ts | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/gui/test/e2e/utils.ts b/gui/test/e2e/utils.ts index 1978f4ede1..197eadd818 100644 --- a/gui/test/e2e/utils.ts +++ b/gui/test/e2e/utils.ts @@ -17,27 +17,14 @@ interface History { index: number; } -export const startApp = async ( - options: Parameters<typeof electron.launch>[0], -): Promise<StartAppResponse> => { - process.env.CI = 'e2e'; - const app = await electron.launch(options); - - await app.evaluate(({ webContents }) => { - return new Promise((resolve) => { - webContents.getAllWebContents()[0].on('did-finish-load', resolve); - }); - }); +type LaunchOptions = Parameters<typeof electron.launch>[0]; +export const startApp = async (options: LaunchOptions): Promise<StartAppResponse> => { + const app = await launch(options); const page = await app.firstWindow(); - page.on('pageerror', (error) => { - console.log(error); - }); - - page.on('console', (msg) => { - console.log(msg.text()); - }); + page.on('pageerror', (error) => console.log(error)); + page.on('console', (msg) => console.log(msg.text())); const util: TestUtils = { getByTestId: (id: string) => page.locator(`data-test-id=${id}`), @@ -48,6 +35,19 @@ export const startApp = async ( return { app, page, util }; }; +export const launch = async (options: LaunchOptions): Promise<ElectronApplication> => { + process.env.CI = 'e2e'; + const app = await electron.launch(options); + + await app.evaluate(({ webContents }) => { + return new Promise((resolve) => { + webContents.getAllWebContents()[0].once('did-finish-load', resolve); + }); + }); + + return app; +} + export const currentRouteFactory = (app: ElectronApplication) => { return async () => { return await app.evaluate(({ webContents }) => { |
