I am using a 3rd party vue component SomeComponent that implements its own translations.
This is my mount in my test
import { mount } from '@vue/test-utils';
import { SomeComponent } from '../../some-component'
import { createI18n } from 'vue-i18n'
import lang from '../../lang/en'
const i18n = createI18n({
locale: 'en',
allowComposition: true,
messages: lang,
})
const items = [{ home: 'Home', about: 'About' }]
const wrapper = mount(MyComponent, {
global: {
plugins: [i18n],
components: {
SomeComponent,
},
},
props: {
items,
},
})
But I get this error
TypeError: Cannot read properties of undefined (reading 't')
How can I properly mount SomeComponent without mocking SomeComponent itself and resolve the undefined t error?
vue-i18n's version inMyComponentandSomeComponentcould possibly be different, so I bet things can fail if they are not compatible.SomeComponentdoes not create its own instance, hence the issue aboveTypeError: Cannot read properties of undefined (reading 't'). It needsMyComponent's i18n instance.