Skip to content

Instantly share code, notes, and snippets.

@brickgale
Last active June 30, 2022 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brickgale/2cc1f32c4676f360267f9c92441cc1db to your computer and use it in GitHub Desktop.
Save brickgale/2cc1f32c4676f360267f9c92441cc1db to your computer and use it in GitHub Desktop.
Used by mount/render on vue-test-utils or testing-library/vue by Stubbing a component (vue 3)
import { h } from 'vue'
export default {
name: 'CustomStubHasSlots',
props: {
tag: {
type: String,
default: 'div'
}
},
render() {
let slots = [];
Object.keys(this.$slots).map(key => {
slots = [ ...slots, ...this.$slots[key]() ]
})
return h(this.tag, {}, slots)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment