Answer the question
In order to leave comments, you need to log in
vuex testing why can't copy action and mutations?
export const state = () => ({
langs: []
});
export const mutations = {
setLangs: (state, langs) => {
state.langs = langs;
}
};
export const getters = {
langs: state => state.langs
};
export const actions = {
getLangs: async ({commit}) => {
const langs = await this.$axios.$get('/langs');
//const {data} = await this.$axios.get('/langs');
console.log(langs);
//console.log(data.langs)
commit('setLangs', langs);
//commit('setLangs', data.langs);
}
};
import {actions, getters, mutations, state} from './../store/index';
import { createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex';
describe(`store`, () => {
describe(`actions`, () => {
describe(action = 'getLangs', () => {
it(`returns an empty array if axios returns an empty array`, async (done) => {
const localVue = createLocalVue();
localVue.use(Vuex);
const store = new Vuex.Store({
state: {
count: 0
},
getters,
mutations,
});
console.log({'actions mutations' : store.mutations}); // undefine
console.log({'actions store': store.actions}) // undefine
done();
});
});
});
});
Answer the question
In order to leave comments, you need to log in
console.log({'actions mutations' : store._mutations.setLangs});
console.log({'actions store': store._actions.getLangs});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question