Skip to content

Commit 0d09fd0

Browse files
committed
Update test setup to select second Electron window
Modified the test fixture to wait for and use the second Electron window instead of the first. Introduced a CustomFixtures interface for type safety in test extension.
1 parent d08e510 commit 0d09fd0

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tests/fixtures.mts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { join } from 'path'
44
import { main } from '../package.json'
55
import TestUtil from './testUtil.mjs'
66

7+
interface CustomFixtures {
8+
util: TestUtil
9+
}
10+
711
let appElectron: ElectronApplication
812
let page: Page
913

@@ -32,7 +36,14 @@ export const beforeAll = async () => {
3236
NODE_ENV: 'production'
3337
}
3438
})
35-
page = await appElectron.firstWindow()
39+
const splashWindow = await appElectron.firstWindow()
40+
41+
const secondWindow = await appElectron.waitForEvent('window', {
42+
predicate: (window) => window !== splashWindow,
43+
timeout: 10000
44+
})
45+
46+
page = secondWindow
3647

3748
await page.waitForEvent('load')
3849

@@ -59,8 +70,7 @@ export const afterAll = async () => {
5970
await appElectron.close()
6071
}
6172

62-
export const test = base.test.extend({
63-
// eslint-disable-next-line no-empty-pattern
73+
export const test = base.test.extend<CustomFixtures>({
6474
page: async ({}, use) => {
6575
await use(page)
6676
},

0 commit comments

Comments
 (0)