更新时间:2023-01-15 13:39:35
通过在测试开始时声明一个全局变量,我找到了一个可行的方法:
I found a working method by declaring in the beginning of the test a global variable:
global.window = { location: { pathname: null } };
并像这样检查这个变量:
and checked this variable like this:
expect(global.window.location.pathname).toEqual('/new-url');
效果很好.