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

[docs] Add examples #8

Open
1 of 3 tasks
vinayakkulkarni opened this issue May 14, 2019 · 7 comments
Open
1 of 3 tasks

[docs] Add examples #8

vinayakkulkarni opened this issue May 14, 2019 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@vinayakkulkarni
Copy link
Owner

vinayakkulkarni commented May 14, 2019

@vinayakkulkarni vinayakkulkarni added the help wanted Extra attention is needed label May 14, 2019
@waghcwb
Copy link
Contributor

waghcwb commented May 22, 2019

@vinayakkulkarni,

I've opened a PR with a simple example of how to test Vuex, it still need some work, I'll be adding some updates during the week (little busy at work..)

#15

@vinayakkulkarni
Copy link
Owner Author

@waghcwb : I really appreciate the help. Looking forward to it :)

@jskim82
Copy link

jskim82 commented Jun 7, 2019

@waghcwb

I saw PR.
Can I test vuex based on existing vuex without creating vuex?

@waghcwb
Copy link
Contributor

waghcwb commented Jun 11, 2019

@jskim82,

Sorry, I think I did not understand your question. We create the Vuex instance to mock the results for the tests.

But I'm not fully experienced with Jest tests, maybe there's another way to do it.

@waghcwb
Copy link
Contributor

waghcwb commented Jun 11, 2019

@jskim82,

I think I gotcha. You can import your state, mutations, etc from the store and use as well.

import { state as mockState, mutations as mockMutations } from '@/store';

const localVue = createLocalVue();

localVue.use(Vuex);

function createStore({ state, mutations, actions }) {
  return new Vuex.Store({
    state,
    mutations,
    actions,
  });
}

let store = createStore({ state, mutations, actions });

test('component should mount', t => {
  const wrapper = shallowMount(YourComponent, { localVue, store });
  t.is(wrapper.isVueInstance(), true);
});

@waghcwb
Copy link
Contributor

waghcwb commented Jun 11, 2019

@jskim82,
I've added a example of testing using the actual state from the store. Check #15

@vinayakkulkarni,
I've finished adding examples for testing a vuex store, can you validate please?

@jskim82
Copy link

jskim82 commented Jun 11, 2019

@waghcwb

Thank you~
Let's apply the test in my project.
I will try the complicated vuex test ^. ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants