Vue-test-utils: .attributes().value returns undefined

Created on 6 Mar 2018  ·  1Comment  ·  Source: vuejs/vue-test-utils

Version

1.0.0-beta.11

Reproduction link

http://prntscr.com/inoeig

Steps to reproduce

  • provide value as a prop to component
  • in test use .attributes().value on input wrapper

What is expected?

Get value of the wrapper

What is actually happening?

Returns undefined
http://prntscr.com/inoeth


Sorry if this already known issue, or is not an issue at all. Didn't find similar problem. And on docs is no mention that it doesn't work with value attribute

Most helpful comment

This is expected behavior.

Setting the value with v-bind sets it as a DOM prop, not as an attribute. You can read about the difference here. My advice is to check the value property:

const wrapper = mount(Component)
wrapper.element.value

>All comments

This is expected behavior.

Setting the value with v-bind sets it as a DOM prop, not as an attribute. You can read about the difference here. My advice is to check the value property:

const wrapper = mount(Component)
wrapper.element.value
Was this page helpful?
0 / 5 - 0 ratings