jest-location-mock
jest-location-mock copied to clipboard
window.history.pushState not working as expected
window.history.pushState not working as expected when jest-location-mock is used. clone this repo to reproduce. example (below test fails.)
test('route should be changed', ()=>{
window.history.pushState({}, 'Test page', '/123')
expect(window.location.href).toEqual('http://localhost/123')
})
Currently, this project only mocks window.location
and not the history or navigation APIs. This would be a good future feature 😸
After digging more into #123, it looks like your issue is also a bug with how JSDOM has limited window.history
support, and this mock replaces it.