Skip to main content

There are several ways how to click an element in Angular unit tests. However, .triggerEventHandler does not respect disabled state and does not call a native click event. And .click on a nativeElement does not allow customizing event properties. is a simple tool which covers these limitations:

  • it respects disabled state
  • it allows customizations of events
  • it causes native events
const el = ngMocks.find('a');
// we can click debug;
// we can click native elements// with custom, {  x: 150,  y: 150,});

or simply with selectors which are supported by ngMocks.find.'a');'[data-role="link"]');['data-role']);['data-role', 'linke']);

Under the hood uses ngMocks.trigger, therefore all features of ngMocks.trigger can be used.