I am faced with the following scenario:
// symbols.ts - Injection Key defined as a Symbol
export const FAQ_SERVICE: InjectionKey<FAQService> = Symbol('FAQService');
// main.ts - globally provides a service using the injection key
app.provide(FAQ_SERVICE, new FAQService());
// FAQIndex.vue - component using the injected service
…
setup() {
return {
faqService: inject(FAQ_SERVICE) as FAQService,
};
}
…
My next step is to test this component using jest and mock the service. I am aware that when providing objects using plain Strings, mocking can be done using this method:
component = mount(FAQIndex, {
global:
{
provide: {
'FAQ_SERVICE': { /* mock object */ },
},
},
});
However, I am uncertain of how to approach this when the service is injected via Symbols like in the example provided above.