test: clean up connect options set for debug controller (#18317)

This commit is contained in:
Pavel Feldman 2022-10-25 12:03:04 -04:00 committed by GitHub
parent d8ec7cba47
commit d819f97f40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View file

@ -137,6 +137,10 @@ export class Backend extends EventEmitter {
}; };
} }
async close() {
await this._transport.closeAndWait();
}
async resetForReuse() { async resetForReuse() {
await this._send('resetForReuse'); await this._send('resetForReuse');
} }

View file

@ -38,13 +38,16 @@ const test = baseTest.extend<Fixtures>({
const backend = new Backend(); const backend = new Backend();
await backend.connect(wsEndpoint); await backend.connect(wsEndpoint);
await use(backend); await use(backend);
await backend.close();
}, },
connectedBrowser: async ({ playwright, wsEndpoint }, use) => { connectedBrowser: async ({ playwright, wsEndpoint }, use) => {
const oldValue = (playwright.chromium as any)._defaultConnectOptions;
(playwright.chromium as any)._defaultConnectOptions = { (playwright.chromium as any)._defaultConnectOptions = {
wsEndpoint, wsEndpoint,
headers: { 'x-playwright-reuse-context': '1', }, headers: { 'x-playwright-reuse-context': '1', },
}; };
const browser = await playwright.chromium.launch(); const browser = await playwright.chromium.launch();
(playwright.chromium as any)._defaultConnectOptions = oldValue;
await use(browser as any); await use(browser as any);
await browser.close(); await browser.close();
}, },