lundi 22 juin 2020

Vue test renderless component (jsx scopedSlots)

Its possible to test renderless components without mocking?I has component like this

export default {
  render() {
    return this.$scopedSlots.default({
      loadData: this.loadData,
    })
  },

Called it in template

<template>
<div>
   <renderless-component v-slot="componentProps" >
      <button @click="componentProps.loadData">
   </renderless-component>
</div>
</template>

When try to test it with mount or shallowMount, button not rendered. So, what is the right way to do unit test for renderless compomnents?

Aucun commentaire:

Enregistrer un commentaire