Skip to content

"Cannot read property '_transitionClasses' of undefined" when injecting vee-validate which is not used #829

Closed
@folmert

Description

@folmert

Version

1.0.0-beta.20

Reproduction link

https://cli.vuejs.org/guide/prototyping.html

Steps to reproduce

I have this strange error when I'm running a test on a component that's using vee-validate. What's even weirder is that it doesn't happen when I actually use this.errors in that component.
this.errors is an ErrorBag added by vee-validate, and it makes the error disappear even if I just add a dummy line like console.log(this.errors); or this.errors; into the tested component's created hook.

Test code:

import { mount } from '@vue/test-utils';
import { renderToString } from '@vue/server-test-utils';
import Vue from 'vue';
import VeeValidate from 'vee-validate';
import VeeValidateConfig from '@/vee-validate-config';
Vue.use(VeeValidate, VeeValidateConfig);
import FolderSelect from '@/components/FolderSelect';

describe('FolderSelect', () => {
let wrapperDeep;

beforeEach(() => {
    wrapperDeep = mount(FolderSelect);
});

it('renders select box if option "existing folder" is selected', () => {
    // this code is forcing component to use vee-validate:
    wrapperDeep.setData({folder: 'existing'}); 
});

Output from yarn test:unit:

[Vue warn]: Error in directive validate bind hook: 
"TypeError: Cannot read property '_transitionClasses' of undefined"

It's coming from node_modules/vue/dist/vue.runtime.common.js, line 1739 and 589.

After I add to tested component:

created () {
    console.log(this.errors);
},

The error is gone! Why the error appears otherwise? Is Vue clearing vee-validate if it's not used and in result breaking these transitions? Doesn't help if I add {{ errors }} to the template, though.

I'm injecting vee-validate like this:

export default {
    inject: ['$validator'],
    (...)

Not sure if this error is caused by Vue, vue-test-utils or vee-validate, but since it doesn't throw this error on dev and production build, it must be sth with vue-test-utils.

What is expected?

The error should be gone.

What is actually happening?

I get "TypeError: Cannot read property '_transitionClasses' of undefined"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions