0👍
You need to define axios stub when you do shallowMount.
For example:
const data = { data: { items: [{ id: 1 }, { id: 2 }] } }
return shallowMount(BarChart, {
stubs: {
highcharts: true,
},
mocks: {
$axios: jest.fn(() => Promise.resolve(data)),
},
});
You do not need to use sinon, @vue/test-utils and jest have provided way to mock axios.
- [Vuejs]-Firestore, vue, vuex, vuexfire: How to make getter actually get data from store?
- [Vuejs]-JEST config testing node_module even if its disabled?
Source:stackexchange.com