Skip to content

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

fix(test-runner): throw error if no port and url is given (#20497)

Max Schmitt01790c0e19e9
diff --git a/packages/playwright-test/src/plugins/webServerPlugin.ts b/packages/playwright-test/src/plugins/webServerPlugin.ts
index 85eedd2c6c..67ead61ae6 100644
--- a/packages/playwright-test/src/plugins/webServerPlugin.ts
+++ b/packages/playwright-test/src/plugins/webServerPlugin.ts
@@ -210,7 +210,7 @@ export const webServerPluginsForConfig = (config: FullConfigInternal): TestRunne
const shouldSetBaseUrl = !!config.webServer;
const webServerPlugins = [];
for (const webServerConfig of config._webServers) {
- if (webServerConfig.port !== undefined && webServerConfig.url !== undefined)
+ if ((!webServerConfig.port && !webServerConfig.url) || (webServerConfig.port && webServerConfig.url))
throw new Error(`Exactly one of 'port' or 'url' is required in config.webServer.`);
const url = webServerConfig.url || `http://localhost:${webServerConfig.port}`;