Skip to content

Move test fixture server off port 3000 and use relative asset URLs#8823

Merged
mvaligursky merged 2 commits into
mainfrom
mv-test-port
Jun 2, 2026
Merged

Move test fixture server off port 3000 and use relative asset URLs#8823
mvaligursky merged 2 commits into
mainfrom
mv-test-port

Conversation

@mvaligursky

@mvaligursky mvaligursky commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Engine tests started their fixture HTTP server on port 3000, colliding with the developer-site Docusaurus dev server (also default 3000) when both run together.

Changes:

  • Move the test fixture server from port 3000 to 3210 (test/fixtures.mjs) and update the JSDOM document base URL to match (test/jsdom.mjs)
  • Convert hardcoded http://localhost:3000/... asset URLs across the test suite to root-relative paths (/test/assets/...), which resolve against the JSDOM document base via XMLHttpRequest — removing the hardcoded host/port from individual tests
  • Keep absolute URLs only where required: the bundle .tar URLs (BundleHandler uses global fetch(), which rejects relative URLs), and sog.test.mjs (deliberately tests absolute resolution against a <base href>)

Test robustness improvements (from review):

  • test/fixtures.mjs: mochaGlobalSetup now returns a Promise that resolves on the server's listening callback, so Mocha waits for the server to be ready before any test issues a request (avoids a startup race)
  • test/platform/net/http.test.mjs: now sets up its own JSDOM document via jsdomSetup()/jsdomTeardown(), so global.XMLHttpRequest exists and its root-relative request URLs resolve regardless of test execution order — the file is now runnable in isolation

Test-only change; no public API impact. Full suite passes (1734 passing, 2 pending).

Engine tests started their fixture HTTP server on port 3000, colliding with
the developer-site Docusaurus dev server (also default 3000) when both run
together. Move the server to port 3210 and convert hardcoded asset URLs to
root-relative paths so the host/port no longer appears in individual tests.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the engine’s Mocha fixture HTTP server setup and test asset URL usage to avoid port collisions (notably with dev servers on 3000) and to remove hardcoded host/port from most tests by relying on JSDOM’s document base URL.

Changes:

  • Moved the fixture server and JSDOM document base URL from http://localhost:3000 to http://localhost:3210.
  • Converted most test asset URLs from absolute http://localhost:... to root-relative /test/assets/....
  • Kept absolute URLs only where required (e.g., bundle .tar URLs / explicit base-href resolution tests).

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/platform/net/http.test.mjs Switched http.get calls to root-relative URLs.
test/jsdom.mjs Updated the JSDOM document base URL to port 3210.
test/framework/scene-registry.test.mjs Switched asset base path to /test/assets/.
test/framework/parsers/sog.test.mjs Updated explicit absolute base URL expectations to port 3210.
test/framework/handlers/sprite-handler.test.mjs Updated sprite/atlas fixture URLs to root-relative paths.
test/framework/handlers/bundle-hander.test.mjs Updated required absolute bundle .tar URLs to port 3210.
test/framework/components/sprite/component.test.mjs Updated sprite fixture URLs to root-relative paths.
test/framework/components/script/component.test.mjs Updated script and scene URLs to root-relative paths.
test/framework/components/particlesystem/component.test.mjs Updated particle system fixture URLs to root-relative paths.
test/framework/components/model/component.test.mjs Updated model/material fixture URLs to root-relative paths.
test/framework/components/element/text-element.test.mjs Updated font fixture URLs to root-relative paths.
test/framework/components/element/image-element.test.mjs Updated sprite/material/texture fixture URLs to root-relative paths.
test/framework/components/animation/component.test.mjs Updated animation/model fixture URLs to root-relative paths.
test/framework/asset/asset-registry.test.mjs Updated assetPath base to /test/assets/.
test/framework/asset/asset-list-loader.test.mjs Updated assetPath base to /test/assets/.
test/fixtures.mjs Moved fixture server to port 3210.
test/assets/sprites/red-sprite.json Updated atlas reference to root-relative URL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/fixtures.mjs Outdated
Comment thread test/platform/net/http.test.mjs
…ttp test

- fixtures.mjs: mochaGlobalSetup returns a Promise resolving on the server's
  listening callback, so Mocha waits before any test issues a request
- http.test.mjs: set up its own JSDOM document so global.XMLHttpRequest exists
  and root-relative URLs resolve regardless of test ordering
@mvaligursky mvaligursky merged commit 583aa54 into main Jun 2, 2026
8 checks passed
@mvaligursky mvaligursky deleted the mv-test-port branch June 2, 2026 13:45
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.

2 participants