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.