diff --git a/.claude/rules/testing/playwright-tests.md b/.claude/rules/testing/playwright-tests.md index 2520787ad3..6b7370f866 100644 --- a/.claude/rules/testing/playwright-tests.md +++ b/.claude/rules/testing/playwright-tests.md @@ -119,8 +119,11 @@ uv run python -m http.server 8765 # Serves from tests/docs/playwright/ ``` -Locally (`reuseExistingServer: !isCI`), Playwright reuses whatever already listens on that port, even another app. -Every spec then fails with element-not-found errors; set `QUARTO_PLAYWRIGHT_PORT` to a free port. +The fixture server is never reused (`reuseExistingServer: false`): if another process answers on the port, the run stops with `http://127.0.0.1: is already used`. +Each concurrent run (another worktree, a second terminal) needs its own free `QUARTO_PLAYWRIGHT_PORT`; the default 8765 suits only one run at a time. +A process answering 404 on the port is not detected as busy; the run then times out after 120 s (`Timed out waiting 120000ms from config.webServer`), so pick another port. + +The revealjs multiplex server has a fixed port, 1948 (set in `tests/docs/playwright/revealjs/multiplex.qmd`), and is reused locally: concurrent runs share the first run's instance, which serves no test fixtures. ## Best Practices diff --git a/tests/integration/playwright/playwright.config.ts b/tests/integration/playwright/playwright.config.ts index c715b56090..689814dc28 100644 --- a/tests/integration/playwright/playwright.config.ts +++ b/tests/integration/playwright/playwright.config.ts @@ -100,7 +100,10 @@ export default defineConfig({ // HTTP server for rendered HTML files command: `uv run python -m http.server ${fixtureServerPort} --bind 127.0.0.1`, url: fixtureServerUrl, - reuseExistingServer: !isCI, + // Never reuse: a server already on the port may be another app, or another + // checkout serving its own tests/docs/playwright, so tests would run + // against the wrong HTML. A busy port fails the run instead. + reuseExistingServer: false, cwd: '../../docs/playwright', // http.server does a reverse DNS lookup before listening, slow on some hosts timeout: 120000, @@ -110,6 +113,9 @@ export default defineConfig({ // Socket.IO multiplex server for RevealJS command: 'npm start', url: 'http://127.0.0.1:1948', + // Reused locally: it relays socket messages and serves no test fixtures, + // and its port is fixed in revealjs/multiplex.qmd, so concurrent runs + // from several checkouts share one instance. reuseExistingServer: !isCI, cwd: './multiplex-server', timeout: 10000,