Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .claude/rules/testing/playwright-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:<port> 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

Expand Down
8 changes: 7 additions & 1 deletion tests/integration/playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Loading