Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!