I have a global prototype defined in my Vue project in main.js as follows
//main.js
import axios from 'axios';
import Vue from 'vue';
Vue.prototype.$http=axios.create({
baseURL: 'https://example.com/api/'
});
Various vue components directly call this.$http.get
or this.$http.post
for performing requests.
How do I test these components in Jest, apparently using mock I can mocks I can do
jest.mock('axios')
but my project is huge and changing every instance of this.$http
to axios is not feasible.
How to achieve this using jest.mock
?
Also how to test if a single component is doing multiple API calls on different endpoints?