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

Fixes https://github.com/microsoft/playwright/issues/22898
This commit is contained in:
Max Schmitt 2023-05-10 09:30:56 +02:00 committed by GitHub
parent 5e0574dc44
commit 1541206482
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View file

@ -20,7 +20,7 @@ import { createPlaywright, DispatcherConnection, RootDispatcher, PlaywrightDispa
import { Browser } from '../server/browser'; import { Browser } from '../server/browser';
import { serverSideCallMetadata } from '../server/instrumentation'; import { serverSideCallMetadata } from '../server/instrumentation';
import { SocksProxy } from '../common/socksProxy'; import { SocksProxy } from '../common/socksProxy';
import { assert } from '../utils'; import { assert, isUnderTest } from '../utils';
import type { LaunchOptions } from '../server/types'; import type { LaunchOptions } from '../server/types';
import { AndroidDevice } from '../server/android/android'; import { AndroidDevice } from '../server/android/android';
import { DebugControllerDispatcher } from '../server/dispatchers/debugControllerDispatcher'; import { DebugControllerDispatcher } from '../server/dispatchers/debugControllerDispatcher';
@ -272,7 +272,7 @@ function launchOptionsHash(options: LaunchOptions) {
return JSON.stringify(copy); return JSON.stringify(copy);
} }
function filterLaunchOptions(options: LaunchOptions) { function filterLaunchOptions(options: LaunchOptions): LaunchOptions {
return { return {
channel: options.channel, channel: options.channel,
args: options.args, args: options.args,
@ -284,6 +284,7 @@ function filterLaunchOptions(options: LaunchOptions) {
chromiumSandbox: options.chromiumSandbox, chromiumSandbox: options.chromiumSandbox,
firefoxUserPrefs: options.firefoxUserPrefs, firefoxUserPrefs: options.firefoxUserPrefs,
slowMo: options.slowMo, slowMo: options.slowMo,
executablePath: isUnderTest() ? options.executablePath : undefined,
}; };
} }

View file

@ -30,6 +30,10 @@ export class RunServer implements PlaywrightServer {
async _start(childProcess: CommonFixtures['childProcess']) { async _start(childProcess: CommonFixtures['childProcess']) {
this._process = childProcess({ this._process = childProcess({
command: ['node', path.join(__dirname, '..', '..', 'packages', 'playwright-core', 'lib', 'cli', 'cli.js'), 'run-server'], command: ['node', path.join(__dirname, '..', '..', 'packages', 'playwright-core', 'lib', 'cli', 'cli.js'), 'run-server'],
env: {
...process.env,
PWTEST_UNDER_TEST: '1',
},
}); });
let wsEndpointCallback; let wsEndpointCallback;

View file

@ -67,7 +67,8 @@ it('should reject if launched browser fails immediately', async ({ mode, browser
expect(waitError.message).toContain('== logs =='); 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; let waitError = null;
await browserType.launch({ executablePath: 'random-invalid-path' }).catch(e => waitError = e); await browserType.launch({ executablePath: 'random-invalid-path' }).catch(e => waitError = e);
expect(waitError.message).toContain('Failed to launch'); expect(waitError.message).toContain('Failed to launch');