我有location.reload()
的函数。如何为重新加载功能的测试编写角度单元测试用例。
searchregion(){ location.reload(); }
我试图编写如下测试用例。但它显示错误“error::找不到要监视reload()的对象”:
it('should test the reload functions', () =>{ spyOn(location, 'reload'); component.searchregion(); expect(location.reload).toHaveBeenCalled(); });
有人能帮我吗?