mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
38 lines
997 B
TypeScript
38 lines
997 B
TypeScript
![]() |
import '../base.fixture';
|
||
|
import {ElectronApplication, ElectronLauncher, ElectronPage} from '../../electron-types';
|
||
|
import path from 'path';
|
||
|
|
||
|
const electronName = process.platform === 'win32' ? 'electron.cmd' : 'electron';
|
||
|
|
||
|
declare global {
|
||
|
interface FixtureState {
|
||
|
application: ElectronApplication;
|
||
|
window: ElectronPage;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
declare module '../../index' {
|
||
|
const electron: ElectronLauncher
|
||
|
}
|
||
|
|
||
|
registerFixture('application', async ({playwright}, test) => {
|
||
|
const electronPath = path.join(__dirname, '..', '..', 'node_modules', '.bin', electronName);
|
||
|
const application = await playwright.electron.launch(electronPath, {
|
||
|
args: [path.join(__dirname, 'testApp.js')],
|
||
|
});
|
||
|
try {
|
||
|
await test(application);
|
||
|
} finally {
|
||
|
await application.close();
|
||
|
}
|
||
|
});
|
||
|
|
||
|
registerFixture('window', async ({application}, test) => {
|
||
|
const page = await application.newBrowserWindow({ width: 800, height: 600 });
|
||
|
try {
|
||
|
await test(page);
|
||
|
} finally {
|
||
|
await page.close();
|
||
|
}
|
||
|
});
|