Currently, I am implementing unit test for my project and there is a file that contained window.location.href.
window.location.href
I want to mock this to test and here is m
I have resolved this issue by adding writable: true and move it to beforeEach
writable: true
beforeEach
Here is my sample code:
global.window = Object.create(window); const url = "http://dummy.com"; Object.defineProperty(window, "location", { value: { href: url }, writable: true });