Is your feature request related to a problem? Please describe.
Currently, when testing Vue components that depend on context providers (e.g., <Suspense>, <RouterView>, pinia stores, or custom provide/inject wrappers), users must manually create a wrapper component via defineComponent + h() to wrap the component under test:
const Wrapped = defineComponent({
render() {
return h(MyProvider, null, { default: () => h(Component) })
}
})
mount(Wrapped)
This is boilerplate-heavy and inconsistent with the ergonomics of other framework testing tools that support a native wrapper pattern.
Describe the solution you'd like
Add a wrapper option to mount() that accepts either a Vue component or a render function:
// Form 1: component object
mount(Component, {
wrapper: MyProvider,
})
// Form 2: render function — allows passing props to the wrapper
mount(Component, {
wrapper: ({ default: defaultSlot }) =>
h(MyProvider, { theme: 'dark' }, { default: defaultSlot }),
})
When a component object is provided, it is rendered with the target component as its default slot:
// Equivalent to:
h(MyProvider, null, { default: () => h(Component) })
When a render function is provided, it receives the target component's default slot and returns a VNode — giving full control over wrapper props and slot composition.
Describe alternatives you've considered
No response
Additional context
This pattern is already well-established in other testing ecosystems:
Having this in VTU would directly enable vitest-browser-vue to expose the same wrapper option without needing to construct a wrapper component inline via defineComponent + h(). Since vitest-browser-vue's render() delegates to mount(), a VTU-level wrapper would be a natural fit — just pass through the option and let VTU handle the rest.
Is your feature request related to a problem? Please describe.
Currently, when testing Vue components that depend on context providers (e.g.,
<Suspense>,<RouterView>, pinia stores, or customprovide/injectwrappers), users must manually create a wrapper component viadefineComponent+h()to wrap the component under test:This is boilerplate-heavy and inconsistent with the ergonomics of other framework testing tools that support a native wrapper pattern.
Describe the solution you'd like
Add a
wrapperoption tomount()that accepts either a Vue component or a render function:When a component object is provided, it is rendered with the target component as its default slot:
When a render function is provided, it receives the target component's default slot and returns a
VNode— giving full control over wrapper props and slot composition.Describe alternatives you've considered
No response
Additional context
This pattern is already well-established in other testing ecosystems:
render(<Component />, { wrapper: MyProvider })feat: add wrapper option testing-library/svelte-testing-library#492
render(Component, {}, { wrapper: Wrapper, wrapperProps: {...} })Having this in VTU would directly enable
vitest-browser-vueto expose the samewrapperoption without needing to construct a wrapper component inline viadefineComponent+h(). Sincevitest-browser-vue'srender()delegates tomount(), a VTU-levelwrapperwould be a natural fit — just pass through the option and let VTU handle the rest.