-
Notifications
You must be signed in to change notification settings - Fork 111
Cannot use vue-i18n plugin with current rendering API #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, and thank you for filling in this issue! In some of my projects I ended up mocking I even use Lodash' import get from 'lodash'
import locales from '@/assets/locales/es.json'
const {...} = render(Component, {
mocks: {
$t: msg => get(locales, msg)
}
}) |
Mocking is definitely an option :) but I want to integrate it properly like I can with my i18n solution when using |
Hi @afontcu I tried my hand at a PR for this, let me know if this would cause any consequences or if there's anything additional you think could be an issue? |
Thanks for the merge on this, super delighted. 🔥 |
Thank you for contributing!! 🎉
|
The goal
I want to get i18n capabilities in my test using this library, with the popular community vue solution for i18n:
vue-i18n
.The issue
In order to make i18n possible using that package, it is currently not possible as far as I can tell. The idea would be that you could pass it to the
mountOptions
(i.e. second argument ofrender
function), it will not work because it depends on thelocalVue
/Vue
being available.One may think, why not just use the third callback argument and register it there? Agree with you! But there is the problem that you must create the i18n like so in
@vue/test-utils
:The thing to note is that the i18n variable passed into
mount
. In the current setup of the function, it is impossible to pass this i18n variable in the second argument ofrender
without having alocalVue
instance available.Perhaps the third argument could be changed to return a value that is passed in as additional options so that they fall through to the mountOptions? i.e. I imagine passing it as:
The text was updated successfully, but these errors were encountered: