You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I sometimes use the vm property of a Wrapper to access global properties. This comes up most often in tests that use a real router, then make an assertion about vm.$route. However, it seems that vm does not provide access to global properties for Composition API components.
In this repository, there are 4 variations on a component. A plugin adds a global property named foo. For 2 of the components, vm.foo is defined, but for the other 2, vm.foo is not defined. This is what I see when I run tests:
✓ provides access to a global property from an Options API component
× provides access to a global property from a Composition API component
× provides access to a global property from an Options API component with a setup() function
✓ provides access to a global property from an Options API component with a setup() function that does not return
Expected behavior
It would be great to be able to access global properties from vm for all components.
Describe the bug
I sometimes use the
vm
property of a Wrapper to access global properties. This comes up most often in tests that use a real router, then make an assertion aboutvm.$route
. However, it seems thatvm
does not provide access to global properties for Composition API components.To Reproduce
https://github.com/matthew-white/global-properties-repro/blob/master/src/components/__tests__/HelloWorld.spec.js
In this repository, there are 4 variations on a component. A plugin adds a global property named
foo
. For 2 of the components,vm.foo
is defined, but for the other 2,vm.foo
is not defined. This is what I see when I run tests:✓ provides access to a global property from an Options API component
× provides access to a global property from a Composition API component
× provides access to a global property from an Options API component with a setup() function
✓ provides access to a global property from an Options API component with a setup() function that does not return
Expected behavior
It would be great to be able to access global properties from
vm
for all components.Related information:
npmPackages:
@vue/test-utils: ^2.4.1 => 2.4.1
vitest: ^0.33.0 => 0.33.0
vue: ^3.3.4 => 3.3.4
Additional context
Just to link issues, I think this issue may be related to #2008.
The text was updated successfully, but these errors were encountered: