I have the following function to test
function tradePage() {
  setTimeout(function() {
    window.location.pathname =          
        I found a working method by declaring in the beginning of the test a global variable:
global.window = { location: { pathname: null } };
and checked this variable like this:
expect(global.window.location.pathname).toEqual('/new-url');
That worked fine.
Object.assign(location, { host: "www.newhost.com", pathname: 'file.txt' });
It will update all the location URL object properties (origin, href, hostname, host).
so the final href property will be https://www.newhost.com/file.txt.
Do this in a beforeEach block.
just call console.log(location) to verify the results. Happy coding!