title: Angular, spy on Location.go in unit test karma/jasmine
body: <p>My component does a simple rewrite of the url using location.go:</p>
  
  <pre><code>import { Location } from '@angular/common';
  ...
  constructor(private location: Location){}
  ...
  this.location.go(`${this.router.url}/${this.projectId}`);
  </code></pre>
  
  <p>My unit test fails saying <code>Expected spy go to have been called</code></p>
  
  <pre><code>import { Location } from '@angular/common';
  ...
  configureTestSuite(() =&gt; {
    ...
    TestBed.configureTestingModule({
      ...
      imports: [..., RouterTestingModule],
      providers: [
        Location,
      ],
      ...
    });
  
    loc = TestBed.get(Location);
  });
  ...
  describe('Add Project', () =&gt; {
    it('should add new project', fakeAsync(() =&gt; {
    ...
    spyOn(loc, 'go');
    ...
    tick();
    expect(loc.go).toHaveBeenCalled();
    }));
  });
  </code></pre>