-
Hey, const router = createRouterMock({
runInComponentGuards: true,
}); and run a test like this: it('checks beforeRouteUpdate', async () => {
const router = getRouter();
await router.push('/test1/1');
const wrapper = createWrapper();
await wrapper.router.push('/test2/2');
...
}); I can see a breakpoint in my But if I initialize the mock with routes: const router = createRouterMock({
runInComponentGuards: true,
routes: [
{ name: 'test1', path: '/test1/:id', component: MockComponent},
{ name: 'test2', path: '/test2/:id', component: MockComponent},
],
}); the breakpoint in the guard never hits. Am I doing something wrong? Or is there another way to test the in-component guard behavior with vue 3 / composition API? Thank you in advance.Versions: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Before route update implies a route that updates rather than a new route (you have two routes in your array). You can find more about this in vue router docs, navigation guards |
Beta Was this translation helpful? Give feedback.
-
Oh god, I was using the wrong guard for this test. I feel stupid. |
Beta Was this translation helpful? Give feedback.
Before route update implies a route that updates rather than a new route (you have two routes in your array). You can find more about this in vue router docs, navigation guards