Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: use custom browser binary for connnect tests (#22900)

Max Schmitt154120648207
diff --git a/packages/playwright-core/src/remote/playwrightConnection.ts b/packages/playwright-core/src/remote/playwrightConnection.ts
index a8dc6ef3e3..bcae6b4d69 100644
--- a/packages/playwright-core/src/remote/playwrightConnection.ts
+++ b/packages/playwright-core/src/remote/playwrightConnection.ts
@@ -20,7 +20,7 @@ import { createPlaywright, DispatcherConnection, RootDispatcher, PlaywrightDispa
import { Browser } from '../server/browser';
import { serverSideCallMetadata } from '../server/instrumentation';
import { SocksProxy } from '../common/socksProxy';
-import { assert } from '../utils';
+import { assert, isUnderTest } from '../utils';
import type { LaunchOptions } from '../server/types';
import { AndroidDevice } from '../server/android/android';
import { DebugControllerDispatcher } from '../server/dispatchers/debugControllerDispatcher';
@@ -272,7 +272,7 @@ function launchOptionsHash(options: LaunchOptions) {
return JSON.stringify(copy);
}
-function filterLaunchOptions(options: LaunchOptions) {
+function filterLaunchOptions(options: LaunchOptions): LaunchOptions {
return {
channel: options.channel,
args: options.args,
@@ -284,6 +284,7 @@ function filterLaunchOptions(options: LaunchOptions) {
chromiumSandbox: options.chromiumSandbox,
firefoxUserPrefs: options.firefoxUserPrefs,
slowMo: options.slowMo,
+ executablePath: isUnderTest() ? options.executablePath : undefined,
};
}
diff --git a/tests/config/remoteServer.ts b/tests/config/remoteServer.ts
index a088621281..51c181cdc1 100644
--- a/tests/config/remoteServer.ts
+++ b/tests/config/remoteServer.ts
@@ -30,6 +30,10 @@ export class RunServer implements PlaywrightServer {
async _start(childProcess: CommonFixtures['childProcess']) {
this._process = childProcess({
command: ['node', path.join(__dirname, '..', '..', 'packages', 'playwright-core', 'lib', 'cli', 'cli.js'), 'run-server'],
+ env: {
+ ...process.env,
+ PWTEST_UNDER_TEST: '1',
+ },
});
let wsEndpointCallback;
diff --git a/tests/library/browsertype-launch.spec.ts b/tests/library/browsertype-launch.spec.ts
index 3596ca47b2..172db76b86 100644
--- a/tests/library/browsertype-launch.spec.ts
+++ b/tests/library/browsertype-launch.spec.ts
@@ -67,7 +67,8 @@ it('should reject if launched browser fails immediately', async ({ mode, browser
expect(waitError.message).toContain('== logs ==');
});
-it('should reject if executable path is invalid', async ({ browserType }) => {
+it('should reject if executable path is invalid', async ({ browserType, mode }) => {
+ it.skip(mode === 'service', 'on service mode we dont allow passing custom executable path');
let waitError = null;
await browserType.launch({ executablePath: 'random-invalid-path' }).catch(e => waitError = e);
expect(waitError.message).toContain('Failed to launch');