title: angular 2.0.0-rc.1 + karma: provide Router
body: <p>When a test needs an instance of the <code>Router</code>, just providing <code>Router</code> itself is not enough:</p>
  
  <pre><code>import {Router} from '@angular/router';
  
  import {it, inject, beforeEachProviders} from '@angular/core/testing';
  import {ComponentToTest} from './component.to.test';
  
  describe('ComponentToTest', () =&gt; {
    beforeEachProviders(() =&gt; [
      Router,    
      ComponentToTest
    ]);
  
  
    it('should call getData() on contruct', inject([Router], (router) =&gt; {
      spyOn(ComponentToTest.prototype, 'getData');
      expect(ComponentToTest.prototype.getData).not.toHaveBeenCalled();
      let component = new ComponentToTest(router);
      expect(ComponentToTest.prototype.getData).toHaveBeenCalled();
    }));
  });
  </code></pre>
  
  <p>Following error will occur:</p>
  
  <blockquote>
    <p>Error: Cannot resolve all parameters for 'Router'(?, ?, ?, ?, ?, ?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'Router' is decorated with Injectable.</p>
  </blockquote>
  
  <p>Yet I don't really know how to resolve the router.</p>
  
  <h1><code>Router</code> parameters</h1>
  
  <h3>_rootComponent: Object,</h3>
  
  <h3>_rootComponentType: Type,</h3>
  
  <p>In alpha we had the <code>RootRouter</code>:
  <code>import {RootRouter} from 'angular2/src/router/router';</code>. This is gone now without any replacement.</p>
  
  <h3>_componentResolver: ComponentResolver,</h3>
  
  <h3>_urlSerializer: RouterUrlSerializer,</h3>
  
  <p>Haven't got a clue on how to provide these.</p>
  
  <h3>_routerOutletMap: RouterOutletMap,</h3>
  
  <p>Seems like this one is already provided in the Router itself</p>
  
  <h3>_location: Location</h3>
  
  <p>This parameter can possibly still be provided by <code>SpyLocation</code>:</p>
  
  <pre><code>import {SpyLocation} from '@angular/common/testing';
  
  describe('ComponentToTest', () =&gt; {
    beforeEachProviders(() =&gt; [
      provide(Location, { useClass: SpyLocation }),
    ]);
  });
  </code></pre>