Skip to content

Commit

Permalink
chore: filter test args out
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed Nov 15, 2022
1 parent 98513c3 commit f9918bc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
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'), options.cwd || process.cwd(), args[0], '--inspect=0', '--remote-debugging-port=0', ...args.slice(1)];

if (os.platform() === 'linux') {
const runningAsRoot = process.geteuid && process.geteuid() === 0;
Expand Down
3 changes: 3 additions & 0 deletions packages/playwright-core/src/server/electron/loader.ts
Expand Up @@ -19,6 +19,9 @@ const path = require('path');
const { chromiumSwitches } = require('../chromium/chromiumSwitches');

const appPath = path.resolve(process.argv[2], process.argv[3]);
// Remove cwd, user app, --inspect=0, --remote-debugging-port=0
process.argv.splice(2, 4);
process.argv[1] = appPath;

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

0 comments on commit f9918bc

Please sign in to comment.