[Vuejs]-How to mock an emit when testing a child component in Jest (Vue)

0👍

You could mock $emit on the mounted component with the mocks mounting option:

const $emit = jest.fn()
shallowMount(MyComponent, {
  mocks: {
    $emit
  }
})
expect($emit).toHaveBeenCalledWith('some-emit', { foo: 1 })

Leave a comment