routing icon indicating copy to clipboard operation
routing copied to clipboard

Router and Route are not available in tests when using vue-i18n-routing and vue-test-utils

Open BeniRupp opened this issue 10 months ago • 0 comments

Describe the bug

When mounting a component that uses useRoute() or useRouter() with vue-test-utils and a vue-i18n-router, the useRoute and useRouter composables do not return any values. Instead the following error will be printed:

[Vue warn]: injection "Symbol(route location)" not found. 
  at <HelloWorld ref="VTU_COMPONENT" > 
  at <VTUROOT>

When using a vue-router instead of the vue-i18n-router everything is working as expected.

Reproduction

https://stackblitz.com/edit/vitejs-vite-vckr8m?file=tests%2FSample.spec.js

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (2) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.3 - /usr/local/bin/pnpm

Used Package Manager

npm

Additional context

No response

Validations

  • [X] Follow our Code of Conduct
  • [X] Read the Contributing Guide.
  • [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • [X] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • [X] The provided reproduction is a minimal reproducible of the bug.

BeniRupp avatar Apr 17 '24 05:04 BeniRupp