You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Confirm navigation button works by clicking between three links in minimal reproduction dev server
Close the dev server process
Run pnpm test and it will fail with essentially router missing errors.
Expected behavior
As the Button component works as a router-link when running in dev mode or production builds, I would expect it to rendering correctly when running the test suite as well.
Actual behavior
The test will error with:
[Vue warn]: injection "Symbol(router)" not found.
[Vue warn]: injection "Symbol(route location)" not found.
[Vue warn]: Component is missing template or render function.
at <RouterLink key=0 to="/about" replace=false >
at <Button text="This will break in the tests" to="/about" >
at <App ref="VTU_COMPONENT" >
at <VTUROOT>
Additional information
We essentially want the Button component to support being a RouterLink when a to prop is passed, but we're finding it errors in the test suite.
I've done a bit a research of the other major UI libraries and noticed they are using similar-yet-different patterns to support this, so potentially we're just doing it wrong:
But before going down this path wanted to raise it, as I feel like this shouldn't be so complicated and it was working for our tests before we wanted to use a real router for integration tests!
Any direction if I'm doing it wrong would be appreciated 🙏
This discussion was converted from issue #2186 on March 25, 2024 08:07.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Reproduction
https://stackblitz.com/~/github.com/amurf/vue-router-component-library-integration
Steps to reproduce the bug
pnpm test
and it will fail with essentially router missing errors.Expected behavior
As the Button component works as a router-link when running in dev mode or production builds, I would expect it to rendering correctly when running the test suite as well.
Actual behavior
The test will error with:
Additional information
We essentially want the
Button
component to support being a RouterLink when ato
prop is passed, but we're finding it errors in the test suite.I've done a bit a research of the other major UI libraries and noticed they are using similar-yet-different patterns to support this, so potentially we're just doing it wrong:
https://github.com/vuetifyjs/vuetify/blob/master/packages/vuetify/src/composables/router.tsx
https://github.com/epicmaxco/vuestic-ui/blob/develop/packages/ui/src/composables/useRouterLink.ts
https://github.com/quasarframework/quasar/blob/dev/ui/src/composables/private/use-router-link.js
But before going down this path wanted to raise it, as I feel like this shouldn't be so complicated and it was working for our tests before we wanted to use a real router for integration tests!
Any direction if I'm doing it wrong would be appreciated 🙏
Beta Was this translation helpful? Give feedback.
All reactions