-
Notifications
You must be signed in to change notification settings - Fork 245
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
Behavior of global.components is confusing #845
Comments
@lmiller1990 considering I saw some recent activity from you would be happy to hear your thoughts |
It like the change was made here: #504 to support a use-case in the posva/vue-router-mock library. I can see why this would be confusing. Have you encountered this use case in your usual development workflow? I have not really found myself using It looks like reverting it might have some negative impacts, at least on the |
@lmiller1990 thank you for giving context! I will take a look and come back today with proposal |
@lmiller1990 I've checked that #504 is actually not the issue where problematic code was added Regarding "if we meet this in the wild" - I've discovered this while preparing codemod, which "automatically" unpacked non-existent anymore |
This behavior was very confusing me as well and the main challenge for me was that the globals are registered using app.component() and/or app.use() in Vue. However, this library uses an alternate array syntax for global registration. Luckily, I was using a custom-built component library so I was able to create an "index" that I could import to this library. I then used a for-loop to register the components in my main.js file. It seems that this library handles global registration in a completely different way from Vue itself which is very confusing. |
@vpillinger can you share a minimal example showing how Test Utils differs from Vue itself? Also what do you mean by "array syntax"? You can supply components using an object: https://next.vue-test-utils.vuejs.org/api/#global import Something from './Something.vue'
mount(Foo, {
global: {
components: {
MyButton: Something,
InlineComponent: {
template: `<div>OK</div>`
}
}
}
}) etc. |
I'm struggling to understand the reasoning, why
global.components
perform two things simultaneously:global.stubs
, but just for component we are mountingSecond one is provided by this piece of code inside
mount
:where
global.components
effectively overwrite local components.I find this behavior super-confusing:
global.components
) will work only for components, who use Options APIglobal.stubs
andglobal.components
becomes hard-to-explainFor example this test looks super-confusing unless you know what is happening [source]:
You're like: ...em... what? I'm unstubbing
GlobalComponent
by passingGlobalComponent: false
, but why it is stubbed, we're not using shallowMount?I see no added benefits in current behavior and would like to suggest dropping it, and matching
global.components
application APIapp.component
behavior - it simply registers component as global one and nothing moreThe text was updated successfully, but these errors were encountered: