I'm using jest to run vue unit tests to check the output of individual components. The component uses vuetify.
I create an instance of vue to mount the component:
import myComponent from './MyComponent.vue';
import VueRouter from 'vue-router';
import Vuetify from 'vuetify';
describe('Component', () => {
let wrapper;
const router = new VueRouter({
base: '/ui/',
routes: [
{
name: 'myRoute',
path: '/route-to-my-component',
component: myComponent
},
]
});
beforeEach(() => {
const localVue = createLocalVue();
localVue.use(VueRouter);
localVue.use(Vuetify);
wrapper = mount(myComponent, {
localVue: localVue,
router
});
});
it('contains a container', () => {
expect(wrapper.contains('v-container')).toBe(true);
})
});
I expect this test to pass, but instead I'm getting TypeError: Cannot read property 't' of undefined
.
For reference, I was following https://fernandobasso.github.io/javascript/unit-testing-vue-vuetify-with-jest-and-vue-test-utils.html.
createLocalVue
imported from tests utils ? – asotogt
, this is most likely issue with translation. You will need to mock the translation module in your test. – Metalmi