Angular2 Inject ElementRef in unit test

I encounter Can’t resolve all parameters for ElementRef: (?) Error using the mock from @gilad-s in angular 2.4 Modified the mock class to: export class MockElementRef extends ElementRef { constructor() { super(null); } } resolves the test error. Reading from the angular source code here: https://github.com/angular/angular/blob/master/packages/core/testing/src/component_fixture.ts#L17-L60 the elementRef of the fixture is not created from …

Read more