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
I am trying to write a unit test for a component in our solution and have run into issues trying to use vue-test-utils. Reading the documentation I came accross attachToDocument which from reading implies that this will allow for using $refs and document.getElementById and so on. However I can't get this test to work. Both shallow and mount both give me errors trying to mount the component for testing. I followed the instructions at https://vue-test-utils.vuejs.org/guides/testing-SFCs-with-karma.html for setting up karma, mocha and webpack and was able to get tests running until I tried this component.
Create a vue component and add a ref an element ex upload. Attempt to access the $refs.upload from mounted and get an exception 'cannot read property 'upload' of null', attempt to use document.getElementById from mounted and the same null exception occurs, 'cannot read property 'addEventListner' of null.
What is expected?
$refs and document.getElementById to find the item in the template.
What is actually happening?
A null reference exception occurs.
The text was updated successfully, but these errors were encountered:
Version
1.0.0-beta.19
Reproduction link
https://jsfiddle.net/h0bnmk5d/17/
Steps to reproduce
I am trying to write a unit test for a component in our solution and have run into issues trying to use vue-test-utils. Reading the documentation I came accross attachToDocument which from reading implies that this will allow for using $refs and document.getElementById and so on. However I can't get this test to work. Both shallow and mount both give me errors trying to mount the component for testing. I followed the instructions at https://vue-test-utils.vuejs.org/guides/testing-SFCs-with-karma.html for setting up karma, mocha and webpack and was able to get tests running until I tried this component.
Create a vue component and add a ref an element ex upload. Attempt to access the $refs.upload from mounted and get an exception 'cannot read property 'upload' of null', attempt to use document.getElementById from mounted and the same null exception occurs, 'cannot read property 'addEventListner' of null.
What is expected?
$refs and document.getElementById to find the item in the template.
What is actually happening?
A null reference exception occurs.
The text was updated successfully, but these errors were encountered: