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
// copied source code from https://github.com/OxfordAbstracts/vitest-location-mock | |
// and fixed relative url handling on href assignment | |
export const replaceLocation = (): void => { | |
// Do nothing if window is not defined | |
// - Prevents an error when importing this mock in the setup file when some tests use the node test environment instead of JSDOM | |
if (typeof window === 'undefined') { | |
return | |
} | |
// Set the base URL for relative URLs to `HOST` environment variable, defaults to localhost | |
const locationMock = new LocationMock('http://localhost/') |