Move test fixture server off port 3000 and use relative asset URLs#8823
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
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:3000tohttp://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
.tarURLs / 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.
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
test/fixtures.mjs) and update the JSDOM document base URL to match (test/jsdom.mjs)http://localhost:3000/...asset URLs across the test suite to root-relative paths (/test/assets/...), which resolve against the JSDOM document base viaXMLHttpRequest— removing the hardcoded host/port from individual tests.tarURLs (BundleHandler uses globalfetch(), which rejects relative URLs), andsog.test.mjs(deliberately tests absolute resolution against a<base href>)Test robustness improvements (from review):
test/fixtures.mjs:mochaGlobalSetupnow returns a Promise that resolves on the server'slisteningcallback, 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 viajsdomSetup()/jsdomTeardown(), soglobal.XMLHttpRequestexists and its root-relative request URLs resolve regardless of test execution order — the file is now runnable in isolationTest-only change; no public API impact. Full suite passes (1734 passing, 2 pending).