title: Angular2 Jasmine test case Can't resolve all parameters for NavBarComponent: (?, ?)
body: <p>I'm working on Angular2 Angular CLI project and I'm writing Jasmine test cases for components, components of my project dependent on services (They are params to component constructors). When I try to write tests for components, I get <strong>Can't resolve all parameters for NavBarComponent: (?, ?)</strong>.</p>
  
  <p>I have mocked services and was able to write tests for services. However, I'm getting above issue when for component test cases. </p>
  
  <p>It will be great to know how to fix this issue.  </p>
  
  <p>Here is my code</p>
  
  <pre><code>export class NavBarComponent implements OnInit {
        constructor(private sanitizer: DomSanitizer,private service:       AppService){
  
          }
  }
  </code></pre>
  
  <p>Spec file</p>
  
  <pre><code>describe('NavBarComponent component ', () =&gt; {
  
      beforeEach(() =&gt; {
          TestBed.configureTestingModule({
              imports: [FormsModule, HttpModule],
              declarations: [NavBarComponent],
              providers: [{ provide: Router, useClass: class { navigate = jasmine.createSpy('navigate'); }}, 
              {provide: AppService, useClass: AppService},
              {provide: DomSanitizer, useClass: DomSanitizer}],
              schemas: [NO_ERRORS_SCHEMA]
          });
      });
  
  
       it('check the number of li elements in NavBarComponent component',
          async(() =&gt; {
              TestBed
                  .compileComponents()
                  .then(() =&gt; {
                      let fixture = TestBed.createComponent(NavBarComponent);
                      let userDOMEl = fixture.debugElement.nativeElement;
                      expect(userDOMEl.querySelectorAll('li').length).toEqual(17);
                  });
          }));
  
  
  });
  </code></pre>