window.history.pushState not working after updating jest:29.xx
and installing jest-environment-jsdom:29.xx
. below code works fine in jest 27.5.0.
window.history.pushState({}, 'Test page', '/123')
expect(window.location.href).toEqual('http://localhost/123')
})
Following documentation might help you to mock with pushState and replaceState in jest: https://gist.github.com/the0neWhoKnocks/bdac1d09b93b8418d948558f7ab233d7
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.