Last active
June 30, 2022 03:36
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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