title: Angular 7 unit test with window.location.href
body: <p>I am trying to do unit test for my API request to check whether it returns the expected result. In the callback of API request, I have to redirect the page to an external url using window.location.href. 
  Seems the test case trying to redirect the page and headless chrome returns disconnected error. I tried to create mock window service but still not working. </p>
  
  <pre><code>
   this.apiSvc.logout().subscribe((res) =&gt; {
          localStorage.clear();
          window.location.href = res.url;
      })```
  
  App.component.spec.ts
  
   it('should redirect to external page on clicking of logout function', async(() =&gt; { 
      spyOn(apiSvc, 'logout').and.callFake(() =&gt; {
        return of({url: mockWindow.location.href})
      })
      component.onLogout();
      expect(uiApiSvc.logout).toHaveBeenCalled();
    }));
  
  Error message
  Chrome 78.0.3904 (Windows 10.0.0): Executed 7 of 26 DISCONNECTED (30.567 secs / 0.722 secs)
  </code></pre>