vendredi 9 novembre 2018

How to test that a custom event from was fired from child component

I've a Vue component with the following structure

// parent-component.vue
<main>
  <component :is="my.component" @custom-event="callback"/>
</main>

The child component has always have the following mixin

// child-shared-mixin.js
export default {
  mounted() {
    this.$emit('custom-event')
  },
}

Here is the example of the child component

// child-component.vue
<script>
  import { ChildSharedMixin } from 'mixins'

  export default {
    mixins: [
      ChildSharedMixin
    ],
  }
</script>

So, whenever the child is mounted I trigger a event to the parent and then execute a callback.

With Jest and Vue Test Utils how can I test that mixin has fired the custom-event?

Aucun commentaire:

Enregistrer un commentaire