ChangeDetectorRef
cannot be injected on test bed! You’ll need to directly spy on them.
it('should call markForCheck when do a barrel roll.', () => {
const changeDetectorRef = fixture.debugElement.injector.get(ChangeDetectorRef);
const detectChangesSpy = spyOn(changeDetectorRef.constructor.prototype, 'markForCheck');
doABarrelRoll();
expect(detectChangesSpy).toHaveBeenCalled();
});
References: