title: vue-test-utils: How to test logic within mounted() lifecycle hook (with vuex)?
body: <p>I'm trying to write a unit test for the logic within Vue's <code>mounted()</code> lifecycle hook, but not having much luck. The problem seems to be that <code>mounted()</code> never gets called when the component is mounted using vue-test-utils <code>mount</code>. Here's the Vue component I'm trying to test:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;template&gt;
    &lt;div&gt;&lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script&gt;   
  export default {
    name: 'MyComponent',
    mounted () {
      this.$store.dispatch('logout')
    }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>And the test itself:</p>
  
  <pre class="lang-js prettyprint-override"><code>import { mount, createLocalVue } from '@vue/test-utils'
  import Vuex from 'vuex'
  import MyComponent from '@/components/MyComponent'
  
  const localVue = createLocalVue()
  
  localVue.use(Vuex)
  
  describe('MyComponent.vue', () =&gt; {
    let store
    let actions
  
    beforeEach(() =&gt; {
      actions = {
        logout: jest.fn().mockName('logout')
      }
      store = new Vuex.Store({
        state: {},
        actions
      })
    })
  
    it('calls store "logout" action', () =&gt; {
      mount(MyComponent, { localVue, store })
      expect(actions.logout).toHaveBeenCalled()
    })
  })
  </code></pre>
  
  <p>However, this fails with <code>expect(logout).toHaveBeenCalled()</code> asserting false.</p>
  
  <p>If I call the mocked store action directly with <code>actions.logout()</code> the test passes, and I have other tests which also call store actions on things like a button press, and those pass as well, so the problem definitely appears to be with the mounted() lifecycle hook.</p>
  
  <p>Any thoughts?</p>
  
  <p>(vue <code>2.5.4</code> and vue-test-utils <code>1.0.0-beta-.15</code>)</p>