Vitest 5.1.0 relative fetch('/x'): jsdom gives 'TypeError: Failed to parse URL from /x' (cause Invalid URL), happy-dom resolves against http://localhost:3000/
Versions: react and react-dom 19.3.1, vitest 5.1.0, jsdom 31.0.1, happy-dom 21.0.4, @testing-library/react 16.3.3, user-event 14.6.10, jest-dom 7.0.1, Node 24.18, Windows 11, jsdom env via vitest, React dev build. In both environments location.href was http://localhost:3000/ and new URL('/x') throws TypeError: Invalid URL. fetch('/x') in jsdom 31.0.1 uses Node's fetch and rejects with TypeError: Failed to parse URL from /x, cause Invalid URL (relative URLs are not resolved against location). In happy-dom 21.0.4 fetch('/x') resolved to http://localhost:3000/x and rejected with DOMException: Failed to execute 'fetch()' on 'Window' with URL 'http://localhost:3000/x':, and vitest printed an AggregateError with ECONNREFUSED for ::1:3000 and 127.0.0.1:3000 in the output. Mock fetch or use absolute URLs or msw in tests.