Skip to content

Multiple Vue instances initialised #1152

@gbyesiltas

Description

@gbyesiltas

Environment


  • Operating System: Linux
  • Node Version: v18.20.3
  • Nuxt Version: 3.15.3
  • CLI Version: 3.20.0
  • Nitro Version: 2.10.4
  • Package Manager: npm@10.2.3
  • Builder: -
  • User Config: devtools, compatibilityDate, modules
  • Runtime Modules: @nuxtjs/i18n@9.1.3
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-s7wzzz7d-dv2yxgpx?file=components%2FMyComponent.vue

Describe the bug

Coming from this nuxt-i18n issue, I tried diving a bit deeper into the problem, and I think there are multiple vue instances being initialized in the test environment causing this issue. See in this reproduction.

The instance we get from the nuxtApp.vueApp is different than the one we get from getCurrentInstance when we mount the environment in a unit test which is not the case if we run the app normally.

From my understanding, the i18n module installs the i18n instance to the one from nuxtApp, but uses getCurrentInstance within the useI18n composable which causes this issue.

Additional context

I first added this as a comment on the nuxt-i18n issue but I thought it would make more sense to open an issue here

Logs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions