javascript - vue.runtime.common.js: "Cannot read property '_transitionClasses' of undefined" w

I have this strange error when I'm running a test on a ponent that's using vee-validate. What

I have this strange error when I'm running a test on a ponent that's using vee-validate. What's even weirder is that it doesn't happen when I actually use this.errors in that ponent (even putting console.log(this.errors) is making it disappear).

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 '@/ponents/FolderSelect';

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

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

it('renders select box if option "existing folder" is selected', () => {
    // this code is forcing ponent 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 ing from node_modules/vue/dist/vue.runtimemon.js, line 1739 and 589.

After I add to tested ponent:

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

The error is gone! Why the error appears otherwise? Is Vue clearing vee-validate if it's not used? (this.errors is an ErrorBag added by vee-validate). Doesn't help if I add {{ errors }} to the template, though.

I'm injecting vee-validate like this:

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

I have this strange error when I'm running a test on a ponent that's using vee-validate. What's even weirder is that it doesn't happen when I actually use this.errors in that ponent (even putting console.log(this.errors) is making it disappear).

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 '@/ponents/FolderSelect';

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

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

it('renders select box if option "existing folder" is selected', () => {
    // this code is forcing ponent 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 ing from node_modules/vue/dist/vue.runtime.mon.js, line 1739 and 589.

After I add to tested ponent:

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

The error is gone! Why the error appears otherwise? Is Vue clearing vee-validate if it's not used? (this.errors is an ErrorBag added by vee-validate). Doesn't help if I add {{ errors }} to the template, though.

I'm injecting vee-validate like this:

export default {
    inject: ['$validator'],
    (...)
Share Improve this question asked Jul 17, 2018 at 10:34 van_folmertvan_folmert 4,53710 gold badges51 silver badges97 bronze badges 7
  • Try this: import { TransitionGroupStub } from '@vue/test-utils' Vue.ponent('transition-group', TransitionGroupStub) – Aldarund Commented Jul 17, 2018 at 10:49
  • @Aldarund no difference :( – van_folmert Commented Jul 17, 2018 at 10:53
  • What about vue test util version? Anything higher than beta12 wont work – Aldarund Commented Jul 17, 2018 at 11:09
  • 1.0.0-beta.20, but from what I read it should use TransitionGroupStub and TransitionStub by default – van_folmert Commented Jul 17, 2018 at 11:18
  • 1 beta20 wont work with vee validate. And with a lot of other libs too like vuetify. Beta 12 is a higher version that work with them – Aldarund Commented Jul 17, 2018 at 11:43
 |  Show 2 more ments

2 Answers 2

Reset to default 4

I had the same problem try adding {sync: false} after mounting the ponent

beforeEach(() => {
  wrapperDeep = mount(FolderSelect,{sync: false});
});

This worked for me.

We hit this at work with @vue/[email protected], and it got resolved by updating to @vue/[email protected], without using sync: false.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744759163a4592066.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信