Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: automatically detect the dev server (#29176)
Pavel Feldman6a14b1dc51d1
diff --git a/packages/playwright-core/src/utils/network.ts b/packages/playwright-core/src/utils/network.tsindex 8cacb8aeb6..bf834abaa0 100644--- a/packages/playwright-core/src/utils/network.ts+++ b/packages/playwright-core/src/utils/network.ts@@ -181,8 +181,9 @@ export async function isURLAvailable(url: URL, ignoreHTTPSErrors: boolean, onLogasync function httpStatusCode(url: URL, ignoreHTTPSErrors: boolean, onLog?: (data: string) => void, onStdErr?: (data: string) => void): Promise<number> {return new Promise(resolve => {- onLog?.(`HTTP GET: ${url}`);+ onLog?.(`HTTP HEAD: ${url}`);httpRequest({+ method: 'HEAD',url: url.toString(),headers: { Accept: '*/*' },rejectUnauthorized: !ignoreHTTPSErrorsdiff --git a/packages/playwright-ct-core/src/vitePlugin.ts b/packages/playwright-ct-core/src/vitePlugin.tsindex a1809676b4..afe3fff9e9 100644--- a/packages/playwright-ct-core/src/vitePlugin.ts+++ b/packages/playwright-ct-core/src/vitePlugin.ts@@ -56,7 +56,7 @@ export function createPlugin(const endpoint = resolveEndpoint(config);const protocol = endpoint.https ? 'https:' : 'http:';const url = new URL(`${protocol}//${endpoint.host}:${endpoint.port}`);- if (process.env.PW_CT_DEV && await isURLAvailable(url, true)) {+ if (await isURLAvailable(url, true)) {// eslint-disable-next-line no-consoleconsole.log(`Test Server is already running at ${url.toString()}, using it.\n`);process.env.PLAYWRIGHT_TEST_BASE_URL = url.toString();diff --git a/tests/playwright-test/playwright.ct-build.spec.ts b/tests/playwright-test/playwright.ct-build.spec.tsindex 6fd4f6d474..6304b44a12 100644--- a/tests/playwright-test/playwright.ct-build.spec.ts+++ b/tests/playwright-test/playwright.ct-build.spec.ts@@ -21,7 +21,12 @@ test.describe.configure({ mode: 'parallel' });const playwrightConfig = `import { defineConfig } from '@playwright/experimental-ct-react';- export default defineConfig({ projects: [{name: 'foo'}] });+ export default defineConfig({+ use: {+ ctPort: ${3200 + (+process.env.TEST_PARALLEL_INDEX)}+ },+ projects: [{name: 'foo'}],+ });`;test('should work with the empty component list', async ({ runInlineTest }, testInfo) => {diff --git a/tests/playwright-test/playwright.ct-react.spec.ts b/tests/playwright-test/playwright.ct-react.spec.tsindex f565c80ea2..7e27149317 100644--- a/tests/playwright-test/playwright.ct-react.spec.ts+++ b/tests/playwright-test/playwright.ct-react.spec.ts@@ -18,7 +18,12 @@ import { test, expect } from './playwright-test-fixtures';const playwrightConfig = `import { defineConfig } from '@playwright/experimental-ct-react';- export default defineConfig({ projects: [{name: 'foo'}] });+ export default defineConfig({+ use: {+ ctPort: ${3200 + (+process.env.TEST_PARALLEL_INDEX)}+ },+ projects: [{name: 'foo'}],+ });`;test('should work with TSX', async ({ runInlineTest }) => {@@ -420,7 +425,8 @@ test('should handle the vite host config', async ({ runInlineTest }) => {test('pass component', async ({ page, mount }) => {const component = await mount(<Component />);- await expect(page).toHaveURL('http://127.0.0.1:3100/');+ const host = await page.evaluate(() => window.location.hostname);+ await expect(host).toBe('127.0.0.1');});`,}, { workers: 1 });diff --git a/tests/playwright-test/ui-mode-test-ct.spec.ts b/tests/playwright-test/ui-mode-test-ct.spec.tsindex 12c3cda430..c4cc2492a9 100644--- a/tests/playwright-test/ui-mode-test-ct.spec.ts+++ b/tests/playwright-test/ui-mode-test-ct.spec.ts@@ -21,7 +21,11 @@ test.describe.configure({ mode: 'parallel', retries });const basicTestTree = {'playwright.config.ts': `import { defineConfig } from '@playwright/experimental-ct-react';- export default defineConfig({});+ export default defineConfig({+ use: {+ ctPort: ${3200 + (+process.env.TEST_PARALLEL_INDEX)}+ }+ });`,'playwright/index.html': `<script type="module" src="./index.ts"></script>`,'playwright/index.ts': ``,diff --git a/tests/playwright-test/web-server.spec.ts b/tests/playwright-test/web-server.spec.tsindex 5fac838dac..0cadbddad8 100644--- a/tests/playwright-test/web-server.spec.ts+++ b/tests/playwright-test/web-server.spec.ts@@ -661,7 +661,7 @@ test('should check ipv4 and ipv6 with happy eyeballs when URL is passed', asyncexpect(result.exitCode).toBe(0);expect(result.passed).toBe(1);expect(result.output).toContain('Process started');- expect(result.output).toContain(`HTTP GET: http://localhost:${port}/`);+ expect(result.output).toContain(`HTTP HEAD: http://localhost:${port}/`);expect(result.output).toContain('WebServer available');});