Store

vuenit.store({})
vuenit.mockStore({})

This creates a vuex-style store that is extremely lightweight. The store is intended for injecting into a component, so that you don't have create an entire vux store, with all of its validation and logic, in order to test your component.

The store takes a configuration object as its only parameter. The configuration object can take two forms: full-featured and state-only. In many cases when unit testing, you won't be too bothered about whether a commit has changed some stateful data, or a dispatch has done anything other than returned a promise; therefore the state-only configuration allows you to just quickly spin-up a store with a bare-bones structure.

Once created, the mock store can be used like the real one. The commit and dispatch methods will just return a stubbed response rather than throwing an error if the matching mutation/action is not available.

The map methods ({mapState, mapGetters, mapMutations, mapActions}) of Vuex should all work with the vuenit store without any additional steps.

results matching ""

    No results matching ""