Skip to content

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

test: cover MCP CDP header env config (#41452)

Alex Tumanov1120121d1c0d
diff --git a/tests/mcp/config-resolve.spec.ts b/tests/mcp/config-resolve.spec.ts
index f4cc2c35f2..d961bfec20 100644
--- a/tests/mcp/config-resolve.spec.ts
+++ b/tests/mcp/config-resolve.spec.ts
@@ -248,6 +248,21 @@ test.describe('merge order', () => {
const config = await resolveCLIConfigForMCP({ config: configFile }, emptyEnv);
expect(config.browser.cdpHeaders).toEqual({ Authorization: 'Bearer token-from-file' });
});
+
+ test('env browser.cdpHeaders overrides config file and preserves colons in values', async ({}, testInfo) => {
+ const configFile = testInfo.outputPath('config.json');
+ const fileConfig: Config = {
+ browser: {
+ cdpEndpoint: 'ws://example.invalid',
+ cdpHeaders: { Authorization: 'Bearer token-from-file' },
+ },
+ };
+ await fs.promises.writeFile(configFile, JSON.stringify(fileConfig));
+ const config = await resolveCLIConfigForMCP({ config: configFile }, {
+ PLAYWRIGHT_MCP_CDP_HEADERS: 'X-Forwarded-Proto: value:with:colons',
+ });
+ expect(config.browser.cdpHeaders).toEqual({ 'X-Forwarded-Proto': 'value:with:colons' });
+ });
});
// ---------------------------------------------------------------------------