You should create an event
const event = new KeyboardEvent('keyup', {
bubbles : true, cancelable : true, shiftKey : false
});
And then get the reference of the debugElement using css selector
const input = debugElement.query(By.css('#id_of_element'));
And then reference of native html element from the previous one
const inputElement = input.nativeElement;
Assign the value for the native element as , now the text field value contains 12.
inputElement.value = 12;
finally dispatch the key up event
inputElement.dispatchEvent(event);
it will trigger the function
Dont forget to add the following line in before each and make sure you define debugElement
debugElement = fixture.debugElement;
Hope it helps