[Vuejs]-How to mock window.eventBus.$on – Vue.js | Jest Framework

-1👍

Here is the example code we can follow.

emitEvent() {
  this.$emit("myEvent", "name", "password")
}

Here is the test case

describe("Emitter", () => {
 it("emits an event with two arguments", () => {
  const wrapper = shallowMount(Emitter)
   wrapper.vm.emitEvent()
   console.log(wrapper.emitted())
 })
})

Leave a comment