kazupon / vue-i18n

:globe_with_meridians: Internationalization plugin for Vue.js

Home Page:https://kazupon.github.io/vue-i18n/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: possibility of testing options passed in $t() method

sniperadmin opened this issue · comments

Clear and concise description of the problem

Could we cover branching in the following working example in unit testing?

<template>
    <v-subheader data-test="subtitle">
        {{ $t('auth.subtitle', { status: isRegister ? $t('auth.status.create') : $t('auth.status.login') }) }}
    </v-subheader>
</template>

<script>
export default {
  name: 'SomeComponent',
  props: {
    isRegister: {
      type: Boolean,
      default: true
    },
    isEditor: {
      type: Boolean,
      default: false
    }
  }
}
</script>

It looks like it is not possible to access the options passed in the $t method because in this case, the SFC is already mounted, and the requested JSON keys have been processed

Suggested solution

I don't have any ideas about a proper solution. I think mocking the whole thing won't be an option.
Yes, we could test the printed out text and works fine. However, in coverage, it does not count that

Alternative

No response

Additional context

No response

Validations