title: Error: StaticInjectorError(DynamicTestModule)[RouterLinkWithHref -> Router]: (NullInjectorError: No provider for Router!)
body: <p>I am preparing unit test case for AppComponent which have router as a injected dependency and have included RouterTestingModule in my test bed. But still getting a weird error. Please find the error log shown below:</p>
  
  <pre><code>Error: StaticInjectorError(DynamicTestModule)[RouterLinkWithHref -&gt; Router]: 
    StaticInjectorError(Platform: core)[RouterLinkWithHref -&gt; Router]: 
      NullInjectorError: No provider for Router!
  </code></pre>
  
  <blockquote>
    <p>error properties: Object({ ngTempTokenPath: null, ngTokenPath: [
    'RouterLinkWithHref', Function ], ngDebugContext: DebugContext_({
    view: Object({ def: Object({ factory: Function, nodeFlags: 671753,
    rootNodeFlags: 1, nodeMatchedQueries: 0, flags: 0, nodes: [ Object({
    nodeIndex: 0, parent: null, renderParent: null, bindingIndex: 0,
    outputIndex: 0, checkIndex: 0, flags: 1, childFlags: 671753,
    directChildFlags: 1, childMatchedQueries: 0, matchedQueries: Object({ 
    }), matchedQueryIds: 0, references: Object({  }), ngContentIndex:
    null, childCount: 10, bindings: [ Object({ flags: 8, ns: '', name:
    'className', nonMinifiedName: 'className', securityContext: 0, suffix:
    undefined }) ], bindingFlags: 8, outputs: [  ], element: Object({ ns:
    '', name: 'nav', attrs: [ Array ], template: null, componentProvider:
    null, componentView: null, componentRendererType: null,
    publicProviders: null({  }), allProviders: null({  }), handleEvent:
    Function }), provider: null, text: null, query: null, ngContent: null
    }), Object({  ... Error:
    StaticInjectorError(DynamicTestModule)[RouterLinkWithHref -> Router]: 
    StaticInjectorError(Platform: core)[RouterLinkWithHref -> Router]: 
        NullInjectorError: No provider for Router!
        at NullInjector.get (webpack:///./node_modules/@angular/core/fesm5/core.js?:1360:19)
        at resolveToken (webpack:///./node_modules/@angular/core/fesm5/core.js?:1598:24)
        at tryResolveToken (webpack:///./node_modules/@angular/core/fesm5/core.js?:1542:16)
        at StaticInjector.get (webpack:///./node_modules/@angular/core/fesm5/core.js?:1439:20)
        at resolveToken (webpack:///./node_modules/@angular/core/fesm5/core.js?:1598:24)
        at tryResolveToken (webpack:///./node_modules/@angular/core/fesm5/core.js?:1542:16)
        at StaticInjector.get (webpack:///./node_modules/@angular/core/fesm5/core.js?:1439:20)
        at resolveNgModuleDep (webpack:///./node_modules/@angular/core/fesm5/core.js?:8667:29)
        at NgModuleRef_.get (webpack:///./node_modules/@angular/core/fesm5/core.js?:9355:16)
        at resolveDep (webpack:///./node_modules/@angular/core/fesm5/core.js?:9720:45)</p>
  </blockquote>
  
  <p>Please help. I have already tried removing router links from my template.</p>
  
  <pre><code>TestBed.configureTestingModule({
      declarations: [
        AppComponent
      ],
      imports: [
        CoreModule.forRoot(),
        RouterTestingModule.withRoutes(routes),
      ],
      providers: [
        {provide: APP_BASE_HREF, useValue: '/'},
      ]
  }
  </code></pre>