簡體   English   中英

window.history.pushState 不能開玩笑

[英]window.history.pushState not Working in jest

window.history.pushState 在更新jest:29.xx並安裝jest-environment-jsdom:29.xx 下面的代碼在 jest 27.5.0 中運行良好。

    window.history.pushState({}, 'Test page', '/123')
    expect(window.location.href).toEqual('http://localhost/123')
})

以下文檔可能會幫助您開玩笑地使用pushStatereplaceState進行模擬: https://gist.github.com/the0neWhoKnocks/bdac1d09b93b8418d948558f7ab233d7

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM