Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access store in composition api #185

Closed
PawanScroll opened this issue Aug 2, 2021 · 2 comments
Closed

Unable to access store in composition api #185

PawanScroll opened this issue Aug 2, 2021 · 2 comments

Comments

@PawanScroll
Copy link

All my components use store like so, const store = useStore();

in my jest.setup.js I have,

const state = { site: { id: 1, }, post: { data: [], },...

const getters = { 'site/getSite': { id: 1, created: null,...

and this is how I provide the mock store, following the docs

const store = new Store({ state, getters });
config.global.mocks.$store = store;

But I'm stuck with

multiple [Vue warn]: injection "store" not found.

Now, my question is, is there a function like injectRouterMock in vue-router-mock which can be used or how do I provide the injection (useStore uses injection internally, I think)

I tried the provide option on global but with no luck, maybe I'm missing something?

PS. it was working with the following implementation,

const store = createStore({ modules: { site,... } })
config.global.plugins = [store]
config.global.provide = { [Symbol('mock-store')]: store }

@winniehell
Copy link
Contributor

this may be fixed with vuejs/test-utils#1871

so maybe #203 helps

winniehell added a commit to winniehell/vuex-mock-store that referenced this issue May 8, 2023
posva pushed a commit to winniehell/vuex-mock-store that referenced this issue May 15, 2023
@winniehell
Copy link
Contributor

so maybe #203 helps

yes, this is fixed now

@posva posva closed this as completed May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants