Created
April 26, 2021 19:05
-
-
Save Lokua/3e73e8ea84ae64982d2ebf1b50bb6ed1 to your computer and use it in GitHub Desktop.
Mock location in jsdom tests
This file contains 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
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