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
When testing a single Pinia-Store outside of a component, the Villus client is not found. All standard component tests using createTestingPinia() work just fine.
vue.getCurrentInstance() returns null and the client is not injected even though it is available.
functionresolveClient(){constvm=vue.getCurrentInstance();// Uses same component provide as its own injections// Due to changes in https://github.com/vuejs/vue-next/pull/2424letclient=vm&&vue.inject(VILLUS_CLIENT,resolveInternalInjection(vm,VILLUS_CLIENT));if(client)setActiveClient(client);client=getActiveClient();if(client===null||client===undefined){thrownewError('Cannot detect villus Client, did you forget to call `useClient`? Alternatively, you can explicitly pass a client as the `manualClient` argument.');}returnclient;}
Is there a way to achieve this, or is some testing-util needed where a dummy-component is mounted?
The text was updated successfully, but these errors were encountered:
If that doesn't work you can also import setActiveClient that is similar to pinias but the plugin method is doing that already under the hood so it should work for you.
Thank you so much, app.use(client) did the trick. For anyone else interested, this is the final setup for testing a Pinia-Store that uses Villus composables:
When testing a single Pinia-Store outside of a component, the Villus client is not found. All standard component tests using
createTestingPinia()
work just fine.Using this code to inject the Villus client:
vue.getCurrentInstance()
returns null and the client is not injected even though it is available.Is there a way to achieve this, or is some testing-util needed where a dummy-component is mounted?
The text was updated successfully, but these errors were encountered: