Skip to content

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

test(cdp): properly restore HTTP_PROXY env var to fix flake (#40464)

Dmitry Gozman82cdf3d7b42f
diff --git a/tests/library/chromium/connect-over-cdp.spec.ts b/tests/library/chromium/connect-over-cdp.spec.ts
index c5a06d0d6c..8876604d9b 100644
--- a/tests/library/chromium/connect-over-cdp.spec.ts
+++ b/tests/library/chromium/connect-over-cdp.spec.ts
@@ -439,10 +439,14 @@ test('should use env proxy with connectOverCDP discovery request', async ({ brow
const oldValue = process.env.HTTP_PROXY;
try {
process.env.HTTP_PROXY = proxyServer.URL;
- await browserType.connectOverCDP(server.PREFIX).catch(() => {});
+ const error = await browserType.connectOverCDP(server.PREFIX).catch(e => e);
+ expect(error.message).toContain(`Unexpected status 404 when connecting to ${server.PREFIX}/json/version/`);
expect(proxyServer.requestUrls).toEqual([`${server.PREFIX}/json/version/`]);
} finally {
- process.env.HTTP_PROXY = oldValue;
+ if (oldValue === undefined)
+ delete process.env.HTTP_PROXY;
+ else
+ process.env.HTTP_PROXY = oldValue;
}
});