0

Hello. I have to write test of "when component have counter is 2, then the user can only type two chars":

 propsData.model = ''
    propsData.length = 2
    const wrapper = mountFunction({propsData})
    const input = wrapper.find('input')
    await input.trigger('keydown', {
        key: 'a'
      })
    await input.trigger('keydown', {
        key: 'a'
      })
    await Vue.nextTick()
    console.log(wrapper.findComponent({name: 'v-text-field'}))
    console.log(wrapper.vm.$refs.input.$refs.input)

But, when I check value, then length allways is 0. I tried DOM Native Events, but doesn't work too. Any of ideas?

1 Answer 1

0

input.trigger('keydown') - its event for @keydown. Input element use @input event for updating value . Probably .trigger('input' , 'a') - that's what you need

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.