Photo by Michael Jasmund on Unsplash

Another unit test and another mocking issue. The code to be tested is more less like this:

To test this component we need to mock:

window.location.pathname

Static mocking if we need only one value:

Dynamic pathname mocking if we need the value to be changed during the test:

window.open

--

--