Javascript 在Vue.js单元测试中,如何在$route上测试手表?

Javascript 在Vue.js单元测试中,如何在$route上测试手表?,javascript,vue.js,vuejs2,jestjs,vue-router,Javascript,Vue.js,Vuejs2,Jestjs,Vue Router,我有一个Vue应用程序组件,用于监视$route的更改。进行更改时,它会向屏幕阅读器“宣布”页面更改,以便他们知道页面已更改: ... watch: { $route: function() { this.$nextTick(function () { this.focusAppWrapper(); // Find the page title if one exists and announce that.

我有一个Vue应用程序组件,用于监视$route的更改。进行更改时,它会向屏幕阅读器“宣布”页面更改,以便他们知道页面已更改:

...
watch: {
    $route: function() {
        this.$nextTick(function () {
           this.focusAppWrapper();
           // Find the page title if one exists and announce that.
           let h1 = this.$el.querySelector('h1');
           if (h1 && h1.innerText.length > 0) {
               this.announcerText = h1.innerText
               // Also update document title which is necessary to help indicate a new page
               // is being viewed.
               document.title = h1.innerText
           }
           else {
               this.announcerText = 'New page loaded'
           }
        });
    }
}
...
我找不到最好的测试方法的指导。我想我最好不要创建一个“真正的”路由器,而应该是一个模拟的路由器,这样我就可以在上面触发一个改变了吗

好在我不需要知道任何关于新/旧路线的信息。只是路线改变了