How to cover lines inside event handler in jest testing with vuejs

Viewed 81

I am writing unit tests for my vuejs component which adds an event listener on mounting a component like below

mounted() {
  window.$on('test_event', () => {
    console.log('test_event was triggered');
    this.testCount++;
  }
}

But I dont get the console line covered when run the mount for component in the unit test. How to cover the lines inside arrow event handler function?

0 Answers
Related