0

Am trying to write unit tests for a v-select component using vue-test-utils. I could notice that, change/input event is not getting triggered whenever the item is updated in v-select.

Component

v-select(
  ref       = "select_cards"
  items     = "[4,8,12]"
  label     = "Number of cards"
  v-model   = "numberOfCards"//data variable
  @change   = "generateRandomValues()"
  :disabled = "isDisabled" //boolean data variable
)

Test -

const input = wrapper.find("input")
input.element.value = 12
input.trigger("change")

I tried with @input instead of @change. And I tried to set value in test by - wrapper.find("input").setValue(12). But I can notice that change/input event is not getting triggered in unit test. However, this do work when I try it out in browser.

Any suggestions, on how to get the change event on select triggered from unit tests?

P.S - Am using Vue 2.6.11, Vuetify 2.4.9 and Vue test utils 1.1.3

3
  • Maybe this can help? stackoverflow.com/questions/50992183/… Commented Apr 10, 2021 at 20:34
  • @Kunukn - I tried all the solutions provided in above reference. Its not working yet. Wondering if this is an issue induced in newer versions of vue test utils or am I missing something. Commented Apr 10, 2021 at 22:03
  • The Vuetify tests are here github.com/vuetifyjs/vuetify/blob/master/packages/vuetify/src/… maybe something like this might help? await wrapper.vm.$nextTick() Commented Apr 11, 2021 at 14:37

0

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.