Skip to main content


isMockControlValueAccessor helps when we need to access callbacks which were set via registerOnChange and registerOnTouched on a mock object which has implemented ControlValueAccessor, and to call __simulateChange, __simulateTouch to trigger them. It verifies whether an instance respects MockControlValueAccessor interface.

We need it when we get an error like:

Property '__simulateChange' does not exist on type <class>

Property '__simulateTouch' does not exist on type <class>

const instance = ngMocks.findInstance(MyCustomFormControl);
// instance.__simulateChange('foo'); // does not work.
if (isMockControlValueAccessor(instance)) {
// now works