Closed JarvisH closed 3 months ago
Try using createClient
as a Vue app plugin.
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.
import { setActiveClient, createClient } from 'villus';
const client = createClient(someConfig);
app.use(client);
// or
setActiveClient(client);
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:
beforeEach(() => {
const app = createApp({})
const pinia = createPinia()
app.use(pinia)
app.use(client)
setActivePinia(pinia)
})
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?