Question: possibility of testing options passed in $t() method
sniperadmin opened this issue · comments
Nasr Galal commented
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
- Read the Contributing Guidelines
- Read the Documentation
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.