title: Angular unit test fails because of component in constructor.
body: <p>I have a constructor that uses this: </p>
  
  <pre><code>  constructor(
      public core: CoreComponent,
    ) {
     //
    }
  </code></pre>
  
  <p>But when i try to test these components with a testcase like this: </p>
  
  <pre><code>describe('CoreSubMenuComponent', () =&gt; {
    let component: CoreSubMenuComponent;
    let fixture: ComponentFixture&lt;CoreSubMenuComponent&gt;;
  
    beforeEach(async(() =&gt; {
      TestBed.configureTestingModule({
        imports: [
          TestingModule.forRoot(),
        ]
      }).compileComponents();
    }));
  
    beforeEach(() =&gt; {
      fixture = TestBed.createComponent(CoreSubMenuComponent);
      component = fixture.componentInstance;
      fixture.detectChanges();
    });
  
    it('should create', () =&gt; {
      expect(component).toBeTruthy();
    });
  });
  </code></pre>
  
  <p>I get a null injector error: </p>
  
  <pre><code>Error: StaticInjectorError(DynamicTestModule)[CoreSubMenuComponent -&gt; CoreComponent]: 
    StaticInjectorError(Platform: core)[CoreSubMenuComponent -&gt; CoreComponent]: 
      NullInjectorError: No provider for CoreComponent!
  </code></pre>
  
  <p>It is imported into the testingModule so that isn't the issue. I also tried adding it to the providers array. but that just moves it to the angular renderer which can't be added to the providers array. I also added an <code>@injectable()</code> tag before the <code>@component</code> tag in the <code>CoreComponent</code> but it doesn't change my tests failing. </p>
  
  <p>I tried getting it with <code>@host()</code> but it throws an error. I also tried to get it with the <code>Injector</code> but that also throws an error. These are 4 components that use the <code>CoreComponent</code> as a var to get some info from them but they make the tests fail. All my other tests are pass just fine with over 80 tests. Just these 4 won't work because they try to get properties that are defined in the <code>CoreComponent</code>. </p>
  
  <p>Does someone know how i could reference this component with an instance so that my tests will pass? </p>