I'm trying to initiate a button click on a image, but when running the test, it keeps erroring out with find did not return cal-modal, cannot call trigger() on empty Wrapper
What am I doing wrong? Very very simplified code below:
CALENDAR.VUE
<template>
<div class="col-xs-6 text-right">
<b-img ref='cal-modal' id='cal-modal' class="cal-icon" @click="displayCal" v-b-modal.date-time-modal src="/static/img/ico.png"></b-img>
</div>
</template>
TEST FILE
import {createLocalVue, mount} from "@vue/test-utils";
import Calendar from '@/components/Calendar.vue'
import BootstrapVue from "bootstrap-vue";
const localVue = createLocalVue()
localVue.use(BootstrapVue)
it('display cal', () => {
const wrapper = mount(Calendar, {localVue});
wrapper
.find('cal-modal')
.trigger('click')
})
Try using a ref
selector or an id
selector. Like this ..
wrapper.find({ ref: 'cal-modal' })
Or
wrapper.find('#cal-modal')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With