feat(remote): handle timeout manually in browser fixture (#13406)

To make launch/connect not affect the test timeout:
- `browser` fixture is declared with `timeout: 0`.
- Default timeouts are set to 30sec for launch and 3min for connect.
This commit is contained in:
Dmitry Gozman 2022-04-08 13:39:12 -07:00 committed by GitHub
parent 43bf6df2bb
commit 916dd1e698
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,7 +91,7 @@ export const test = _baseTest.extend<TestFixtures, WorkerFixtures>({
_browserOptions: [async ({ playwright, headless, channel, launchOptions }, use) => {
const options: LaunchOptions = {
handleSIGINT: false,
timeout: 0,
timeout: 30000, // 30 seconds
...launchOptions,
};
if (headless !== undefined)
@ -110,14 +110,13 @@ export const test = _baseTest.extend<TestFixtures, WorkerFixtures>({
if (!['chromium', 'firefox', 'webkit'].includes(browserName))
throw new Error(`Unexpected browserName "${browserName}", must be one of "chromium", "firefox" or "webkit"`);
if (connectOptions) {
const browser = await playwright[browserName].connect({
wsEndpoint: connectOptions.wsEndpoint,
const browser = await playwright[browserName].connect(connectOptions.wsEndpoint, {
headers: {
'x-playwright-browser': channel || browserName,
'x-playwright-headless': headless ? '1' : '0',
...connectOptions.headers,
},
timeout: connectOptions.timeout,
timeout: connectOptions.timeout ?? 3 * 60 * 1000, // 3 minutes
});
await use(browser);
await browser.close();
@ -127,7 +126,7 @@ export const test = _baseTest.extend<TestFixtures, WorkerFixtures>({
const browser = await playwright[browserName].launch();
await use(browser);
await browser.close();
}, { scope: 'worker' } ],
}, { scope: 'worker', timeout: 0 } ],
acceptDownloads: [ undefined, { option: true } ],
bypassCSP: [ undefined, { option: true } ],