-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: ability to pass components to HooksConfig
#30453
Comments
Could you help me understand why we need to register component in beforeMount for this use case to work? I was hoping it would work out of the box. |
Vue is unable to locate the So this test will fail because there's no reference from the -- DefaultSlot.vue <-- NOTE: Button component not registered here
<template>
<main>
<slot />
</main>
</template> test('render a component as slot', async ({ mount }) => {
const component = await mount(DefaultSlot, {
slots: {
default: '<Button title="Submit" />', <-- NOTE: There is no reference
},
});
await expect(component).toContainText('Submit');
}) Vue test utils follows a similar approach: https://test-utils.vuejs.org/api/#global-components. Their |
Ah, I missed the string quotes around <Button>, it makes sense to me now. In terms of the proposed shape of the API, I see hooksConfig as a user object w/o schema. In this case it seems like Vue would benefit from framework-specific |
I actually use
It is a common scenario, but i don't think it needs a specific API as it saves just a few lines of code. This would also be the first API that's different from the rest and i kind of like the flexibility of the It's a trade-off between a generic |
Another option is to put the boilerplate code in // /playwright/index.ts
beforeMount(async ({ app, hooksConfig }) => {
for (const [name, component] of Object.entries(hooksConfig?.components || {}))
app.component(name, component);
}); |
Ah, so you want the user to control both sides of the story, so hooksConfig's schema is left to the user to define? That's fine with me. |
🚀 Feature Request
The ability to pass components to
HooksConfig
, probably by using theresolveImportRef
to resolve thehooksConfig
;Example
Motivation
It simplifies testing slots and other use cases such as providing plugins
The text was updated successfully, but these errors were encountered: