Warnings in testing environment about usage of onBeforeRouteLeave
without an active route record
#2328
-
I've got a fairly basic set of unit tests testing a route component. The tests themselves seem to be working just fine, but I do get an error on every single test about my usage of
I have my tests set up as described in the docs, like so: describe('MyComponent.vue', () => {
let router: Router;
beforeEach(() => {
router = createRouter({ history: createWebHistory(), routes }); // routes is my main routes file used in the app
})
it('should render', async () => {
await router.push({ name: 'my-route' });
await router.isReady();
component = mount(MyComponent, { global: { plugins: [router] } };
expect(component.exists()).toBe(true);
})
} Any clues on what I'm doing wrong here? The component itself isn't doing anything crazy with the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
In short, |
Beta Was this translation helpful? Give feedback.
In short,
MyComponent
should have a<RouterView />
that should be rendering the component that contains theonBeforeRouteLeave()
, otherwise it won't register the guard properly