How to trigger (ionFocus) manually from Karma unit test


I want to hide submit button on input focus in a login form.

I works in development mode.

When I go to test it using Karma Jasmine, I am unable to find a way to trigger ionFocus manually.

When I was using (focus) earlier, the .focus() method on actual input tag used to focus the input, but it doesn’t happen any more.

Can anyone please help me ?

Do you know how to trigger ionFocus or ionBlur manually ?

Can you please help me here ?

@abhishekkanitkar, it may be a little late, but I was trying this in my UTs for ion-textarea and the following snippet worked for me to trigger the (ionBlur) event

let textarea = fixture.debugElement.query(By.css(‘ion-textarea’));

Hope you find this useful!

1 Like