Unit Testing Tap (instead of click)


If I’m using Karma and Jasmine to test my Ionic application, here’s how I’d test a click event:

spyOn(storyPreview, 'goToStory');

var previewInner = storyPreviewEl.querySelector('.story-preview');


// previewInner.tap() <----- this doesn't work
// previewInner.dispatchEvent('tap') <----- neither does this



However, I wanted to use the (tap) directive instead of the (click) because it responds much faster but I wasn’t able to figure out how to test that in my unit test. Doing previewInner.tap() doesn’t work. I know you guys are using Hammer under the hood and I saw a post on Stack Overflow about Hammer specifically but figured I’d ask here in case others were wondering how to test it for Ionic.