forked from MarcusFelling/demo.playwright
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.spec.ts
32 lines (27 loc) · 970 Bytes
/
example.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* Example automation for electron
* @see https://playwright.dev/docs/api/class-electron
*/
import {_electron as electron, test, expect, ElectronApplication} from '@playwright/test';
let electronApp: ElectronApplication;
test.beforeEach(async () => {
// Launch Electron app.
electronApp = await electron.launch({args: ['dist/index.js']});
});
test.afterEach(async () => {
// Launch Electron app.
await electronApp.close();
});
test('app path', async () => {
// Evaluation expression in the Electron context.
const appPath = await electronApp.evaluate(async ({app}) => {
// This runs in the main Electron process, parameter here is always
// the result of the require('electron') in the main app script.
return app.getAppPath();
});
expect(appPath).toContain('electron/dist');
});
test('app title', async () => {
// Get the first window that the app opens, wait if necessary.
const window = await electronApp.firstWindow();
});