avoriaz
avoriaz copied to clipboard
How do you ensure a global is being set to child components from mount?
I am mounting an instance of a component and I am setting the globals, when the component is rendered the child components dont have the global available. Am i missing something or doing it wrong?
I have tried
mount(component, { globals: { $myref: 'xxx' }});
and
const instance = Vue.extend();
options.instance.prototype.$myref= 'xxx';
mount(component, options);
and
const instance = Vue.extend();
options.instance.prototype.$myref= 'xxx';
options.globals = { $myref: 'xxx' };
mount(component, options);
in all the mounted component has $myref
but the child always shows undefined.
Any ideas or help would be great.
Thanks
Is the child component created with Vue.extend? If so then this library doesn't support adding globals. I recommend using @vue/test-utils instead.