Routing will not finish when clicking on router-link and the target route component is imported dynamically #6030
-
Reproductionhttps://github.com/BeniRupp/vue-router-async-import-bug Steps to reproduce the bugIn a vitest test having a router with two routes, a component with a router-link and dynamic component imports for the route components:
Expected behaviorThe route Actual behaviorThe route Additional informationI assume that the test will finish before the import resolves, because the router changes the route, calls the import function, but the This problem is not reproducible if:
Am I doing something wrong or is there a better way to wait until the async import was resolved and the route changed? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi! I import my routes from a routes.js file, containing mostly dynamic routes, and ran into the same problem. All components are pending while vitest does it's thing, await flushPromises() or await router.isReady() won't help. So I forced them to resolve in a beforeAll, like
If you use nested routes, you would of cause need to recurs any dynamically loaded components there too. Good luck! |
Beta Was this translation helpful? Give feedback.
You can call
vi.dynamicImportSettled()
to wait for any dynamic import that is currently pending