Skip to content

Instantly share code, notes, and snippets.

@Lokua
Created April 26, 2021 19:05
Show Gist options
  • Save Lokua/3e73e8ea84ae64982d2ebf1b50bb6ed1 to your computer and use it in GitHub Desktop.
Save Lokua/3e73e8ea84ae64982d2ebf1b50bb6ed1 to your computer and use it in GitHub Desktop.
Mock location in jsdom tests
export const mockLocation = value =>
Object.defineProperties(window, {
location: {
value,
writable: true,
},
})
export const mockPathname = pathname =>
mockLocation({
pathname,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment