How to fix Error: Not implemented: navigation (except hash changes)
Alternate solution: You could mock the location object
const mockResponse = jest.fn();
Object.defineProperty(window, 'location', {
value: {
hash: {
endsWith: mockResponse,
includes: mockResponse,
},
assign: mockResponse,
},
writable: true,
});
Alternative version that worked for me with jest
only:
let assignMock = jest.fn();
delete window.location;
window.location = { assign: assignMock };
afterEach(() => {
assignMock.mockClear();
});
Reference: https://remarkablemark.org/blog/2018/11/17/mock-window-location/