Testing Vue + vuetify and v-mask causing error

Viewed 269

My Vue component uses a mask from v-mask and it works fine.

<v-text-field
    v-model="cpfCnpjField"
    v-mask="maskcpfCnpjField"
></v-text-field>

In my spec file spec I'm importing the VueMask

import VueMask from 'v-mask';
const localVue = createLocalVue();
localVue.use(VueMask);

When I run my tests with jest, the component cannot be mounted. The compiler throws

console.error node_modules/vue/dist/vue.runtime.common.dev.js:1884 TypeError: Cannot read property 'length' of undefined at updateValue (C:\workspace\front-farm\node_modules\v-mask\dist\v-mask.js:401:35)

Any idea of what can be happening?

1 Answers

You could try to shallowMount the component. That worked for me

Related