Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(electron): filter test args out #18822

Merged
merged 1 commit into from Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/electron/electron.ts
Expand Up @@ -130,7 +130,7 @@ export class Electron extends SdkObject {
controller.setLogName('browser');
return controller.run(async progress => {
let app: ElectronApplication | undefined = undefined;
const electronArguments = [require.resolve('./loader'), options.cwd || process.cwd(), ...args, '--inspect=0', '--remote-debugging-port=0'];
const electronArguments = [require.resolve('./loader'), '--inspect=0', '--remote-debugging-port=0', options.cwd || process.cwd(), ...args];

if (os.platform() === 'linux') {
const runningAsRoot = process.geteuid && process.geteuid() === 0;
Expand Down
8 changes: 7 additions & 1 deletion packages/playwright-core/src/server/electron/loader.ts
Expand Up @@ -18,7 +18,13 @@ const { app } = require('electron');
const path = require('path');
const { chromiumSwitches } = require('../chromium/chromiumSwitches');

const appPath = path.resolve(process.argv[2], process.argv[3]);
// Command line is like:
// [Electron, loader.js, --inspect=0, --remote-debugging-port=0, options.cwd, app.js, ...args]
const appPath = path.resolve(process.argv[4], process.argv[5]);
process.argv.splice(2, 4);
process.argv[1] = appPath;
// Now it is like
// [Electron, app.js, ...args]

for (const arg of chromiumSwitches) {
const match = arg.match(/--([^=]*)=?(.*)/)!;
Expand Down
5 changes: 5 additions & 0 deletions tests/electron/electron-app.spec.ts
Expand Up @@ -38,6 +38,11 @@ test('should script application', async ({ electronApp }) => {
expect(appPath).toBe(path.resolve(__dirname));
});

test('should preserve args', async ({ electronApp }) => {
const argv = await electronApp.evaluate(async ({ app }) => process.argv);
expect(argv.slice(1)).toEqual([expect.stringContaining('electron/electron-app.js')]);
});

test('should return windows', async ({ electronApp, newWindow }) => {
const window = await newWindow();
expect(electronApp.windows()).toEqual([window]);
Expand Down