Skip to content

test(e2e): let TEST_HOST choose the test server's interface - #132

Merged
ErickXavier merged 1 commit into
mainfrom
fix/test-server-host
Nov 24, 2026
Merged

ErickXavier merged 1 commit into
mainfrom
fix/test-server-host

Conversation

@ErickXavier

Copy link
Copy Markdown
Collaborator

Summary

test-server.js always listened on every interface, so the example pages were reachable from the local network during e2e and verification runs (finding from the verify-nojs-elements skill, #131).

  • TEST_HOST picks the interface, for example TEST_HOST=127.0.0.1 for loopback only. It pairs with the existing TEST_PORT. Unset, the server listens on all interfaces exactly as before, so npm scripts, the Playwright webServer and CI are unchanged.
  • The startup line names the bound address: NoJS-Elements Test Server — http://localhost:<port> (bound to <address>).
  • verify-nojs-elements launches with TEST_HOST=127.0.0.1; its Isolation note is updated.
  • CHANGELOG.md Unreleased entry. No version bump.

Evidence (fail before, pass after)

__tests__/test-server.test.js (Jest, node environment) starts the real test-server.js on a free port and requests /package.json over IPv4 and, where the machine has an IPv6 loopback, over ::1.

Check Before (cd2703a) After
"TEST_HOST=127.0.0.1 serves on 127.0.0.1 and nowhere else" failed: ::1 answered 200, expected ECONNREFUSED passes
"without TEST_HOST it listens on every interface, as before" passes passes
verify-nojs-elements launch on 4321 n/a listen socket 127.0.0.1:4321; curl via 127.0.0.1 200, via [::1] refused; modal and dnd journeys pass
Full suites n/a Jest 853 passed, 5 skipped (unchanged skips); version:check OK

Blast radius

  • The fact this is safe because of: with TEST_HOST unset, server.listen(PORT, undefined, cb) binds exactly what server.listen(PORT, cb) bound. The second test runs the unset case and still reaches the server over both 127.0.0.1 and ::1.
  • Playwright: e2e/playwright.config.ts is untouched. The whole Chromium e2e suite passes with the default (234 passed). With TEST_HOST=127.0.0.1, the modal and dnd specs also pass (25 passed): baseURL http://localhost:<port> still reaches the server, because Chromium falls back from ::1 to 127.0.0.1.
  • Nothing else reads TEST_HOST. docs/dev-server.js (npm start) is a separate server and keeps its 3000-3010 port scan.

test-server.js always listened on every interface, so the example
pages were reachable from the local network during e2e and
verification runs. TEST_HOST (for example 127.0.0.1) picks the
interface; unset keeps the old behavior. verify-nojs-elements now
launches with TEST_HOST=127.0.0.1.
@ErickXavier
ErickXavier merged commit 4d94f47 into main Nov 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant