-
-
Notifications
You must be signed in to change notification settings - Fork 861
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
Cannot read property '_t' of undefined. Vue-i18t injection with @vue/test-utils mount() #754
Comments
Hi there! Try using the correct key name just as you would when adding vue-i18n to your app: import Vue from "vue";
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
- const vueI18n= new VueI18n()
+ const i18n = new VueI18n()
import {mount} from '@vue/test-utils'
import Demo from '../../../src/components/Demo'
it('vue-i18n test', async () => {
const wrapper = mount(Demo, { // try to inject vue-i18n
- vueI18n,
+ i18n,
}) // mount({ vueI18n, ...Demo}) not works too
}) That should do the trick. |
Thanks |
I'm getting this error in a pure-JS single-file-component with code akin to that below. After getting the error with Component that is throwing the error:
My base i18n configuration:
|
Looks like my resolution is to change |
vue & vue-i18n version
2.6.10, 8.15.1
Reproduction Link
Unfortunately I don't know how to reproduce unit testing with jsfiddle. It would be very helpfull if you provide base template for unit testing like you did http://jsfiddle.net/r8qnsfb1/
Steps to reproduce
jest test.spec.js
What is Expected?
test success
What is actually happening?
TypeError: Cannot read property '_t' of undefined
Description
hello!
I got this error inside unit test. I found very similar Issue in #276 except we don't use Vue.extends() and $mount() syntax in our code and tests. We try inject vue-i18n using regular @vue/test-utils mount() function and get this error.
As you can see we use mount(component, options) . And get error
The text was updated successfully, but these errors were encountered: