How to mock [removed].href with Jest + Vuejs?

后端 未结 13 561
轻奢々
轻奢々 2020-12-24 00:32

Currently, I am implementing unit test for my project and there is a file that contained window.location.href.

I want to mock this to test and here is m

13条回答
  •  一生所求
    2020-12-24 01:04

    Can rewrite window.location by delete this global in every test.

    delete global.window.location;
    const href = 'http://localhost:3000';
    global.window.location = { href };
    

提交回复
热议问题