title: Vue - unit test watching a vuex getter property
body: <p>I have a getter: <code>defaultInternalAccountId</code> and I am watching this property in my component. When it changes, I call a method: <code>fetchAccount</code>, which is also called when the component is mounted. I need to create a test that asserts that it was called twice and that the second time it was called with the correct <code>accountId</code>. Here's an attempt: </p>
  
  <pre><code>test('Dispatches fetchAccount when defaultInternalAccountId is updated', () =&gt; {
      const accountId = '1234';
      const accountId2 = '5678';
      mockDefaultInternalAccountId.mockReturnValueOnce(accountId);
      mockDefaultInternalAccountId.mockReturnValueOnce(accountId2);
  
      const wrapper = shallowMount(AssetAllocationsSummaryContainer, {
          localVue,
          store,
      });
  
      expect(mockFetchAccount.mock.calls[0][1]).toEqual({ accountId }); // There are other args that mapActions applies
  
      wrapper.vm.$nextTick();
      expect(mockFetchAccount).toHaveBeenCalledTimes(2);
      expect(mockFetchAccount.mock.calls[1][1]).toEqual({ accountId: accountId2 }); // There are other args that mapActions applies
  });
  </code></pre>
  
  <p>The above is failing at <code>expect(mockFetchAccount).toHaveBeenCalledTimes(2);</code> as <code>mockFetchAccount</code> is only being called once. Here is the watcher:</p>
  
  <pre><code>watch: {
    defaultInternalAccountId: {
        immediate: true,
        handler(newAccountId, oldAccountId) {
            if (newAccountId &amp;&amp; newAccountId !== oldAccountId) {
                this.fetchAccount({ accountId: newAccountId });
            }
        },
    },
  },
  </code></pre>
  
  <p><code>defaultInternalAccountId</code> is a mapped getter: <code>...mapGetters(['defaultInternalAccountId']),</code> and <code>fetchAccount</code> is a mapped action: <code>...mapActions(['fetchAccount']),</code>. All is working as expected in vivo. I have also attempted setting state directly, but the component does not pick up on that change: <code>store.state.defaultInternalAccountId = accountId2</code></p>