Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
get value v-model(vue bind) after trigger click component using jest

i am so confused what happens with my code. i am new in jest and unit testing, while developing i use bootstrap-vue, nuxt and vue test utils (jest) for unit testing.

Shortly, i have custom component (CheckboxInput). this component use b-form-checkbox-group from bootstrap vue it's my code.

  props : {
    ...another props,
    value : {default : () => ({}),
  },
  computed : {
    local_value: {
      get: function () {
        return this.value
      },
      set: function (value) {
        this.$emit('input', value)
      }
    },
  }
  --------
  <b-form-checkbox-group
    :id="id"
    :ref="id"
    :class="additional_class"
    v-model="local_value"
    :size="size"
    :indeterminate="is_indeterminate"
    :disabled="is_disabled"
    :stacked="is_vertical"
  >
    <b-form-checkbox
      v-for="(option, index) in options"
      :key="index"
      :value="option.value"
      :disabled="option.is_disabled"
      :checked="is_force_unchecked"
      :unchecked-value="option.unchecked_value ? option.unchecked_value : false"
    >
      {{ option.text }}
    </b-form-checkbox>
  </b-form-checkbox-group>

I want to create simple test for make sure user select options DOM value is matched. it's my test

it("select one option", async () => {
    // options value is => [{list}, {of}, {object}]

    const random = Math.floor(Math.random() * options.length)
    const input = wrapper.find(`#${checkbox_id}`)
    let opt = input.find(`input[value='${options[random].value}']`)
    opt.trigger("click")

    // this wrapper still contain default value, but i can find that component properly
    console.log(wrapper.vm.local_value)
    console.log(options[random])
    console.log(opt.html())

idk what happens with my code and how to trigger properly. please help me if you have any solution for me, also i have another question. "How to check or try catch the test is work or not in jest/vue test utils"

Thank you for your time.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda