Test-utils: Router ignores stubs provided to mount()?

I am trying to write a test to check that my router instantiates the correct component with the correct props. Since the router has multiple navigation guards and the component I want to test has heavy lifecycle methods, I thought I can simply stub the component and then use e.g. expect(wrapper.find(Component).props(...)).toBe(...) to test the props of the component that should be mounted.

However the router seems to ignore the stubs provided in the call to mount().

This repository contains a sample project: https://github.com/nlochschmidt/vue-router-test-utils-bug

Here is the router.ts:

export default (localVue = Vue) => {
  localVue.use(Router)
  return new Router({
    routes: [
      {
        path: '/',
        name: 'home',
        component: Home
      }
    ]
  })
}

Here is the Home.vue

<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png">
    <HelloWorld msg="Welcome to Your Vue.js + TypeScript App"/>
  </div>
</template>

...

This is my router.spec.ts:

describe("router", () => {
  test("should show Home component on /", () => {
    const localVue = createLocalVue()
    const router = createRouter(localVue)
    const wrapper = mount(App, { localVue, router, stubs: { Home }})
    
    expect(wrapper.find(Home).exists()).toBe(true)
    // Since Home should be stubbed, the HelloWorld component shouldn't get mounted
    // However HelloWorld is actually mounted and this test fails
    expect(wrapper.find(HelloWorld).exists()).toBe(false)
  })
})

Tested with vue 2.6.10 and @vue/test-utils 1.0.0-beta.29

You can refer to it.
using-with-vue-router

What exactly are you referring to?

I have read that section and accordingly I am installing the Router on my localVue as described in installing vue router with localvue. However the docs don’t help me with the strange behavior regarding component stubs.

I am not sure whether it is related to this.

I have tried with shallowMount but that doesn’t work either.

With shallowMount all child components get stubbed. In this case, this would include the <router-view>, however I don’t actually want that to be stubbed I want only the component stubbed that will be placed for the <router-view>.

I believe this is a bug in vue-test-utils and I’ve created an issue for it https://github.com/vuejs/vue-test-utils/issues/1258