Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48980

Jest says getInputElement is not a function

$
0
0

I use Jest for unit testing. It works great. But one weird issue appears when using the getInputElement method on HTMLIonInputElement. It exists on browser. But not in Jest (jsdom, jest-preset-angular) does not know that function.

It’s werid because this is a custom function from Ionic to get the native input element. (see docs).

I use it correctly. On runtime it works.

// Some directive.
constructor(el: ElementRef<HTMLIonInputElement>) {
  void el.nativeElement.getInputElement().then((inputEl) => (this.nativeInputElement = inputEl));
}

Jest throws:

TypeError: el.nativeElement.getInputElement is not a function

I know that Jest uses either node or jsdom. Not the real browser. But I cannot explain why is this custom method not available here. Maybe it has something to do with web components? But all other stuff I tested works fine.

Some ideas / exp advice? I would be grateful.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48980

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>