avoriaz icon indicating copy to clipboard operation
avoriaz copied to clipboard

How do you ensure a global is being set to child components from mount?

Open d1820 opened this issue 5 years ago • 1 comments

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

d1820 avatar Mar 26 '19 05:03 d1820

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.

eddyerburgh avatar Apr 27 '19 10:04 eddyerburgh