When the "errors" property is not utilized, the error "Cannot read property '_transitionClasses' of undefined" is encountered in vue.runtime.common.js

I encountered a strange issue while running a test on a component that utilizes vee-validate. What's even more bizarre is that the error doesn't occur when I use this.errors in the component (even simply including console.log(this.errors) seems to make it disappear).

Here is an excerpt of the 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 propsData, wrapperDeep;

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

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

Upon executing yarn test:unit, the following warning is displayed:

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

This error originates from

node_modules/vue/dist/vue.runtime.common.js
, specifically lines 1739 and 589.

Remarkably, adding the following snippet to the tested component resolves the error:

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

But why does the error appear in the first place? Could it be that Vue clears vee-validate if it's not actively being used? (this.errors represents an ErrorBag introduced by vee-validate). Oddly enough, incorporating {{ errors }} in the template does not mitigate the issue.

My approach to injecting vee-validate looks like this:

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

Answer №1

After encountering a similar issue, I found success by including {sync: false} following the component mounting process.

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

Implementing this change resolved the problem for me.

Answer №2

Our team encountered a problem at the office with

@vue/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="20636760662767667b6e73696a4574747e7407727570742d606c67">[email protected]</a>
, but we were able to fix it by updating to
@vue/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9fcebfbbbcb49cbc80abbb9aebcba8a7a9a7a98fa8bca7bbc0">[email protected]</a>
without needing to use sync: false.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for retrieving console data in VueJS Data

Is there a way to review data from a form component in the console without vue taking any action? I need to receive external data and fill in the fields accordingly. I attempted to set a value using document.getElementsByName("nfe.codigo")[0].value = "000 ...

Utilizing a solo attribute within a Vue3 composable

I'm currently using a composable function to load images in my Vue3 project. While I've been able to successfully pass all the props as one object, you can check this question for reference, I'm facing an issue with passing a specific proper ...

Identifying the length of a division element following its addition

I'm facing difficulties in detecting the length and index of the dynamically appended div. I have researched extensively and found a solution involving MutationObservers, but I am unsure if it is necessary for this particular issue. Let's focus ...

Exploring the world of mocking and stubbing in protractor

I am interested in testing my angular application using protractor. The app includes an API Module that communicates with the server In these tests, I would like to mock this API Module. I am not looking to perform full integration tests, but rather tests ...

The Bootstrap 4 Modal has a one-time activation limit

It seems that I mistakenly created two modals. The issue arises when I open either of them for the first time and then close it, as from that point on, neither modal is able to be opened again by performing the same action that initially worked. https://i ...

AJAX: Displaying the contents of a folder. Issue with URL resolution

I'm attempting to showcase a collection of images stored in a specific folder within a div. My approach involves utilizing AJAX within a JavaScript file titled edit, which is positioned one directory away from the index route. This implementation is b ...

Display or conceal several elements using JQUERY/HTML upon hovering

Here is the current progress: <div style="position: relative;"> <a href="#games"> <div class="sidenavOff"> <img src = "images/card_normal.png" /> <img src = "images/category_icons/icon_games.png" style = "position: a ...

Should one consider using the Express app.use() method within an asynchronous callback function?

Seeking advice on a recommended best practice. I recently developed an Express server that generates a JWT and sends it to the client whenever they hit an API endpoint. To maintain modularity, I separated the route handler into its own module and exporte ...

Awaiting the mount to the Vue event bus

I am faced with a challenge involving a Map component that initializes leaflet on the DOM in the following manner: Map.vue <template> <div ref="map"/> </template> <script> import * as L from 'leaflet'; import mapEventB ...

Tips on sending a function's return value to an object in Node.js

I'm currently exploring Node.js and working on a REST API for a project. One of the functionalities I am implementing is a post request to store form data in a database. Some values will be retrieved from the form data while others will be generated ...

Testing Vue Components: A Comprehensive Guide

Currently, I have a simple counter component in Vue. <div> + </div> <input type="text" v-model="countData" /> <div> - </div> If you want to see the detailed code for this component, click here - https://github.com/Shreer ...

Having difficulty displaying form errors using handlebars

My form validation is not working properly. When I enter incorrect information, it alerts correctly, but when I submit the form, it returns [Object object]. What could be causing this issue in my code and how should I handle the data? https://i.stack.imgu ...

Retrieving information from a separate JavaScript file

I'm currently developing a Discord Bot and my code is all contained within one file. My goal now is to break this code up into multiple files for better organization. For instance, I plan to have: index.js which will handle all the requires (e.g. var ...

Issue with static resource fetching when referencing a .js file within an HTML document while using Flask

My HTML file loads my OpenLayers JavaScript file (which displays a map frame) when opened directly. However, when running the HTML from my Flask python app, the JavaScript file/object fails to load (resulting in no map display, just some heading text). I ...

Using Angular to automatically update the user interface by reflecting changes made in the child component back to the parent component

Within Angular 5, I am utilizing an *IF-else statement to determine if the authorization value is true. If it is true, then template 2 should be rendered; if false, then template 1 should be rendered. Below is the code snippet: <div *ngIf="authorized; ...

Tips on saving the background image URL value into a variable

How can I save the URL value of a background image in a variable? For example: image: url(images/9XkFhM8tRiuHXZRCKSdm_ny-2.jpg); I store this value as value = images/9XkFhM8tRiuHXZRCKSdm_ny-2.jpg in a variable and then use this variable in an href tag. ...

It appears that the collection.add() method in connector/node.js only successfully executes one time

Currently, I am experimenting with MySQL Document Store to compare it with our relational tables. To achieve this comparison, I am working on transforming our existing table into a collection. The table contains approximately 320K records that I need to ...

"Troubleshooting the issue of nested jQuery Ajax requests failing to execute properly

UPDATE: I'm getting an error saying that my li tag is considered an illegal token. I'm unsure how to resolve this issue as I believed I was appending it within a ul tag I'm tasked with fetching a JSON array of public Github repositories and ...

Utilize event delegation to retrieve the data attribute

Working great for me, able to access data-club-id: <!-- example --> <a class="clubCode" href="" data-club-id= "1234">join with the code</a> $("a.clubCode").on("click",function(e){ e.preventDefault(); var clubId = $(this) ...

Implement Clip Function with Gradient Effect in JavaScript on Canvas

Trying to incorporate the clip() function within the canvas element to create a unique effect, similar to the one shown in the image. I have successfully achieved a circular clip, but I am now aiming for a gradient effect as seen in the example. How can th ...