NuxtN
Nuxt15mo ago
jovan

@nuxtjs/i18n test errors

Hi everyone,

I'm using the @nuxtjs/i18n library in my Nuxt project and am currently writing a test for a Vue component. However, I keep running into the following errors:
"Need to install with app.use function"
"$t is not a function"

My component is fairly simple, rendering translations inside the <template> using $t.

Here’s the basic test I'm working on:

test('renders all child components', () => { const wrapper = mount(AppSettings, { global: { components: mockComponents, mocks: { $t: (key: string) => key, // Mocking the i18n $t function }, }, }); Object.keys(mockComponents).forEach((componentName) => { expect(wrapper.findComponent({ name: componentName }).exists()).toBe(true); }); });

I've tried mocking the $t function, but I still get the "Need to install with app.use function" error. Does anyone know why this is happening or how to resolve it?

Thanks!
Was this page helpful?