test(electron): extend args test (#21388)
This commit is contained in:
parent
fc91e6086b
commit
7f8db8f3c0
1
tests/electron/electron-app-args.js
Normal file
1
tests/electron/electron-app-args.js
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
globalThis.argv = process.argv.slice(0);
|
||||||
|
|
@ -48,9 +48,10 @@ test('should script application', async ({ electronApp }) => {
|
||||||
expect(appPath).toBe(path.resolve(__dirname));
|
expect(appPath).toBe(path.resolve(__dirname));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should preserve args', async ({ electronApp }) => {
|
test('should preserve args', async ({ launchElectronApp }) => {
|
||||||
const argv = await electronApp.evaluate(async () => process.argv);
|
const electronApp = await launchElectronApp('electron-app-args.js', ['foo', 'bar']);
|
||||||
expect(argv.slice(1)).toEqual([expect.stringContaining(path.join('electron', 'electron-app.js'))]);
|
const argv = await electronApp.evaluate(async () => globalThis.argv);
|
||||||
|
expect(argv).toEqual([expect.stringContaining(path.join('dist', 'electron')), expect.stringContaining(path.join('electron', 'electron-app-args.js')), 'foo', 'bar']);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return windows', async ({ electronApp, newWindow }) => {
|
test('should return windows', async ({ electronApp, newWindow }) => {
|
||||||
|
|
@ -118,7 +119,7 @@ test('should return browser window', async ({ launchElectronApp }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should bypass csp', async ({ launchElectronApp, server }) => {
|
test('should bypass csp', async ({ launchElectronApp, server }) => {
|
||||||
const app = await launchElectronApp('electron-app.js', { bypassCSP: true });
|
const app = await launchElectronApp('electron-app.js', [], { bypassCSP: true });
|
||||||
await app.evaluate(electron => {
|
await app.evaluate(electron => {
|
||||||
const window = new electron.BrowserWindow({
|
const window = new electron.BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
|
|
@ -167,7 +168,7 @@ test('should return same browser window for browser view pages', async ({ launch
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should record video', async ({ launchElectronApp }, testInfo) => {
|
test('should record video', async ({ launchElectronApp }, testInfo) => {
|
||||||
const app = await launchElectronApp('electron-window-app.js', {
|
const app = await launchElectronApp('electron-window-app.js', [], {
|
||||||
recordVideo: { dir: testInfo.outputPath('video') }
|
recordVideo: { dir: testInfo.outputPath('video') }
|
||||||
});
|
});
|
||||||
const page = await app.firstWindow();
|
const page = await app.firstWindow();
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import { assert } from '../../packages/playwright-core/lib/utils/debug';
|
||||||
|
|
||||||
type ElectronTestFixtures = PageTestFixtures & {
|
type ElectronTestFixtures = PageTestFixtures & {
|
||||||
electronApp: ElectronApplication;
|
electronApp: ElectronApplication;
|
||||||
launchElectronApp: (appFile: string, options?: any) => Promise<ElectronApplication>;
|
launchElectronApp: (appFile: string, args?: string[], options?: any) => Promise<ElectronApplication>;
|
||||||
newWindow: () => Promise<Page>;
|
newWindow: () => Promise<Page>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -45,8 +45,8 @@ export const electronTest = baseTest.extend<TraceViewerFixtures>(traceViewerFixt
|
||||||
// This env prevents 'Electron Security Policy' console message.
|
// This env prevents 'Electron Security Policy' console message.
|
||||||
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
|
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
|
||||||
const apps: ElectronApplication[] = [];
|
const apps: ElectronApplication[] = [];
|
||||||
await use(async (appFile: string, options?: any[]) => {
|
await use(async (appFile: string, args: string[] = [], options?: any[]) => {
|
||||||
const app = await playwright._electron.launch({ ...options, args: [path.join(__dirname, appFile)] });
|
const app = await playwright._electron.launch({ ...options, args: [path.join(__dirname, appFile), ...args] });
|
||||||
apps.push(app);
|
apps.push(app);
|
||||||
return app;
|
return app;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue