Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$refs and document.getElementId return null in mounted #736

Closed
farpetrad opened this issue Jun 18, 2018 · 1 comment
Closed

$refs and document.getElementId return null in mounted #736

farpetrad opened this issue Jun 18, 2018 · 1 comment

Comments

@farpetrad
Copy link

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.

@eddyerburgh
Copy link
Member

HTML templates aren't currently supported—#351.

attachToDocument adds the root element to the document

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants