mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 06:02:57 +03: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();
|
|
}
|
|
});
|