Skip to content

@nuxt/test-utils is not working with useI18n from @nuxtjs/i18n #743

@trandaison

Description

@trandaison

Environment

  • Operating System: Darwin
  • Node Version: v18.16.0
  • Nuxt Version: 3.9.3
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: pnpm@8.15.0
  • Builder: -
  • User Config: devtools, modules
  • Runtime Modules: @nuxtjs/i18n@8.0.0
  • Build Modules: -

Reproduction

https://github.com/trandaison/test-utils/tree/main/examples/i18n

Describe the bug

I forked these examples then add a component named TheHeader.vue which do use const { t } = useI18n() in the setup script.

<script lang="ts" setup>
const { t } = useI18n();
</script>

<template>
  <h1>{{ t('brand') }}</h1>
</template>

The test will be timeout and unable to run in this case.

Screenshot 2024-01-29 at 17 18 18

If I replace the useI18n composition with the $t function (or don't use any translate function at all) the test will be passed.

<script lang="ts" setup>
// const { t } = useI18n();
</script>

<template>
  <h1>{{ $t('brand') }}</h1>
</template>

Screenshot 2024-01-29 at 17 25 13

Additional context

No response

Logs

No response

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