title: Error when running tests in VueJS: vue-router uncaught error during route navigation
body: <p>I keep getting this warning in my unit tests when ever I have router component in my template:</p>
  
  <p>I've raised a ticket about this before <a href="https://stackoverflow.com/questions/43343317/error-when-running-tests-in-vuejs-unknown-custom-element-router-link">Unknown custom element</a> and I've tried the same things but with no luck. Just wondered if anyone knew a bit more about this error?</p>
  
  <p>FinalCountdown.html</p>
  
  <pre><code>&lt;div id="c-final-countdown"&gt;
    &lt;h1&gt;Hello App!&lt;/h1&gt;
    &lt;p&gt;
      &lt;!-- use router-link component for navigation. --&gt;
      &lt;!-- specify the link by passing the `to` prop. --&gt;
      &lt;!-- &lt;router-link&gt; will be rendered as an `&lt;a&gt;` tag by default --&gt;
      &lt;router-link to="/foo"&gt;Go to Foo&lt;/router-link&gt;
      &lt;router-link to="/bar"&gt;Go to Bar&lt;/router-link&gt;
    &lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>FinalCountdown.spec.js</p>
  
  <pre><code>import Vue from 'vue'
  import router from '../../router'
  import FinalCountdown from 'src/components/workflow/FinalCountdown'
  
  describe('workflow/FinalCoundDown component.'), () =&gt; {
    const getComponent = (date) =&gt; {
      let vm = new Vue({
        template: '&lt;div&gt;&lt;final-countdown ref="component"&gt;&lt;/final-countdown&gt;&lt;/div&gt;',
        components: {
          FinalCountdown
        }
      })
      return vm
    }
  
    it('Should render correctly with a date in the future.', () =&gt; {
      const tomorrow = new Date(new Date().getTime() + 24 * 60 * 60 * 1000)
      const vm = getComponent().$mount()
      const component = vm.$refs.component
  
      expect(vm.$el).toBeTruthy()
      console.log(vm.$el) // &lt;div&gt;&lt;!----&gt;&lt;/div&gt;
    })
  }
  </code></pre>
  
  <p>Our assertion fails because we need to provide <code>vm</code> instance with <code>VueRouter</code> instance. So then <code>getComponent</code> becomes:</p>
  
  <pre><code>  const getComponent = (date) =&gt; {
      Vue.use(vueRouter)
      const routes = { ... };
      const router = new VueRouter({ routes })
      let vm = new Vue({
        router,
        template: '&lt;div&gt;&lt;final-countdown ref="component"&gt;&lt;/final-countdown&gt;&lt;/div&gt;',
        components: {
          FinalCountdown
        }
      })
      return vm
    }
  </code></pre>
  
  <p>And then we can see the component mounting but I get the warning error. Hope that all makes sense :D</p>
  
  <p><code>WARN LOG: '[vue-router] uncaught error during route navigation:'</code></p>