You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The v$ object is not initialised correctly when a component is tested with Vitest. I have a very simple component with a checkbox bound to formData.accepted
When I run the following test under Jest, it passes
it('click save button',async()=>{constwrapper=mount(MyComponent)expect(wrapper.vm.v$.formData.accepted.$invalid).toBeTruthy()awaitwrapper.find('[data-cy="accept-checkbox"]').trigger('click')expect(wrapper.vm.v$.formData.accepted.$invalid).toBeFalsy()})
However, if I run the same test using Vitest it fails because wrapper.vm.v$.formData is undefined because v$ is incorrectly initialised to:
Hi @donalmurtagh, how did you solve this problem? I am using Vue 3 and the latest version of Vuelidate, but the component is not created because the rules are not initialized correctly with Vitest.
The
v$
object is not initialised correctly when a component is tested with Vitest. I have a very simple component with a checkbox bound toformData.accepted
Vuelidate is initialised within the component as per the docs
When I run the following test under Jest, it passes
However, if I run the same test using Vitest it fails because
wrapper.vm.v$.formData
isundefined
becausev$
is incorrectly initialised to:By contrast, when the Jest test is run,
v$.$silentErrors
is not empty, and the following property path returns a valueWhat should I do to ensure that
v$
is initialised correctly when the test is run with Vitest?Dependencies
The text was updated successfully, but these errors were encountered: