diff --git a/spec/frontend/diffs/components/compare_versions_spec.js b/spec/frontend/diffs/components/compare_versions_spec.js
index 23da1a3601b76bf7a7bce89395278417d7878369..47a266c2e365dee74ba436f14bf8d865c3b55033 100644
--- a/spec/frontend/diffs/components/compare_versions_spec.js
+++ b/spec/frontend/diffs/components/compare_versions_spec.js
@@ -21,6 +21,7 @@ beforeEach(() => {
 describe('CompareVersions', () => {
   let wrapper;
   let store;
+  let dispatchMock;
   const targetBranchName = 'tmp-wine-dev';
   const { commit } = getDiffWithCommit;
 
@@ -29,6 +30,8 @@ describe('CompareVersions', () => {
       store.state.diffs.commit = { ...store.state.diffs.commit, ...commitArgs };
     }
 
+    dispatchMock = jest.spyOn(store, 'dispatch');
+
     wrapper = mount(CompareVersionsComponent, {
       store,
       propsData: {
@@ -146,7 +149,7 @@ describe('CompareVersions', () => {
 
     it('renders short commit ID', () => {
       expect(wrapper.text()).toContain('Viewing commit');
-      expect(wrapper.text()).toContain(wrapper.vm.commit.short_id);
+      expect(wrapper.text()).toContain(commit.short_id);
     });
   });
 
@@ -204,10 +207,6 @@ describe('CompareVersions', () => {
         setWindowLocation(`?commit_id=${mrCommit.id}`);
       });
 
-      beforeEach(() => {
-        jest.spyOn(wrapper.vm, 'moveToNeighboringCommit').mockImplementation(() => {});
-      });
-
       it('uses the correct href', () => {
         const link = getPrevCommitNavElement();
 
@@ -219,7 +218,7 @@ describe('CompareVersions', () => {
 
         link.trigger('click');
         await nextTick();
-        expect(wrapper.vm.moveToNeighboringCommit).toHaveBeenCalledWith({
+        expect(dispatchMock).toHaveBeenCalledWith('diffs/moveToNeighboringCommit', {
           direction: 'previous',
         });
       });
@@ -238,10 +237,6 @@ describe('CompareVersions', () => {
         setWindowLocation(`?commit_id=${mrCommit.id}`);
       });
 
-      beforeEach(() => {
-        jest.spyOn(wrapper.vm, 'moveToNeighboringCommit').mockImplementation(() => {});
-      });
-
       it('uses the correct href', () => {
         const link = getNextCommitNavElement();
 
@@ -253,7 +248,9 @@ describe('CompareVersions', () => {
 
         link.trigger('click');
         await nextTick();
-        expect(wrapper.vm.moveToNeighboringCommit).toHaveBeenCalledWith({ direction: 'next' });
+        expect(dispatchMock).toHaveBeenCalledWith('diffs/moveToNeighboringCommit', {
+          direction: 'next',
+        });
       });
 
       it('renders a disabled button when there is no next commit', () => {