title: testing vuex action in mounted lifecycle method
body: <p>I'm trying to test that a vuex action is called when a component is mounted, but I can't. this is my code:</p>
  <pre><code>...
  describe('ReservationsList.vue Test', () =&gt; {  
    
    let actions
    let getters
    let store
    let wrapper
  
    beforeEach(() =&gt; {
  
      actions = {
        fetchReservations: jest.fn()
      }
  
      getters = {      
        reservationsList: () =&gt; reservationsData.data
      }
  
      store = new Vuex.Store({
        actions,
        getters     
      })                     
  
    }) 
  
    describe('store', ()=&gt;{
  
      it('calls store action &quot;fetchReservations&quot; when mounted', async () =&gt; {                  
  
        wrapper = shallowMount(ReservationsList, {
          store, 
          localVue
        });     
        await wrapper.vm.$nextTick();          
        expect(actions.fetchReservations).toHaveBeenCalled()                 
  
      })  
  
    })
  })
  </code></pre>
  <p>But the tests fails:</p>
  <pre><code>expect(jest.fn()).toHaveBeenCalled()
  Expected number of calls: &gt;= 1
  Received number of calls:    0
  </code></pre>
  <p>this is my ReservationsList Component:</p>
  <pre><code>&lt;template&gt;  
    &lt;div class=&quot;reservations-list card o-hidden mb-4&quot;&gt;
        &lt;div class=&quot;card-header d-flex align-items-center border-0&quot;&gt;
            &lt;h3 class=&quot;w-50 float-left card-title m-0&quot;&gt;Reservations&lt;/h3&gt;
        &lt;/div&gt;
        &lt;div&gt;
            &lt;div class=&quot;table-responsive&quot;&gt;
                &lt;table class=&quot;table text-center&quot; id=&quot;user_table&quot;&gt;
                    &lt;thead&gt;
                        &lt;tr&gt;
                            &lt;th scope=&quot;col&quot;&gt;Name&lt;/th&gt;
                            &lt;th scope=&quot;col&quot;&gt;Email&lt;/th&gt;
                            &lt;th scope=&quot;col&quot;&gt;Booking date&lt;/th&gt;
                            &lt;th scope=&quot;col&quot;&gt;Number of guests&lt;/th&gt;                     
                        &lt;/tr&gt;
                    &lt;/thead&gt;
                    &lt;tbody&gt;                       
  
                      &lt;reservations-item 
                        :key=&quot;reservation.id&quot;
                        v-for=&quot;reservation in reservationsList&quot; 
                        :reservation=&quot;reservation&quot;                      
                        &gt;                        
                      &lt;/reservations-item&gt;    
                                                                   
                    &lt;/tbody&gt;
                &lt;/table&gt;
            &lt;/div&gt;          
        &lt;/div&gt;
    &lt;/div&gt;                  
  &lt;/template&gt;
  &lt;script&gt;
      
      import ReservationsItem from './ReservationsItem';
      import {mapGetters, mapActions} from 'vuex';
      import { fetchReservations } from &quot;../store/actions.type&quot;;
      import store from &quot;../store&quot;;
  
      export default {       
  
        components: { ReservationsItem },
  
        mounted(){      
          this.fetch();
        },
  
        computed:{
          ...mapGetters(['reservationsList'])                
        },           
  
        methods: {        
          fetch() {            
              store.dispatch('fetchReservations');
          }
      }
  
    }
  &lt;/script&gt;
  </code></pre>
  <p>And my Vuex store:</p>
  <pre><code>....
  export const actions = {  
      
      fetchReservations({commit}, url){
  
         return new Promise((resolve, reject) =&gt; {
  
          return axios.get(url).then(({data})=&gt;{             
               commit(SET_RESERVATIONS, data.data);
               resolve(true);     
           }).catch(error =&gt; {             
               commit(SET_ERROR, error.response.data.message);
               reject(true);
        });   
  
      });
  
      }
  }
  
  .....
  </code></pre>
  <p>The code is working fine, but the test fails, I am using vue-test-utils version 1.1.2 and jest version 26.6.3,  What can I do? Thank you</p>