title: How can I mock axios API calls? with using jest
body: <p>Hi I'm testing my vuex action async function which is calling api via axios, but I have some problem that it show error like  this "
      TypeError: Cannot destructure property <code>data</code> of 'undefined' or 'null'.</p>
  
  <pre><code>  35 |     commit('storeSearchValue', name);
    36 |     const url = process.env.VUE_APP_URL_API_News + '/news' + '?q=' + name;
  &gt; 37 |     const { data } = await axios.get(url);"
  </code></pre>
  
  <p>my vue js code is</p>
  
  <pre><code> async updateSearchValue({ commit }, name) {
      commit('storeSearchValue', name);
      const url = process.env.VUE_APP_URL_API_News + '/news' + '?q=' + name;
      const { data } = await axios.get(url);
      commit('storeNewsData', data.result);
    },
  </code></pre>
  
  <p>and this is test file,</p>
  
  <pre><code>import actions from '@/store/modules/data/data-actions.js'
  import VueRouter from 'vue-router';
  import axios from 'axios';
  
  import {
    createLocalVue
  } from '@vue/test-utils';
  const localVue = createLocalVue();
  localVue.use(VueRouter);
  jest.mock('axios');
  
  describe('', () =&gt; {
    test('updateSearchValue', async () =&gt; {
      const commit = jest.fn()
      const name = jest.fn()
  
      await actions.updateSearchValue({
        commit,
        name
      })
  
      expect(commit).toHaveBeenCalledWith('updateSearchValue', name)
    })
  
  })
  
  </code></pre>