title: Mocking service in a component - mock ignored
body: <p>This time I'm trying to mock a service (that does http calls) to test a component.</p>
  
  <pre><code>@Component({
    selector: 'ub-funding-plan',
    templateUrl: './funding-plan.component.html',
    styleUrls: ['./funding-plan.component.css'],
    providers: [FundingPlanService]
  })
  export class FundingPlanComponent implements OnInit {
    constructor(private fundingPlanService: FundingPlanService) {
    }
  
    ngOnInit() {
      this.reloadFundingPlans();
    }
  
    reloadFundingPlans() {
      this.fundingPlanService.getFundingPlans().subscribe((fundingPlans: FundingPlan[]) =&gt; {
        this.fundingPlans = fundingPlans;
      }, (error) =&gt; {
        console.log(error);
      });
    }
  }
  </code></pre>
  
  <p>The <a href="https://angular.io/docs/ts/latest/guide/testing.html#!#component-with-dependency" rel="noreferrer">documentation</a> (version 2.0.0) explains that you should mock the service. Using the same <code>TestBed</code> configuration:</p>
  
  <pre><code>describe('Component: FundingPlan', () =&gt; {
    class FundingPlanServiceMock {
      getFundingPlans(): Observable&lt;FundingPlan&gt; { return Observable.of(testFundingPlans) }
    }
  
    beforeEach(() =&gt; {
      TestBed.configureTestingModule({
        declarations: [FundingPlanComponent],
        providers: [
          { provide: FundingPlanService, useClass: FundingPlanServiceMock },
        ]
      });
  
      fixture = TestBed.createComponent(FundingPlanComponent);
      component = fixture.componentInstance;
    });
  
    fit('should display a title', () =&gt; {
      fixture.detectChanges();
      expect(titleElement.nativeElement.textContent).toContain('Funding Plans');
    });
  
  });
  </code></pre>
  
  <p>When I run the test, I get:</p>
  
  <pre><code>Error: No provider for AuthHttp!
  </code></pre>
  
  <p>that is indeedused by the actual service, but not by the mock. So for some reason, the mock is not injected or used.</p>
  
  <p>Any advise? Thanks!</p>