import { DebugElement , Type } from '@angular/core' ; import { ComponentFixture } from '@angular/core/testing' ; import { By } from '@angular/platform-browser' ; export function getDirective < T > ( dirType ) { return getByPredicate < T > ( By . directive ( dirType ) ) ; } export function getByPredicate < T > ( predicate ) { return ( fixture ) => getCompFrom < T > ( predicate , fixture ) ; } export function getCompFrom < T > ( predicate , fixture ) { const componentElem = fixture . debugElement . query ( predicate ) ; const component = componentElem . componentInstance as T ; return { componentElem , component } ; }