full-featured

A full-featured configuration allows you to add getters, mutations, and dispatch events, just like a real vuex setup...

vuenit.store({
  state : {
    loading : false
  },
  getters : {
    isLoading(state, localGetters, rootState){
      return !!state.loading;
    }
  },
  mutations : {
    LOADING(state, payload){
      state.loading = !!payload;
    }
  },
  actions : {
    loading({commit}, payload){
      commit('LOADING', payload);
    }
  },
  modules : {
    users : {
      // ...
    }
  }
});

This allows for a much more advanced store, but it requires a lot more setup and can make your tests more complicated. If you find you are having to set up an entire store for your tests, you may want to think about decoupling your code, or just using the real Vuex module instead of a mock one.

namespacing

By default, all modules are namespaced, meaning actions/mutations/getters are prefixed with their parent modules i.e. store.dispatch('users/myAction').

You can disable this for a specific module by setting namespaced : false.
If you want all modules to not be namespaced by default, you can alter the global configuration option mockVuex.config.autoNamespace = false.

results matching ""

    No results matching ""